FastAPI-MCP
A zero-configuration tool for automatically exposing FastAPI endpoints as Model Context Protocol (MCP) tools.
Features
- Zero configuration - Just point it at your FastAPI app and it works, with automatic discovery of endpoints and conversion to MCP tools
- Schema & docs preservation - Keep the same request/response models and preserve documentation of all your endpoints
- Flexible deployment - Mount your MCP server to the same FastAPI application, or deploy separately
- Custom endpoint exposure - Control which endpoints become MCP tools using operation IDs and tags
- ASGI transport - Uses FastAPI’s ASGI interface directly by default for efficient communication
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
.
Note on
base_url
: Whilebase_url
is optional, it is highly recommended to provide it explicitly. Thebase_url
tells the MCP server where to send API requests when tools are called. Without it, the library will attempt to determine the URL automatically, which may not work correctly in deployed environments where the internal and external URLs differ.
Documentation, Examples and Advanced Usage
FastAPI-MCP provides comprehensive documentation in the docs
folder:
- Best Practices - Essential guidelines for converting APIs to MCP tools safely and effectively
- FAQ - Frequently asked questions about usage, development and support
- Tool Naming - Best practices for naming your MCP tools using operation IDs
- Connecting to MCP Server - How to connect various MCP clients like Cursor and Claude Desktop
- Advanced Usage - Advanced features like custom schemas, endpoint filtering, and separate deployment
Check out the examples directory for code samples demonstrating these features in action.
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 © 2024 Tadata Inc.
FastAPI-MCP
Project Details
- tadata-org/fastapi_mcp
- MIT License
- Last Updated: 4/21/2025
Categories
Recomended MCP Servers
A Model Context Protocol (MCP) server for the POX SDN controller
ClaudeKeep lets you save & share chats from Claude using an MCP inside Claude Desktop
Evaluate if a task requires human intervention
A server implementation for Wikidata API using the Model Context Protocol (MCP).
A Model Context Protocol (MCP) server for integrating Perplexity's AI API with LLMs.
An MCP server to search for flights.
A Minimum Control Program (MCP) server implementation for web browsing capabilities using BeautifulSoup4
A Desktop Chat App that leverages MCP(Model Context Protocol) to interface with other LLMs.
Geocoding MCP server with GeoPY!