Skip to main content
Glama
OpenAPI MCP Bridge

OpenAPI MCP Bridge

by knaman9189

OpenAPI → MCP Bridge

Make your API usable by AI agents in one command. Point it at any OpenAPI 3.x spec and it serves every endpoint as a Model Context Protocol tool. Claude, Cursor, ChatGPT and any other MCP client can then call your API, with guardrails.

openapi-mcp --spec https://api.yourcompany.com/openapi.json --bearer-env YOUR_API_TOKEN --read-only

Why this matters

Customers increasingly want to use your product from inside their AI assistant. That means "create a ticket", "pull last week's invoices" or "find the customer with email X" straight from chat. If your SaaS has an OpenAPI spec, you're one step away. This bridge handles the mechanical part and the parts that are easy to get wrong:

Concern

How it's handled

Tool generation

One tool per operation. Names come from operationId, or are built from method + path. $refs are resolved, recursive schemas are cut off safely, and descriptions come from summaries.

Agent-friendly schemas

Path, query and header params plus a body arg. Required fields are enforced and unknown args are rejected before any HTTP call.

Least privilege

--read-only exposes only GETs. --include-tags / --exclude-tags scope what's exposed, for example hiding admin.

Safety hints

MCP tool annotations: GETs are readOnlyHint, DELETEs are destructiveHint, so clients can ask the user before destructive calls.

Credentials

Read from environment variables only. The model never sees or sets auth headers, and it can't override Authorization.

Injection

Path params are fully URL-encoded, so ../admin can't escape its path segment. Redirects aren't followed.

Context-window hygiene

JSON responses are pretty-printed and truncated past a limit. Non-2xx responses come back as tool errors with the status code.

Related MCP server: MCP OpenAPI Bridge

Quick start

pip install -e ".[dev]"
pytest                                                  # 6 tests incl. a full MCP client↔server round trip
openapi-mcp --spec examples/taskboard.yaml --list       # preview the generated tools
list_projects                            GET    /projects                                [read]
create_project                           POST   /projects                                [write]
get_project                              GET    /projects/{projectId}                    [read]
delete_project                           DELETE /projects/{projectId}                    [DESTRUCTIVE]
get_projects_tasks_by_project_id         GET    /projects/{projectId}/tasks              [read]
create_task                              POST   /projects/{projectId}/tasks              [write]

6 tools

Use it from Claude Desktop, Cursor or any MCP client

{
  "mcpServers": {
    "my-api": {
      "command": "openapi-mcp",
      "args": ["--spec", "https://api.example.com/openapi.json", "--bearer-env", "MY_API_TOKEN", "--exclude-tags", "admin"],
      "env": { "MY_API_TOKEN": "..." }
    }
  }
}

Options

Flag

Purpose

--spec

Path or URL to an OpenAPI 3.x spec (JSON or YAML)

--base-url

API base URL (defaults to the spec's first servers entry)

--bearer-env

Env var holding a bearer token

--api-key-header + --api-key-env

API-key auth, for example X-API-Key

--read-only

Expose GET operations only

--include-tags / --exclude-tags

Comma-separated tag filters

--list

Print the generated tools and exit

Use as a library

from openapi_mcp.spec import load_spec, parse_operations
from openapi_mcp.executor import Executor, AuthConfig
from openapi_mcp.server import build_server

ops = parse_operations(load_spec("openapi.yaml"), exclude_tags={"admin"})
server = build_server(ops, Executor("https://api.example.com", AuthConfig(bearer_env="TOKEN")))

Going to production (what I'd add for a real rollout)

  • Curated tools: large APIs (100+ endpoints) overwhelm agents. Group endpoints into a smaller set of task-level tools, such as find_customer or refund_order, with descriptions written for the model.

  • Per-user auth: OAuth on the MCP server (Streamable HTTP transport) so each user acts with their own permissions.

  • Confirmation flows: require confirmation for write and destructive tools, rate-limit them per user, and keep an audit log.

  • Evals: a test suite of natural-language tasks, checking that the agent picks the right tool with the right arguments.

Need an MCP server or AI integration for your product?

I'm Naman Kaushik, a backend and applied-AI engineer with 15 years of experience. I built an internal MCP tooling directory covering roughly 4,250 tools across 162 servers, plus production RAG, semantic search and multi-provider LLM pipelines. I can make your product usable from Claude, ChatGPT and Cursor, safely.

→ namankaushik.me

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables MCP clients to call any OpenAPI-defined API by automatically converting its operations into tools, with built-in support for authentication, rate limiting, and response handling.
      7
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to discover and invoke tools generated from existing OpenAPI-described REST APIs through a governed MCP gateway with centralized authentication, policy-based access control, rate limiting, PII redaction, auditing, and token-efficient progressive discovery.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Turns OpenAPI 3.x REST APIs into MCP tools, enabling AI agents to call API operations without hand-written integration code.
      MIT