fastapi_mcp
by tadata-org·★ 11,863·Score 60
FastAPI-MCP exposes FastAPI endpoints as MCP tools with built-in authentication.
Overview
FastAPI-MCP is a Python library that bridges FastAPI applications with the Model Context Protocol, allowing developers to expose existing API endpoints as MCP tools without extensive reconfiguration. The solution preserves request/response schemas, endpoint documentation from Swagger, and works with FastAPI's native authentication mechanisms. It offers flexible deployment options, allowing mounting directly to the FastAPI app or separate deployment.
Try asking AI
After installing, here are 5 things you can ask your AI assistant:
When to choose this
Choose FastAPI-MCP if you already use FastAPI and want to expose your existing endpoints as MCP tools with minimal configuration and leveraging your existing authentication.
When NOT to choose this
Avoid if you're not using FastAPI, as this solution is specifically designed for FastAPI applications and requires Python 3.10+.
Comparable tools
Installation
Install with uv or pip:
uv add fastapi-mcppip install fastapi-mcpBasic usage in FastAPI app:
from fastapi import FastAPI
from fastapi_mcp import FastApiMCP
app = FastAPI()
mcp = FastApiMCP(app)
mcp.mount()For Claude Desktop, add to config.json:
{
"mcpServers": {
"fastapi": {
"command": "python",
"args": ["-m", "fastapi_mcp"]
}
}
}FAQ
- What authentication methods are supported?
- FastAPI-MCP leverages your existing FastAPI dependencies for authentication, using the same Dep() mechanisms you're already familiar with.
- Can I deploy the MCP server separately from my FastAPI app?
- Yes, FastAPI-MCP supports both mounting directly to your FastAPI app and separate deployment options for flexible infrastructure setup.
On Hacker News
Recent discussion from the developer community.
- Story by tadata · 2025-04-10
- Story by tadata · 2025-03-24
Compare fastapi_mcp with
Last updated · Auto-generated from public README + GitHub signals.