fastapi_mcp README

The project's README from github.com/tadata-org/fastapi_mcp. As one markdown file: README.md.

fastapi-to-mcp

Built by Tadata

FastAPI-MCP

tadata-org%2Ffastapi_mcp | Trendshift

Expose your FastAPI endpoints as Model Context Protocol (MCP) tools, with Auth!

PyPI version Python Versions FastAPI CI Coverage

fastapi-mcp-usage

Features

Hosted Solution

If you prefer a managed hosted solution check out tadata.com.

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.

Documentation, Examples and Advanced Usage

FastAPI-MCP provides comprehensive documentation. Additionaly, check out the examples directory for code samples demonstrating these features in action.

FastAPI-first Approach

FastAPI-MCP is designed as a native extension of FastAPI, not just a converter that generates MCP tools from your API. This approach offers several key advantages:

This design philosophy ensures minimum friction when adding MCP capabilities to your existing FastAPI services.

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

License

MIT License. Copyright (c) 2025 Tadata Inc.

fastapi_mcp (tadata-org/fastapi_mcp)

Searching Database…

What is this?FastAPI-MCP turns your existing FastAPI endpoints into Model Context Protocol (MCP) tools, so AI agents like Claude or Cursor can call your API directly, with authentication built in.
Is this a standalone MCP server or a library I add to my app?It is a Python library/extension you add to your FastAPI codebase, not a separate converter tool. It is designed as a native extension of FastAPI rather than something that just generates MCP tools from your OpenAPI spec.
How do I add MCP support to my FastAPI app?Install the package with uv or pip, then add an MCP server directly to your FastAPI application in a couple of lines; the auto-generated MCP server is immediately available.
What do I need installed before using it?You need Python 3.10+ (3.12 recommended) and the uv package manager is the recommended way to install it, though pip works too.
Does it just convert my OpenAPI spec into MCP tools like other converters?No — it explicitly avoids being 'just another OpenAPI -> MCP converter.' It talks to your app directly over ASGI instead of making HTTP calls, so no separate conversion step or extra network hop is needed.
Who is this built for?Developers who already have a FastAPI backend and want to expose it to AI agents without building a separate integration layer.
How does authentication work for the exposed MCP tools?FastAPI-MCP reuses your existing FastAPI Depends() functions, so you secure MCP endpoints exactly the way you already secure your REST endpoints.
Can I run the MCP server separately from my main API?Yes, deployment is flexible — you can mount the MCP server onto the same FastAPI app or deploy it separately if you prefer.
Is there a hosted option if I don't want to self-manage it?Yes, the creators (Tadata) offer a managed hosted solution at tadata.com for teams who don't want to run FastAPI-MCP themselves.
Does it preserve my existing API documentation and schemas?Yes, it preserves the request/response model schemas and endpoint documentation exactly as they appear in Swagger.
Creator
tadata-org
Size
0.4 MB
Stars
12K
Age
1y
Commits · 90 Days