FastAPI
by tadata-org
FastAPI-MCP mounts an MCP server directly onto an existing FastAPI app, turning its endpoints into MCP tools with the same auth already protecting them.
About
FastAPI-MCP isn't a generic OpenAPI-to-MCP converter — it's built as a native FastAPI extension. Three lines (FastAPI(), FastApiMCP(app), mcp.mount_http()) are enough to expose an app's existing endpoints as MCP tools at /mcp, with request/response schemas, docstrings, and parameter descriptions carried over from the FastAPI route definitions rather than regenerated.
Because it talks to the underlying app through FastAPI's ASGI interface instead of making real HTTP round-trips, tool calls skip the network hop entirely. Auth is handled the same way FastAPI already handles it: securing MCP endpoints is just adding your existing Depends() dependencies, including full support for MCP-compliant OAuth 2.1 flows, so you don't maintain a second authorization system alongside your API's.
Key features
- Converts existing FastAPI endpoints into MCP tools automatically, no separate tool definitions to maintain
- Uses FastAPI's ASGI interface directly instead of real HTTP requests between the API and the MCP server
- Reuses FastAPI's Depends() system for MCP endpoint authentication, including OAuth 2.1 support
- Preserves request/response schemas and route documentation instead of regenerating them
- Can mount the MCP server on the same app or deploy it separately
- Supports both streamable HTTP and SSE transports (mount_http / mount_sse)
Use cases
- Give an agent tool access to an internal API you've already built, without hand-writing a matching MCP tool for every route
- Expose a FastAPI service to Claude Desktop or Cursor while keeping the exact same auth policy the REST API already enforces
- Let an agent call authenticated endpoints on your own backend using OAuth instead of a shared API key
- Stand up an MCP server for a FastAPI microservice in three lines instead of building one from a bare SDK
Available tools
FastApiMCP(app)
Wraps a FastAPI app instance and generates MCP tools from its existing route definitions.
mount_http()
Mounts the generated MCP server onto the FastAPI app using the streamable HTTP transport.
mount_sse()
Mounts the generated MCP server using the SSE transport instead of streamable HTTP.
Frequently asked questions
Do I need to write a separate tool schema for every endpoint I want to expose?
No — FastAPI-MCP generates the MCP tool automatically from each route's existing FastAPI definition, including its request/response models and docstring.
Can I require the same authentication for MCP tool calls that my REST API already uses?
Yes — you secure the MCP server the same way you secure any FastAPI route, by attaching your existing Depends() dependencies, including OAuth 2.1-compliant flows.