Use your OpenAPI specification to expose your API's endpoints as strongly typed tools. Basic example for https://petstore3.swagger.io/ π More complex example, using Github's API: This example use the bearer token auth (with a Github Personal Access Token) and force the tool naming strategy to "verb and path", as Github's operation ids are not valid tool names. As a Nuget tool: openapi-to-mcp Or d
Add this skill
npx mdskills install ouvreboite/openapi-to-mcpDynamically converts OpenAPI specs into MCP tools with clear setup and working examples
1[](https://github.com/ouvreboite/openapi-to-mcp/actions/workflows/build_and_test.yml)2[](https://www.nuget.org/packages/openapi-to-mcp)34# openapi-to-mcp56Use your OpenAPI specification to expose your API's endpoints as strongly typed tools.78Basic example for https://petstore3.swagger.io/ π910```json11{12 "mcpServers": {13 "petstore": {14 "command": "openapi-to-mcp",15 "args": [16 "https://petstore3.swagger.io/api/v3/openapi.json"17 ]18 }19 }20}21```2223More complex example, using Github's API:24```25{26 "mcpServers": {27 "github": {28 "command": "openapi-to-mcp",29 "args": [30 "https://raw.githubusercontent.com/github/rest-api-description/refs/heads/main/descriptions/api.github.com/api.github.com.yaml",31 "--bearer-token",32 "github_pat_xxxxxx",33 "--tool-naming-strategy",34 "verbandpath"35 ]36 }37 }38}39```4041This example use the bearer token auth (with a Github [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic)) and force the tool naming strategy to "verb and path", as Github's operation ids are not valid tool names.42434445## Install4647As a Nuget tool: [openapi-to-mcp](https://www.nuget.org/packages/openapi-to-mcp)48```sh49dotnet tool install --global openapi-to-mcp50```51Or download the executables from the [releases](https://github.com/ouvreboite/openapi-to-mcp/releases)5253## Usage545556```bash57Usage:58 openapi-to-mcp <open-api> [options]5960Arguments:61 <open-api> You OpenAPI specification (URL or file) [required]6263Options:64 -t, --tool-naming-strategy <extension|extension_or_operationid_or_verbandpath|operationid|verbandpath> How the tool name should be computed [default: extension_or_operationid_or_verbandpath]65 -h, --host-override Host override66 -b, --bearer-token Bearer token67 -o2, --oauth-2-grant-type <client_credentials|password|refresh_token> OAuth2 flow to be used68 -o2_tu, --oauth-2-token-url OAuth2 token endpoint URL (override the one defined in your OpenAPI for your chosen OAuth2 flow)69 -o2_ci, --oauth-2-client-id OAuth2 client id (for the client_credentials grant_type)70 -o2_cs, --oauth-2-client-secret OAuth2 client secret (for the client_credentials grant_type)71 -o2_rt, --oauth-2-refresh-token OAuth2 refresh token (for the refresh_token grant_type)72 -o2_un, --oauth-2-username OAuth2 username (for the password grant_type)73 -o2_pw, --oauth-2-password OAuth2 password (for the password grant_type)74 -i, --instructions MCP instruction to be advertised by the server75 --verbose Log more info (in sdterr) [default: False]76 -?, -h, --help Show help and usage information77 --version Show version information78```7980## OpenAPI support8182- Currently, OpenAPI 2.0 and 3.0 are supported.83 - 3.1 is not (at least not until [microsoft/OpenAPI.NET](https://github.com/microsoft/OpenAPI.NET) supports it)84- Specifications can be JSON/YAML and local (file) or remote (URL)85- Only local $refs are supported8687### OpenAPI custom extensions8889A set of custom extensions is available to customize how your API should be exposed:90- `info.x-mcp-instructions` (string): Textual instructions exposed by the MCP server during the initialize handshake91- `operation.x-mcp-tool-name` (string): Custom tool name92- `operation.x-mcp-tool-description` (string): Custom tool description93- `operation.x-mcp-tool-enabled` (boolean): Enabled/disabled a specific operation (enabled by default)9495## MCP features9697Only STDIO transport is currently supported.9899### Tools100Operations ("endpoints") from your OpenAPI specification are translated to MCP [tools](https://modelcontextprotocol.io/docs/concepts/tools)101- All path/query/JSON body parameters are exposed (using their JSON schema)102- Response is returned as-is103- By default, the tool name is computed using first the `operation.x-mcp-tool-name` extension, then the [operation.operationId](https://swagger.io/docs/specification/v3_0/paths-and-operations/#operationid) and then `{httpMethod}_{escaped_path}`104 - The tool naming strategy can be defined via the `--tool-naming-strategy` option.105 - β οΈTools are discarded if their name don't match `^[a-zA-Z0-9_-]{1,64}$`106- Tools description are extracted as follows: `operation.x-mcp-tool-description` ?? `operation.description` ?? `path.description`107108### Tool call and host109110When a tool is called, the MCP server will call the underlying endpoint. To determine which host to call a combination of parameters are used:111- the `--host-override` option112- your specification first [server](https://swagger.io/docs/specification/v3_0/api-host-and-base-path/)'s URL if it's an absolute URL113- the host of the remote OpenAPI provided114- otherwise, an error is thrown115116For example running `openapi-to-mcp https://petstore3.swagger.io/api/v3/openapi.json`:117- https://petstore3.swagger.io/api/v3/openapi.json defines a server, but its URL is relative (/api/v3)118- so the host of the specification's own URL is used: https://petstore3.swagger.io and the relative path of the server is appended to it119120## Authorization121122### Bearer token123124A token can be provided as option `--bearer-token`. It'll be provided to all calls as the `Authorization: Bearer {token}` header.125It'll also be provided when fetching a remote specification.126127### OAuth2128129ClientCredentials, RefreshToken, Password are supported.130If your OpenAPI specification declare [securitySchemes](https://swagger.io/docs/specification/v3_0/authentication/oauth2/) for those flows, the corresponding `tokenUrl` will be used.131132## How to publish133134Create a new tag/release π€·
Full transparency β inspect the skill content before installing.