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.
Metadata
Release files for mcp-openapi 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mcp_openapi-0.0.2.tar.gz | 63.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_openapi-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 70.8 kB
Release files / mcp_openapi-0.0.2.tar.gz
| Download URL | mcp_openapi-0.0.2.tar.gz |
|---|---|
| Size | 63.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2aa47237e62df243e647b92c839adad3c5c2838f77ea043953f285c8e76d0e54
|
|
BLAKE2b-256 checksum How to use checksums |
09796a80c298e62d3325a8fe2a0759c031e5f9736cf1a2182ae635c12c2a2501
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2025.
Transparency logRelease files / mcp_openapi-0.0.2-py3-none-any.whl
| Download URL | mcp_openapi-0.0.2-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3974b70774b4f89eb410600416b6f715666f8cb52b40ca20cf06fbe81485c134
|
|
BLAKE2b-256 checksum How to use checksums |
e3831468897f04a3c820b029b29a0b4f39af610773297dd350fbc25fbc43ea2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2025.
Transparency logSecurity for mcp-openapi 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for mcp_openapi-0.0.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.