Sponsored by Deepsite.site

Openapi To Mcp

Created By
ouvreboite9 months ago
Use any OpenAPI specification to expose an MCP server. Handle OAuth2, bearer tokens, parameters and request bodies. Fine tune the tools names and description with adhoc OpenAPI extensions.
Content

.NET Build NuGet

openapi-to-mcp

Use your OpenAPI specification to expose your API's endpoints as strongly typed tools.

Example for https://petstore3.swagger.io/ 🎉

{
  "mcpServers": {
    "petstore": {
      "command": "openapi-to-mcp",
        "args": [
          "https://petstore3.swagger.io/api/v3/openapi.json"
        ]
    }
  }
}

Install

As a Nuget tool: openapi-to-mcp

dotnet tool install --global openapi-to-mcp

Or download the executables from the releases

Usage

Usage:
  openapi-to-mcp <open-api> [options]

Arguments:
  <open-api>  You OpenAPI specification (URL or file) [required]

Options:
  -h, --host-override                          Host override
  -b, --bearer-token                           Bearer token
  -o, -o2, --oauth-2-grant-type                OAuth2 flow to be used
  <client_credentials|password|refresh_token>
  -o2.tu, --oauth-2-token-url                  OAuth2 token endpoint URL (override the one defined in your OpenAPI for
                                               your chosen OAuth2 flow)
  -o2.ci, --oauth-2-client-id                  OAuth2 client id (for the client_credentials grant_type)
  -o2.cs, --oauth-2-client-secret              OAuth2 client secret (for the client_credentials grant_type)
  -o2.rt, --oauth-2-refresh-token              OAuth2 refresh token (for the refresh_token grant_type)
  -o2.un, --oauth-2-username                   OAuth2 username (for the password grant_type)
  -o2.pw, --oauth-2-password                   OAuth2 password (for the password grant_type)
  -i, --instructions                           MCP instruction to be advertised by the server
  -?, -h, --help                               Show help and usage information
  -v, --version                                Show version information

OpenAPI support

  • Currently, OpenAPI 2.0 and 3.0 are supported.
  • Specifications can be JSON/YAML and local (file) or remote (URL)
  • Only local $refs are supported

Custom extensions

A set of custom extensions is available to customize how your API should be exposed:

  • info.x-mcp-instructions (string): Textual instructions exposed by the MCP server during the initialize handshake
  • operation.x-mcp-tool-name (string): Custom tool name
  • operation.x-mcp-tool-description (string): Custom tool description
  • operation.x-mcp-tool-enabled (boolean): Enabled/disabled a specific operation (enabled by default)

MCP features

Only STDIO transport is currently supported.

Tools

Operations ("endpoints") from your OpenAPI specification are translated to MCP tools

  • All path/query/JSON body parameters are exposed (using their JSON schema)
  • Response is returned as-is
  • Tools name are extracted as follows: operation.x-mcp-tool-name ?? operation.operationId ?? {httpMethod}_{escaped_path}
    • ⚠️Tools are discarded if their name don't match ^[a-zA-Z0-9_-]{1,64}$
  • Tools description are extracted as follows: operation.x-mcp-tool-description ?? operation.description ?? path.description

Tool call and host

When a tool is called, the MCP server will call the underlying endpoint. To determine which host to call a combination of parameters are used:

  • the --host-override option
  • your specification first server's URL if it's an absolute URL
  • the host of the remote OpenAPI provided
  • otherwise, an error is thrown

For example running openapi-to-mcp https://petstore3.swagger.io/api/v3/openapi.json:

Authorization

Bearer token

A token can be provided as option --bearer-token. It'll be provided to all calls as the Authorization: Bearer {token} header. It'll also be provided when fetching a remote specification.

OAuth2

ClientCredentials, RefreshToken, Password are supported. If your OpenAPI specification declare securitySchemes for those flows, the corresponding tokenUrl will be used.

How to publish

Create a new tag/release 🤷

Server Config

{
  "mcpServers": {
    "petstore": {
      "command": "openapi-to-mcp",
      "args": [
        "https://petstore3.swagger.io/api/v3/openapi.json"
      ]
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
ChatWiseThe second fastest AI chatbot™
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
DeepChatYour AI Partner on Desktop
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Tavily Mcp
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Playwright McpPlaywright MCP server
Serper MCP ServerA Serper MCP Server
CursorThe AI Code Editor
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
Amap Maps高德地图官方 MCP Server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
WindsurfThe new purpose-built IDE to harness magic
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.