Skip to main content
Glama

MCPBridge

Turn any REST API into an MCP server that AI agents can use — in one command.

Point it at an OpenAPI spec. It exposes every operation as an MCP tool, wraps it in an OAuth 2.1 authorization server (so Claude, ChatGPT, Cursor and friends can connect from their hosted clients), and speaks Streamable HTTP.

npx mcpbridge serve --spec https://petstore3.swagger.io/api/v3/openapi.json
MCPBridge 0.1.0
  spec    https://petstore3.swagger.io/api/v3/openapi.json
  tools   19
  MCP     https://your-host.example.com/mcp
  consent https://your-host.example.com/authorize

Add that /mcp URL as a remote MCP server in your client. Done.

Source: https://github.com/neil-lien/mcpbridge. Deploy your own free instance (no card required, Render free tier):

Deploy to Render


Why this exists

Every API on the internet is about to become a tool call. The gap is that agents speak MCP and APIs speak OpenAPI — different transports, different auth, different shape.

Doing the translation by hand means writing a tool schema per endpoint, an HTTP client per service, and an OAuth server you did not want to build. MCPBridge is that translation layer, prebuilt:

Problem

What MCPBridge does

OpenAPI → tool schemas

Converts parameters (including $refs) into JSON Schema; descriptions from summary + description

Per-endpoint HTTP plumbing

Path params, query params (with style/explode), headers, request bodies

OAuth 2.1 for hosted clients

Dynamic client registration, authorization code + PKCE, refresh tokens, resource metadata (RFC 9728)

Secrets

The caller's API credential lives in the OAuth grant, never in the tool schema


Related MCP server: OpenAPI MCP Server

Quickstart

# 1. from an OpenAPI file on disk
npx mcpbridge serve --spec ./openapi.json

# 2. or straight from a URL
npx mcpbridge serve --spec https://api.example.com/openapi.json --upstream-token "$MY_API_KEY"

# 3. preview the generated tools without starting a server
npx mcpbridge tools --spec ./openapi.json

Default port is 3000. Set --base-url when the server is behind a proxy so the OAuth metadata advertises the right public origin:

npx mcpbridge serve --spec ./openapi.json --base-url https://mcp.example.com

Connect a client

Hosted clients (Claude.ai, ChatGPT, Cursor web) need a reachable HTTPS URL:

https://mcp.example.com/mcp

The client discovers /.well-known/oauth-protected-resource, registers itself, sends the user to your consent screen, and comes back with a bearer token. No client secrets, no manual key exchange.

For a local client that accepts a static header instead, the same URL works with Authorization: Bearer <token> — see Authentication.


CLI

mcpbridge serve [options]     # start the MCP + OAuth server
mcpbridge tools --spec <spec> # print the generated tools as JSON

Flag

Default

Meaning

--spec <path|url>

required

OpenAPI 3.x document. JSON or YAML.

--port <n>

3000

Listen port. $PORT is honoured.

--host <addr>

0.0.0.0

Listen address.

--base-url <url>

http://localhost:<port>

Public origin used in OAuth metadata.

--upstream-base <url>

spec servers[0]

Override the API the tools call.

--upstream-token <token>

—

Default credential for callers that do not supply one.

--credential-header <h>

Authorization

Header the credential is sent in. Supports a template: "X-Api-Key: {token}".

--auto-approve

off

Skip the consent screen (only for single-tenant self-hosting).

--product-name <name>

MCPBridge

Name shown on the consent screen.

--support-email <mail>

—

Contact shown on the consent screen.

--include <pattern,...>

all

Comma-separated regexes. Keeps only operations whose path, operationId, or generated tool name matches.

--page-size <n>

0

Tools per tools/list page. 0 = no pagination; see the note below before enabling it.

--json

off

Machine-readable log output.


Authentication

MCPBridge is a complete OAuth 2.1 authorization server:

  • POST /register — dynamic client registration (RFC 7591)

  • GET /authorize — consent screen, authorization code + PKCE (S256 required)

  • POST /token — code exchange and refresh rotation

  • POST /revoke — token revocation

  • GET /.well-known/oauth-authorization-server — server metadata

  • GET /.well-known/oauth-protected-resource — resource metadata (RFC 9728)

Tool calls run with the credential attached to the grant. Users paste their API token on the consent screen, or you preload one with --upstream-token. /mcp rejects any request without a valid bearer token and returns WWW-Authenticate pointing at the resource metadata, which is how clients discover the flow.

Tokens are held in memory. Running multiple instances behind a load balancer needs sticky sessions or a shared store — see Limitations.


Deploy

The image is a single Node process with no native dependencies.

docker build -t mcpbridge .
docker run -p 3000:3000 \
  -e SPEC_URL=https://petstore3.swagger.io/api/v3/openapi.json \
  -e BASE_URL=https://mcp.example.com \
  mcpbridge

Any container host works: Fly.io, Railway, Render, Cloud Run, a VPS with Caddy in front.

Free, no credit card: this repo ships a render.yaml blueprint. Push to GitHub, then Render → New → Blueprint → pick the repo. plan: free and SPEC_URL are already set, and the app reads RENDER_EXTERNAL_URL to configure its public OAuth issuer, so BASE_URL needs no manual setup. Hugging Face Spaces (Docker SDK, app_port: 3000) works the same way — the app detects SPACE_HOST.

Free instances sleep when idle (Render: ~50 s cold start), so wake /healthz before sharing the link. Point DNS at it, pass the public origin as BASE_URL, and OAuth discovery just works — as long as the URL is HTTPS and not a path-less shared subdomain the client refuses.


What gets generated

Given this OpenAPI fragment:

paths:
  /forecast:
    get:
      operationId: get_forecast
      summary: Get a weather forecast
      parameters:
        - name: latitude
          in: query
          required: true
          schema: { type: number }

MCPBridge produces:

{
  "name": "get_forecast",
  "description": "Get a weather forecast",
  "inputSchema": {
    "type": "object",
    "properties": { "latitude": { "type": "number" } },
    "required": ["latitude"]
  },
  "annotations": { "readOnlyHint": true }
}

Notable behaviour:

  • Tool names come from operationId, sanitised to [a-zA-Z0-9_-]. Collisions get a numeric suffix.

  • GET/HEAD operations are readOnlyHint: true; DELETE and body-bearing writes are destructiveHint: true.

  • Operation-level servers override the document-level one, so a spec spread across several hosts stays correct.

  • Deprecated operations are skipped unless explicitly included.

  • Local $refs are resolved; circular references degrade to { "type": "object", "additionalProperties": true } instead of exploding.

  • Responses over 60 KB are truncated, with a marker telling the model to narrow the call. Hangs are cut at 30 s so a slow upstream cannot stall an agent turn.


Real specifications

Against the 12 MB GitHub REST spec (818 paths, OpenAPI 3.0.3):

Parse

38 ms

Generate

205 ms

Tools

1196 (38 deprecated skipped)

tools/list payload

1.77 MB, ≈ 500k tokens

Half a million tokens of tool definitions is worse than useless: the agent either refuses the list or burns its context on it. Scope the surface instead of exposing it all:

mcpbridge tools --spec api.github.com.json --include "^repos_get,issues_list" | jq length

--include matches the path, the operationId, or the generated tool name — the name users actually see in tools/list (GitHub writes repos/get; the tool is repos_get).

--page-size paginates tools/list, but the reference TypeScript client's listTools() does not follow nextCursor, so it defaults to 0 (off). Enabling it is only safe with clients you know follow cursors.


Limitations

  • In-memory token store. Restarting the process invalidates every token. Fine for a single box, not for horizontal scaling.

  • No upstream OAuth. Credentials are API keys or bearer tokens, not three-legged OAuth flows against the upstream API.

  • OpenAPI 3.0/3.1 only. Swagger 2.0 is rejected with a clear error; convert it first.

  • No streaming response bodies. Tools return a single JSON payload.

  • Read-only-by-default is a hint, not a guarantee: a GET that mutates state on the server side cannot be detected here.


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

    • F
      license
      Not graded
      quality
      D
      maintenance
      Exposes any REST API as MCP tools, enabling AI agents to discover and call existing HTTP endpoints without modifying the original API.
      -
    • 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