SuperAPIAI Directory

openapi-mcp-gateway

github.com · AI developer platforms

Mount multiple OpenAPI specs or a FastAPI app as MCP servers in one process, exposing GET endpoints as resources and large specs through meta-tools.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

Purpose

OpenAPI MCP Gateway is used to convert OpenAPI (Swagger) specifications or existing FastAPI applications into Model Context Protocol (MCP) servers, for MCP clients such as Claude Code, Codex, and Cursor to connect to.

Main Capabilities

  • Multiple specifications, multiple authentications: Supports mounting multiple APIs in a single process, each API having its own independent mount path and authentication method, allowing GitHub, OAuth2 SaaS services, and internal APIs to be mounted simultaneously, with their token namespaces independent of each other.
  • Specification-compliant authorization: The gateway runs its own OAuth server and issues audience-bound upstream tokens, so MCP client credentials are not replayed to third parties. Supports authorization_code、client_credentials and token_exchange flows.
  • Tool reshaping: Operation IDs can be renamed via YAML, parameters that the model should not touch can be hidden, and requests and responses can be rewritten using JSONata, without forking the specification.
  • Dynamic exposure: Use the three meta-tools list → get → call to proxy specifications containing about 1,200 operations, avoiding consuming the entire context window on connection.
  • Resources rather than just tools: Qualifying read-only GET operations are registered as MCP resources, addressed by URI and presented by the client, rather than guessed by the model.
  • FastAPI native: Use @mcp_tool to decorate routes, and they can be exposed in-process via ASGI, with no extra hop or need to maintain a second specification.
  • Protocol-native features: Every registered tool carries a title and annotations (readOnlyHint, destructiveHint, idempotentHint), and results include structuredContent.

Usage

Requires Python 3.11+. You can run the published package directly via uvx openapi-mcp-gateway , or use uv run openapi-mcp-gateway --config servers.yml to run a configuration file. For unauthenticated public APIs, MCP clients can connect to http://127.0.0.1:8000/petstore/mcp. A configuration file can be used to explicitly specify authentication headers; service token flows can add --auth-flow client_credentials. It can also be used via stdio for local desktop clients such as Claude Desktop. The configuration merge order is: defaults → YAML (--config) → CLI flags → Gateway.run(...) kwargs. String fields support ${ENV_VAR} and ${ENV_VAR:-default} environment variables, resolved at request time; unrecognized keys are rejected at startup.

Applicable Scenarios

  • Scenarios where multiple OpenAPI specifications need to be exposed uniformly to MCP clients.
  • OAuth2 authorization scenarios where each end user needs an independent upstream token.
  • Specifications with a large number of operations where you want to save the LLM context window.
  • Scenarios where you want to expose read-only GET endpoints as resources rather than tools.
  • Existing FastAPI applications that you want to expose in-process as an MCP server.

Limitations

  • Requires Python 3.11+.
  • token_exchange requires the oidc extra dependency, and startup is refused if it is not installed; this mode requires an issuer and an audience.
  • Token exchange support varies by identity provider; Keycloak requires an additional audience mapper, exchange client configuration, and exchange target configuration.
  • passthrough applies only to FastAPI in-process integration, and using it for genuinely standalone upstream APIs constitutes a confused-deputy pattern prohibited by the specification.
  • Resource support is uneven across the ecosystem, and agent frameworks that completely ignore resources will be unable to access promoted operations.
  • Subscription functionality is not implemented, because REST has no native push.
  • authorization_code Under this, the gateway's own access token is valid for 1 hour and the refresh token for 24 hours;token_exchange does not issue tokens, and the lifetime is set by the issuer.
  • params When set, params_strategy is required; unknown operationIds cause an error at startup.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools