Navigation
FastAPI-MCP: Zero-Config AI Integration, Boost Productivity - MCP Implementation

FastAPI-MCP: Zero-Config AI Integration, Boost Productivity

FastAPI-MCP: Instantly turn FastAPI endpoints into MCP tools—zero config, seamless AI integration. Maximize productivity, future-proof your workflows. 🚀" )

Developer Tools
4.6(199 reviews)
298 saves
139 comments

96% of users reported increased productivity after just one week

About FastAPI-MCP

What is FastAPI-MCP: Zero-Config AI Integration, Boost Productivity?

FastAPI-MCP is a zero-configuration tool designed to seamlessly expose FastAPI endpoints as Model Context Protocol (MCP) tools. It automates the integration process, allowing developers to focus on building APIs without manual setup. The tool discovers and converts all your FastAPI routes into MCP-compliant services while preserving schemas, documentation, and endpoint behaviors.

Key Features of FastAPI-MCP: Zero-Config AI Integration, Boost Productivity?

  • Seamless Integration: Embed an MCP server directly into your FastAPI application with a single line of code.
  • No Setup Required: Works out of the box—just point it to your FastAPI app and it auto-discovers all endpoints.
  • Schema Integrity: Maintains the original request/response schemas and Swagger documentation for clarity.
  • Extensibility: Add custom MCP tools alongside auto-generated ones for hybrid workflows.
  • Flexible Descriptions: Options to include full response schemas or simplified examples in tool metadata.

FastAPI-MCP Features

How to use FastAPI-MCP: Zero-Config AI Integration, Boost Productivity?

Getting started is straightforward:

  1. Install via uv or pip:
uv add fastapi-mcp
  1. Mount the MCP server in your FastAPI app:
from fastapi_mcp import add_mcp_server
add_mcp_server(app, mount_path="/mcp", name="Your MCP Service")

Advanced options allow customization, such as toggling response schema details or adding custom tools.

Use Cases of FastAPI-MCP: Zero-Config AI Integration, Boost Productivity?

FastAPI-MCP excels in scenarios where AI-driven tools need to interact with existing APIs:

  • Chatbot Integration: Expose API endpoints as tools for LLM-powered chat interfaces (e.g., Cursor).
  • Cross-Platform Compatibility: Use mcp-proxy to bridge non-SSE clients like Claude Desktop.
  • API-as-Code Workflows: Automate tool discovery for AI agents that require programmatic API access.

FastAPI-MCP FAQ

FAQ from FastAPI-MCP: Zero-Config AI Integration, Boost Productivity?

Q: Does FastAPI-MCP require any configuration?
A: No. The core functionality works without any setup—just mount the server to your app.

Q: Can I customize tool descriptions?
A: Yes. Use parameters like describe_all_responses to control how schemas are presented.

Q: What Python versions are supported?
A: Python 3.10+ is required. Earlier versions aren’t officially supported.

Q: How do I troubleshoot connection issues?
A: Verify the mount path and ensure the MCP client (e.g., Cursor) uses the correct endpoint URL.

Content

FastAPI-MCP

A zero-configuration tool for automatically exposing FastAPI endpoints as Model Context Protocol (MCP) tools.

PyPI version Python Versions

Features

  • Direct integration - Mount an MCP server directly to your FastAPI app
  • Zero configuration required - just point it at your FastAPI app and it works
  • Automatic discovery of all FastAPI endpoints and conversion to MCP tools
  • Preserving schemas of your request models and response models
  • Preserve documentation of all your endpoints, just as it is in Swagger
  • Extend - Add custom MCP tools alongside the auto-generated ones

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 add_mcp_server

# Your FastAPI app
app = FastAPI()

# Mount the MCP server to your app
add_mcp_server(
    app,                    # Your FastAPI app
    mount_path="/mcp",      # Where to mount the MCP server
    name="My API MCP",      # Name for the MCP server
)

That's it! Your auto-generated MCP server is now available at https://app.base.url/mcp.

Advanced Usage

FastAPI-MCP provides several ways to customize and control how your MCP server is created and configured. Here are some advanced usage patterns:

from fastapi import FastAPI
from fastapi_mcp import add_mcp_server

app = FastAPI()

mcp_server = add_mcp_server(
    app,                                    # Your FastAPI app
    mount_path="/mcp",                      # Where to mount the MCP server
    name="My API MCP",                      # Name for the MCP server
    describe_all_responses=True,            # False by default. Include all possible response schemas in tool descriptions, instead of just the successful response.
    describe_full_response_schema=True      # False by default. Include full JSON schema in tool descriptions, instead of just an LLM-friendly response example.
)

# Optionally add custom tools in addition to existing APIs.
@mcp_server.tool()
async def get_server_time() -> str:
    """Get the current server time."""
    from datetime import datetime
    return datetime.now().isoformat()

Examples

See the examples directory for complete examples.

Connecting to the MCP Server using SSE

Once your FastAPI app with MCP integration is running, you can connect to it with any MCP client supporting SSE, such as Cursor:

  1. Run your application.

  2. In Cursor -> Settings -> MCP, use the URL of your MCP server endpoint (e.g., http://localhost:8000/mcp) as sse.

  3. Cursor will discover all available tools and resources automatically.

Connecting to the MCP Server using mcp-proxy stdio

If your MCP client does not support SSE, for example Claude Desktop:

  1. Run your application.

  2. Install mcp-proxy, for example: uv tool install mcp-proxy.

  3. Add in Claude Desktop MCP config file (claude_desktop_config.json):

On Windows:

{
  "mcpServers": {
    "my-api-mcp-proxy": {
        "command": "mcp-proxy",
        "args": ["http://127.0.0.1:8000/mcp"]
    }
  }
}

On MacOS:

{
  "mcpServers": {
    "my-api-mcp-proxy": {
        "command": "/Full/Path/To/Your/Executable/mcp-proxy",
        "args": ["http://127.0.0.1:8000/mcp"]
    }
  }
}

Find the path to mcp-proxy by running in Terminal: which mcp-proxy.

  1. Claude Desktop will discover all available tools and resources automatically

Development and Contributing

If you're interested in contributing to FastAPI-MCP:

# Clone the repository
git clone https://github.com/tadata-org/fastapi_mcp.git
cd fastapi_mcp

# Create a virtual environment and install dependencies with uv
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv add -e ".[dev]"

# Run tests
uv run pytest

For more details about contributing, see CONTRIBUTING.md.

Community

Join MCParty Slack community to connect with other MCP enthusiasts, ask questions, and share your experiences with FastAPI-MCP.

Requirements

  • Python 3.10+
  • uv

License

MIT License. Copyright (c) 2024 Tadata Inc.

About

Developed and maintained by Tadata Inc.

Related MCP Servers & Clients