GitHub - janwilmake/openapi-to-mcp: Attempt at creating an MCP for every OpenAPI

2 min read Original article ↗

OpenAPI to MCP

Thread

OpenAPI-to-MCP automatically discovers OpenAPI specs, builds proper MCP configurations, and proxies requests with full parameter handling and authentication support!

To test, run npx @modelcontextprotocol/inspector and use any API as MCP by passing url https://mcp.openapisearch.com/{hostname}/mcp

Please note, the openapi can provide a filter to the tools used for MCP by providing info.x-mcp with:

type MCPConfig = {
  /** defaults to 2025-03-26 */
  protocolVersion?: string;
  /** GET endpoint that returns MCP-compatible 401 if authentication isn't valid.
   *
   * e.g. '/me'
   *
   * Will be used before responding with "initialize" and '.../list' methods
   */
  authEndpoint?: string;
  serverInfo?: {
    name: string;
    version: string;
  };
  promptOperationIds?: string[];
  toolOperationIds?: string[];
  resourceOperationIds?: string[];
};

For example:

{
  "openapi": "3.0.3",
  "info": {
    "x-mcp": {
      "protocolVersion": "2025-03-26",
      // this would only enable the myOperation operation, not the other ones
      "toolOperationIds": ["myOperation"]
    }
    //... other info
  }
  "paths": {
    "/some/operation":{
      "get": {
        "operationId": "myOperation",
        //...config
      }
    }
    ///.....
  },
  //.....
}

Also, please note that it is expected that IF the OpenAPI server exposes OAUTH, it follows the MCP recommenation/specification: https://modelcontextprotocol.io/specification/draft/basic/authorization.

Example: https://mcp.openapisearch.com/curlmcp.com/mcp

Should be the same as https://curlmcp.com/mcp since it's based on https://curlmcp.com/openapi.json

Earlier attempt:

https://x.com/janwilmake/status/1913196601679523922

https://x.com/janwilmake/status/1913660585356501195

SPECS

Idea:

  • Improve openapisearch such that it tracks used openapi specs found through the MCP (see https://github.com/janwilmake/openapisearch)
  • Create remote MCP-server for each OpenAPI (this repo)
  • Create remote A2A-server for each OpenAPI (not started)
  • Set this up in a modular way such that others can easily contribute other specs (not started)

Experiments: