Add your description here
Project description
MCP-OpenAPI
A Model Context Protocol server that exposes HTTP methods from an OpenAPI spec as tools.
[!WARNING] This is a proof of concept, yet to be fully tested and documented.
Usage
Each MCP-OpenAPI server exposes operations from a single OpenAPI spec. You could run multiple instances to expose multiple specs.
This package is available on PyPI @ [mcp-openapi][pypi]. You can start a server with uvx mcp-openapi --openapi-url https://httpbin.org/spec.json (sse | stdio).
An example Claude config (while running fastapi dev tests/todos.py with port 8000):
{
"mcpServers": {
"todos": {
"command": "uvx",
"args": [
"mcp-openapi",
"--openapi-url=http://localhost:8000/openapi.json",
"stdio"
]
}
}
}
The OpenAPI url can also be passed as an environment variable, MCP_OPENAPI_URL.
When running as SSE, you can configure the server with:
--fastmcp-sse-host- the host to serve the MCP server on--fastmcp-sse-port- the port to serve the MCP server on
There are additional global options:
--fastmcp-debug- enable debug mode for the MCP server--fastmcp-log-level- the log level for the MCP server
These can also be configured via environment variables using the FASTMCP_ prefix, e.g. FASTMCP_LOG_LEVEL=DEBUG.
How it works
- The MCP-OpenAPI server is initialised with an OpenAPI spec URL.
- The server fetches and parses the OpenAPI spec, and registers each path-operation as a tool.
- A FastMCP server is started with the registered tools.
- When a client requests a tool, the MCP server makes a HTTP request to the API and returns the response.
Supported OpenAPI/Swagger versions
| Swagger 2.0 | OpenAPI 3.0 | OpenAPI 3.1 |
|---|---|---|
| :x: | :heavy_check_mark: | :heavy_check_mark: |
This package supports OpenAPI 3.0 and 3.1 specs, in JSON and YAML formats.
We're using openapi-parser under the hood, which seems to be pretty comprehensive, and supports resolving references to external specs.
Future configuration options
[!INFO] These are still to be implemented.
Restricting endpoints
By default, all endpoints are exposed as tools. You can restrict which endpoints are exposed:
- By path patterns,
- By HTTP method,
- Explicitly listing the individual operations to expose,
- Selecting routes using OpenAPI tags.
Handling API authentication
MCP-OpenAPI makes API requests to the target API - it can use a global auth token:
--auth-token- a bearer token, or basic credentials in base64 format, used depending on the OpenAPI spec.
It would be nice to be able to make requests using varying authentication tokens (e.g. per client user), but without having the LLM see the tokens. TBD.
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 mcp_openapi-0.0.1.tar.gz.
File metadata
- Download URL: mcp_openapi-0.0.1.tar.gz
- Upload date:
- Size: 63.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ed122cd75cfa5d9324fc88e1c8c7d31a8e88650890f4791419ecee4a11389e6
|
|
| MD5 |
1bf7f4805c58ae017cffe63de62d84bb
|
|
| BLAKE2b-256 |
5dee17c9e16b974b58ebac647aaca9580b1fc6c5ac6230c06488d74913e424ec
|
Provenance
The following attestation bundles were made for mcp_openapi-0.0.1.tar.gz:
Publisher:
release.yml on rmasters/mcp-openapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_openapi-0.0.1.tar.gz -
Subject digest:
1ed122cd75cfa5d9324fc88e1c8c7d31a8e88650890f4791419ecee4a11389e6 - Sigstore transparency entry: 173546608
- Sigstore integration time:
-
Permalink:
rmasters/mcp-openapi@3c954be3d0ea5b6a36c81e085af6054154631680 -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/rmasters
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3c954be3d0ea5b6a36c81e085af6054154631680 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_openapi-0.0.1-py3-none-any.whl.
File metadata
- Download URL: mcp_openapi-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07d9ac9098a904f31141bb3033d5cf38463f29439935f859df68c87baf9fb891
|
|
| MD5 |
ac42436e076d4d578016ada175858dc5
|
|
| BLAKE2b-256 |
7ab2b5082248e2812fce848592232f07f58e1fed2a8faf54c904dc22540e30cf
|
Provenance
The following attestation bundles were made for mcp_openapi-0.0.1-py3-none-any.whl:
Publisher:
release.yml on rmasters/mcp-openapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_openapi-0.0.1-py3-none-any.whl -
Subject digest:
07d9ac9098a904f31141bb3033d5cf38463f29439935f859df68c87baf9fb891 - Sigstore transparency entry: 173546610
- Sigstore integration time:
-
Permalink:
rmasters/mcp-openapi@3c954be3d0ea5b6a36c81e085af6054154631680 -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/rmasters
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3c954be3d0ea5b6a36c81e085af6054154631680 -
Trigger Event:
release
-
Statement type: