FastAPI MCP server
Turns your FastAPI endpoints into MCP tools, preserving request/response schemas and using your existing FastAPI auth dependencies.
Also known as tadata-org/fastapi_mcp, fastapi-mcp
- Stars
- 12,030
- Tools
- —
- Downloads, 30 days
- —
- Latest version
- —
- Last commit
- Nov 24, 2025
- License
- MIT
What is FastAPI MCP?
FastAPI turns your FastAPI endpoints into MCP tools, preserving request/response schemas and using your existing FastAPI auth dependencies.
Summary generated from the project's README
About FastAPI MCP server
Exposing existing API endpoints to AI models is what developers achieve by using fastapi_mcp. This tool transforms FastAPI endpoints into Model Context Protocol tools while maintaining the original request and response schemas. It is designed for Python developers who want to integrate their current web services with AI clients without rebuilding their logic from scratch.
Integration is straightforward because it functions as a native extension of your application. You can mount the MCP server directly to your existing FastAPI app or choose a separate deployment. The system uses ASGI transport to communicate directly with your application, which avoids the overhead of making extra HTTP calls. Because it is built into the FastAPI ecosystem, you can secure your tools using your existing Depends() authentication and authorization dependencies.
Setting up the server requires minimal configuration. Once mounted, the server becomes available at a specific endpoint on your base URL. It preserves all documentation from your Swagger UI, ensuring that the AI understands the purpose and structure of every tool provided.
What you can do with it
- 1Secure API exposureAn AI client can interact with protected endpoints using your established security protocols.
- 2Automated tool generationConvert your entire existing API suite into MCP tools with almost no manual setup.
- 3Schema-aware AI interactionsEnsure the AI model understands exactly what data to send and what to expect in return.
- 4Efficient local integrationConnect your AI to your web services without the latency of external HTTP requests.
Written from the project's README. Every use case is checked against a quote from it.
Automated checks
Ran Nov 14, 2026Full report →Not verified yet. A server needs a score of 80, no serious finding, and enough data for us to check. How checks work · What to fix for more points
- Source repository linked and reachabletadata-org/fastapi_mcp is public and reachablegithub.com/tadata-org/fastapi_mcp ↗Pass
- Package names this repository as its sourceNot checked
- Build provenance (Sigstore attestation)Not checked
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit or release 2025-11-24github.com/tadata-org/fastapi_mcp ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNot checked
- No critical advisory in the package or its dependenciesNot checked
- No hidden instructions to the model0 tool descriptions and the README read; no override phrases, credential paths or hidden charactersPass
- Destructive tools are labelledNot checked
- Remote endpoint answers the MCP handshakeNot checked
README
View on GitHubFeatures
-
Authentication built in, using your existing FastAPI dependencies!
-
FastAPI-native: Not just another OpenAPI -> MCP converter
-
Zero/Minimal configuration required - just point it at your FastAPI app and it works
-
Preserving schemas of your request models and response models
-
Preserve documentation of all your endpoints, just as it is in Swagger
-
Flexible deployment - Mount your MCP server to the same app, or deploy separately
-
ASGI transport - Uses FastAPI's ASGI interface directly for efficient communication
Hosted Solution
If you prefer a managed hosted solution check out tadata.com.
Installation
We recommend using uv, a fast Python package installer:
uv add fastapi-mcp
Alternatively, you can install with pip:
pip install fastapi-mcp
Basic Usage
The simplest way to use FastAPI-MCP is to add an MCP server directly to your FastAPI application:
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()
That's it! Your auto-generated MCP server is now available at https://app.base.url/mcp.
Documentation, Examples and Advanced Usage
FastAPI-MCP provides comprehensive documentation. Additionaly, check out the examples directory for code samples demonstrating these features in action.
FastAPI-first Approach
FastAPI-MCP is designed as a native extension of FastAPI, not just a converter that generates MCP tools from your API. This approach offers several key advantages:
-
Native dependencies: Secure your MCP endpoints using familiar FastAPI
Depends()for authentication and authorization -
ASGI transport: Communicates directly with your FastAPI app using its ASGI interface, eliminating the need for HTTP calls from the MCP to your API
-
Unified infrastructure: Your FastAPI app doesn't need to run separately from the MCP server (though separate deployment is also supported)
This design philosophy ensures minimum friction when adding MCP capabilities to your existing FastAPI services.
Development and Contributing
Thank you for considering contributing to FastAPI-MCP! We encourage the community to post Issues and create Pull Requests.
Before you get started, please see our Contribution Guide.
Community
Join MCParty Slack community to connect with other MCP enthusiasts, ask questions, and share your experiences with FastAPI-MCP.
Requirements
- Python 3.10+ (Recommended 3.12)
- uv
License
MIT License. Copyright (c) 2025 Tadata Inc.
FastAPI MCP questions
How do I add an MCP server to my FastAPI app?
Create FastApiMCP with your app instance and call mount(); the MCP server is then served at /mcp on your app's base URL.
Does FastAPI-MCP support authentication?
Yes, authentication is built in and reuses your existing FastAPI dependencies such as Depends() for auth and authorization.
Does it preserve my endpoint documentation and schemas?
Yes, it preserves request and response model schemas and keeps endpoint documentation as it appears in Swagger.
What Python version does FastAPI-MCP require?
It requires Python 3.10 or newer, with 3.12 recommended.
Can the MCP server be deployed separately from the FastAPI app?
Yes, you can mount the MCP server on the same app or deploy it separately.