Overview
FastAPI-MCP exposes the endpoints of an existing FastAPI application as Model Context Protocol tools, so an agent can call the API you already run. The pitch is minimal work: point it at your app, mount it, and the MCP server is served from the same application at /mcp.
It describes itself as FastAPI-native rather than "another OpenAPI to MCP converter", and the difference is visible in three places. Authentication reuses your existing FastAPI dependencies — the same `Depends()` you already wrote guards the MCP endpoints, rather than a parallel auth story. The request and response model schemas and the endpoint documentation carry through, so tools arrive described the way Swagger describes them. And communication happens over FastAPI's ASGI interface directly, so the MCP layer does not make HTTP calls back into your own API.
Deployment is flexible: mounting the MCP server into the same app is the default, and the documentation also covers deploying it separately from the original FastAPI app when you want the two to scale or be secured apart. The package is MIT-licensed, published on PyPI as `fastapi-mcp`, and requires Python 3.10+ (3.12 recommended). Tadata, the company behind it, also offers a hosted service.
What it does
- Mounts an MCP server into an existing FastAPI app with near-zero configuration
- Authentication and authorization through your existing FastAPI Depends() dependencies
- Preserves request/response model schemas and endpoint documentation in the generated tools
- Talks to the app over FastAPI's ASGI interface instead of issuing HTTP calls to itself
- Deploy mounted in the same app, or separately from the original FastAPI service
- Published on PyPI with CI and coverage, MIT-licensed, Python 3.10+
Getting started
Add the package, then wrap your FastAPI app. The README's own example is four lines of code beyond the imports.
Install the package
The project recommends uv; pip works the same way.
uv add fastapi-mcp
# or
pip install fastapi-mcpMount the MCP server on your app
Wrap the FastAPI instance and call mount(). The MCP server is then served at https://app.base.url/mcp.
from fastapi import FastAPI
from fastapi_mcp import FastApiMCP
app = FastAPI()
mcp = FastApiMCP(app)
# Mount the MCP server directly to your FastAPI app
mcp.mount()Keep your existing auth
Because the generated tools run inside your app, the dependencies you already use for authentication and authorization apply to them too — see the documentation's auth section for the patterns.
Deploy separately if you need to
The documentation covers running the MCP server apart from the original FastAPI app, for cases where the two should be scaled or exposed differently.
Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Reach for it when an agent needs to call an internal service you have already built in FastAPI, without writing an MCP server by hand
- Expose a subset of an API to agents while keeping the same dependency-based authentication the human-facing routes use
- Give agents tools whose schemas and descriptions match your Swagger docs, so tool definitions stay in sync with the API
- Run the MCP surface as a separate deployment when agent traffic should not share the main app's process
How FastAPI-MCP compares
FastAPI-MCP alongside other open-source agent frameworks & builders tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| DeepSeek Harness | ★ 226k | DeepSeek AI's open-source agent harness (dsh), built on Cordis, where models, tools, skills, sessions, sandboxes, storage and the UI are all plugins composed through profiles. |
| AutoGPT | ★ 187k | One of the earliest autonomous agent projects, now a platform for building and running agents from reusable blocks and workflows. |
| DeerFlow | ★ 82.5k | ByteDance's open-source super agent harness built on LangGraph: skills, sub-agents, sandboxes, a filesystem and long-term memory for long-horizon research, coding and content tasks. |
| nanobot | ★ 48.2k | Lightweight self-hosted personal AI agent framework in Python, with a WebUI, terminal and chat-app channels, tools, long-term memory, MCP and scheduled automations. |
| Agno | ★ 42.2k | A fast Python framework (formerly Phidata) for building agents with memory, tools, and multimodal inputs, plus a runtime for deploying them in production. |
| LangGraph | ★ 41.8k | A library from the LangChain team for building stateful, graph-based agent workflows with explicit control over steps, memory, and human-in-the-loop checkpoints. |
| AgentGPT | ★ 36.3k | AgentGPT lets you name a custom AI, give it a goal, and watch it plan tasks, run them, and learn from the results, all from a web browser. |
| FastAPI-MCP | ★ 12k | Turn the FastAPI app you already have into MCP tools, with its own auth |