Expose any OpenAPI/Swagger API as Model Context Protocol (MCP) tools over stdio.
Project description
openapi-mcp-bridge
Turn any OpenAPI/Swagger API into Model Context Protocol tools. Point the bridge at a spec (URL or local file) and every endpoint becomes an MCP tool that an AI assistant — Claude Desktop, or any MCP client — can call directly. The bridge constructs the real HTTP request, sends it, and returns the response to the model.
- 🔧 One tool per endpoint — names from
operationId, JSON Schema inputs built from parameters and request bodies. - 📥 OpenAPI 3.x and Swagger 2.0 — both normalised to the same model.
- 🔌 stdio transport built on the official
mcpSDK. - 🔒 No secrets in code — every credential comes from an environment variable.
- ✅ Typed, tested, and linted.
Installation
pip install openapi-mcp-bridge
Or install it as an isolated CLI tool:
pipx install openapi-mcp-bridge
It requires Python 3.10+.
Quickstart
List the tools generated from the public Swagger Petstore spec (this does not start a server — handy for inspecting what will be exposed):
openapi-mcp-bridge --spec https://petstore3.swagger.io/api/v3/openapi.json --list-tools
Run it as an MCP server over stdio:
openapi-mcp-bridge --spec https://petstore3.swagger.io/api/v3/openapi.json
You can also invoke it as a module:
python -m openapi_mcp_bridge --spec ./openapi.yaml
Use with Claude Desktop
Add an entry to your claude_desktop_config.json:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"petstore": {
"command": "openapi-mcp-bridge",
"args": ["--spec", "https://petstore3.swagger.io/api/v3/openapi.json"],
"env": {
"OPENAPI_MCP_TOKEN": "your-bearer-token-here"
}
}
}
}
If you do not have the console script on your PATH, you can run it with
uv without installing anything:
{
"mcpServers": {
"petstore": {
"command": "uvx",
"args": [
"openapi-mcp-bridge",
"--spec",
"https://petstore3.swagger.io/api/v3/openapi.json"
]
}
}
}
Restart Claude Desktop after editing the config. The same command/args/env
shape works for any MCP client (e.g. Cursor, Continue, or a custom one).
Command-line options
| Option | Description |
|---|---|
--spec (required) |
OpenAPI/Swagger spec to load: an http(s) URL or a file path. |
--base-url |
Override the API server base URL declared in the spec. |
--name |
MCP server name (defaults to the spec's info.title). |
--timeout |
Per-request HTTP timeout in seconds (default 30). |
--list-tools |
Print the generated tools and exit without starting the server. |
--version |
Print the version and exit. |
Configuration & authentication
Credentials and connection settings are read from environment variables. No secret is ever stored in code or in the spec.
| Variable | Purpose |
|---|---|
OPENAPI_MCP_BASE_URL |
Override the API base URL (same as --base-url). |
OPENAPI_MCP_TOKEN |
Bearer token → Authorization: Bearer <token>. |
OPENAPI_MCP_API_KEY |
Secret for an apiKey scheme; the header/query name and location are taken from the spec (default header X-API-Key). |
OPENAPI_MCP_BASIC_USERNAME / OPENAPI_MCP_BASIC_PASSWORD |
HTTP Basic credentials. |
OPENAPI_MCP_EXTRA_HEADERS |
JSON object of extra headers merged into every request; overrides derived auth headers. |
OPENAPI_MCP_TIMEOUT |
Per-request timeout in seconds (same as --timeout). |
OPENAPI_MCP_VERIFY_TLS |
Set to false/0/no to disable TLS verification (not recommended). |
A bearer token takes priority over basic credentials. Need a custom auth header
the spec doesn't describe? Use OPENAPI_MCP_EXTRA_HEADERS, e.g.
{"X-Custom-Auth": "value"}.
How it works
- Load the spec from a URL or file (JSON or YAML) and resolve intra-document
$refpointers, with cycle protection. - Normalise OpenAPI 3.x / Swagger 2.0 into a single internal model of operations, parameters, request bodies, and security schemes.
- Generate one MCP tool per operation. Path/query/header parameters become
top-level JSON Schema properties; the request body becomes a
bodyproperty. - Proxy each tool call to a real HTTP request — substituting path parameters, attaching the query string, injecting auth, and sending the body — then return the status line and response body to the model.
Development
git clone https://github.com/sssdavid529/openapi-mcp-bridge.git
cd openapi-mcp-bridge
python -m venv .venv && pip install -e ".[dev]"
ruff check . && ruff format --check . && pytest
See CONTRIBUTING.md for more.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openapi_mcp_bridge-0.1.0.tar.gz.
File metadata
- Download URL: openapi_mcp_bridge-0.1.0.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8384ea6be0fb09d70e98842ddabf46b15f7ca2ca314f539f256e44c50512350f
|
|
| MD5 |
78cfa73ba41514a497ff6029bbdaada8
|
|
| BLAKE2b-256 |
211df28cf555f4a20443e8c874e054a719ceb3636a8266db4ea0c8c9e8c7614c
|
Provenance
The following attestation bundles were made for openapi_mcp_bridge-0.1.0.tar.gz:
Publisher:
release.yml on sssdavid529/openapi-mcp-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_mcp_bridge-0.1.0.tar.gz -
Subject digest:
8384ea6be0fb09d70e98842ddabf46b15f7ca2ca314f539f256e44c50512350f - Sigstore transparency entry: 1683725395
- Sigstore integration time:
-
Permalink:
sssdavid529/openapi-mcp-bridge@a752d098e03d477580594070e663dd1165ca83c9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sssdavid529
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a752d098e03d477580594070e663dd1165ca83c9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openapi_mcp_bridge-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openapi_mcp_bridge-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd84a8970eec6e01e106fb393c0d9f8fbbe04b2124a9a2fdd80ce9c3c6897aac
|
|
| MD5 |
1a319a5d6be3f76af3542154d0acf77e
|
|
| BLAKE2b-256 |
c91dd6558bcdaff26e4711cfade3f3a0c867898d9c1ed97be391376c2bd3c792
|
Provenance
The following attestation bundles were made for openapi_mcp_bridge-0.1.0-py3-none-any.whl:
Publisher:
release.yml on sssdavid529/openapi-mcp-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_mcp_bridge-0.1.0-py3-none-any.whl -
Subject digest:
bd84a8970eec6e01e106fb393c0d9f8fbbe04b2124a9a2fdd80ce9c3c6897aac - Sigstore transparency entry: 1683725637
- Sigstore integration time:
-
Permalink:
sssdavid529/openapi-mcp-bridge@a752d098e03d477580594070e663dd1165ca83c9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sssdavid529
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a752d098e03d477580594070e663dd1165ca83c9 -
Trigger Event:
push
-
Statement type: