Fastapi
VerifiedExpose FastAPI endpoints as MCP tools with built-in authentication.
What is the Fastapi MCP server?
FastAPI-MCP mounts an MCP server at a chosen path on the same FastAPI application or runs it separately. All endpoint schemas, docstrings, and Pydantic models are preserved automatically so LLM clients receive accurate tool definitions.
Because it uses the ASGI interface, no extra HTTP layer is introduced between the MCP client and the original endpoints. Authentication and authorization continue to rely on the same Depends() functions already present in the FastAPI codebase.
Install & connect
Add this to your MCP client config. Pick your client below and copy.
{
"mcpServers": {
"fastapi_mcp": {
"command": "uvx",
"args": [
"fastapi-mcp"
]
}
}
}Package: fastapi-mcp (pypi)
Other ways to install
pip
pip install fastapi-mcpExample prompts
Once connected, try asking your AI client:
Security & permissions
Runs locally via stdio or mounts inside the FastAPI process; inherits all existing dependency-based authentication and never transmits secrets outside the application.
What you can do with Fastapi
Add MCP access to existing APIs
Developers can attach an MCP interface to production FastAPI services without rewriting route logic or duplicating auth code.
Rapid prototyping of AI agents
Teams expose internal business endpoints to LLM agents in minutes by mounting the MCP server during development.
Unified deployment
Single ASGI process serves both REST clients and MCP clients, reducing infrastructure complexity for small teams.
How to use Fastapi
- 1Install with uv add fastapi-mcp or pip install fastapi-mcp
- 2Import FastApiMCP from fastapi_mcp in your FastAPI application file
- 3Instantiate FastApiMCP with your app object
- 4Call mcp.mount() to attach the MCP server at /mcp
- 5Run the FastAPI app normally; the MCP endpoint is now available
Fastapi: pros & cons
Pros
- +Native FastAPI dependency reuse for authentication
- +Preserves exact request/response schemas and documentation
- +Zero boilerplate beyond a few lines of mounting code
- +Supports both mounted and separate deployment modes
Cons
- –Only works with existing FastAPI applications
- –MCP tools are limited to what the underlying API already exposes
- –Documentation and examples are still maturing
Frequently asked questions
No, existing endpoints and dependencies work unchanged.
User reviews
Verified reviews from the community shape this listing's rating.
Loading reviews…