FastAPI-MCP
Exposes FastAPI endpoints as Model Context Protocol (MCP) tools while preserving existing authentication, schemas, and documentation. It enables seamless integration of FastAPI services into MCP ecosystems using a native ASGI transport layer.
What is FastAPI-MCP?
FastAPI-MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to exposes fastapi endpoints as model context protocol (mcp) tools while preserving existing authentication, schemas, and documentation. it enables seamless integration of fastapi services into mcp ecosy...
Exposes FastAPI endpoints as Model Context Protocol (MCP) tools while preserving existing authentication, schemas, and documentation. It enables seamless integration of FastAPI services into MCP ecosystems using a native ASGI transport layer.
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- Exposes FastAPI endpoints as Model Context Protocol (MCP) to
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx fastapi-mcpConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use FastAPI-MCP
FastAPI-MCP is a Python library that automatically converts your existing FastAPI application's endpoints into MCP tools, preserving your authentication logic, Pydantic schemas, and OpenAPI documentation without any extra boilerplate. It uses a native ASGI transport layer for zero-overhead communication, meaning your FastAPI app becomes an MCP server the moment you add three lines of code. Python developers who already have FastAPI services and want to expose them to AI agents or Claude Desktop will find this the fastest path to MCP integration.
Prerequisites
- Python 3.10 or later (3.12 recommended)
- An existing FastAPI application
- pip or uv package manager
- An MCP-compatible client such as Claude Desktop or Cursor to test the integration
Install fastapi-mcp
Add fastapi-mcp to your project using uv (recommended) or pip. No additional dependencies beyond FastAPI are required for basic use.
uv add fastapi-mcp
# or:
pip install fastapi-mcpImport and attach FastApiMCP to your app
Add three lines to your existing FastAPI application file. FastApiMCP wraps your app and mounts the MCP server at /mcp automatically.
from fastapi import FastAPI
from fastapi_mcp import FastApiMCP
app = FastAPI()
mcp = FastApiMCP(app)
mcp.mount()Run your FastAPI application
Start your application as usual. The MCP server is now available at the /mcp path alongside your existing API endpoints.
uvicorn main:app --reloadVerify the MCP endpoint is live
Confirm the MCP server is accessible by checking its URL. Replace localhost:8000 with your actual host and port.
curl http://localhost:8000/mcpConfigure your MCP client to connect
Point your MCP client at the running FastAPI-MCP server. For clients that support HTTP transport, use the /mcp URL directly.
{
"mcpServers": {
"fastapi-mcp": {
"url": "http://localhost:8000/mcp"
}
}
}Test endpoint exposure
Ask your AI client to list available tools. It should reflect all your FastAPI endpoints as callable MCP tools, with schemas derived from your Pydantic models.
FastAPI-MCP Examples
Client configuration
MCP client configuration pointing to a locally running FastAPI-MCP server.
{
"mcpServers": {
"fastapi-mcp": {
"url": "http://localhost:8000/mcp"
}
}
}Prompts to try
Example prompts once your FastAPI application is exposed via FastAPI-MCP.
- "List all available tools from my FastAPI application"
- "Call the /users endpoint and return the first 10 user records"
- "Create a new product using the POST /products endpoint with name 'Widget' and price 9.99"
- "What does the /orders/{order_id} endpoint accept and return?"
- "Run the /reports/sales endpoint with date_from=2026-01-01 and summarize the result"Troubleshooting FastAPI-MCP
The /mcp endpoint returns 404 Not Found
Ensure you called `mcp.mount()` after creating the FastApiMCP instance. Also confirm your application has reloaded with `uvicorn main:app --reload`. The MCP endpoint only registers after mount() is invoked.
Authentication-protected endpoints return 401 when called from the MCP client
FastAPI-MCP preserves your FastAPI `Depends()` authentication. Your MCP client must pass the required credentials (Bearer token, API key, etc.) in the same way an HTTP client would. Check how your MCP client supports header injection or use FastAPI-MCP's built-in auth forwarding configuration.
Pydantic validation errors when the AI client calls an endpoint
The AI may be generating parameters that do not match your Pydantic model. Check the tool schema your MCP client receives (it should mirror your FastAPI OpenAPI docs) and refine your prompt to specify the correct field names and types.
Frequently Asked Questions about FastAPI-MCP
What is FastAPI-MCP?
FastAPI-MCP is a Model Context Protocol (MCP) server that exposes fastapi endpoints as model context protocol (mcp) tools while preserving existing authentication, schemas, and documentation. it enables seamless integration of fastapi services into mcp ecosystems using a native asgi transport layer. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install FastAPI-MCP?
Follow the installation instructions on the FastAPI-MCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with FastAPI-MCP?
FastAPI-MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is FastAPI-MCP free to use?
Yes, FastAPI-MCP is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.
FastAPI-MCP Alternatives — Similar Developer Tools Servers
Looking for alternatives to FastAPI-MCP? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
Browse More Developer Tools MCP Servers
Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up FastAPI-MCP in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use FastAPI-MCP?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.