# FastAPI-MCP

> Turn the FastAPI app you already have into MCP tools, with its own auth

- Category: Agents & Automation / Agent Frameworks & Builders
- Language: Python
- Licence: MIT
- Repository: https://github.com/tadata-org/fastapi_mcp
- Website: https://fastapi-mcp.tadata.com/
- Canonical page: https://ai-tldr.dev/tools/fastapi-mcp/

## In short

FastAPI-MCP exposes the endpoints of an existing FastAPI application as Model Context Protocol tools, so an agent can call the API you already run. The pitch is minimal work: point it at your app, mount it, and the MCP server is served from the same application at /mcp. It sits in the Agent Frameworks & Builders category of the Agents & Automation tools and is open-source, written in Python and licensed MIT.

## Overview

FastAPI-MCP exposes the endpoints of an existing FastAPI application as Model Context Protocol tools, so an agent can call the API you already run. The pitch is minimal work: point it at your app, mount it, and the MCP server is served from the same application at /mcp.

It describes itself as FastAPI-native rather than "another OpenAPI to MCP converter", and the difference is visible in three places. Authentication reuses your existing FastAPI dependencies — the same `Depends()` you already wrote guards the MCP endpoints, rather than a parallel auth story. The request and response model schemas and the endpoint documentation carry through, so tools arrive described the way Swagger describes them. And communication happens over FastAPI's ASGI interface directly, so the MCP layer does not make HTTP calls back into your own API.

Deployment is flexible: mounting the MCP server into the same app is the default, and the documentation also covers deploying it separately from the original FastAPI app when you want the two to scale or be secured apart. The package is MIT-licensed, published on PyPI as `fastapi-mcp`, and requires Python 3.10+ (3.12 recommended). Tadata, the company behind it, also offers a hosted service.

## What it does

- Mounts an MCP server into an existing FastAPI app with near-zero configuration
- Authentication and authorization through your existing FastAPI Depends() dependencies
- Preserves request/response model schemas and endpoint documentation in the generated tools
- Talks to the app over FastAPI's ASGI interface instead of issuing HTTP calls to itself
- Deploy mounted in the same app, or separately from the original FastAPI service
- Published on PyPI with CI and coverage, MIT-licensed, Python 3.10+

## Getting started

Add the package, then wrap your FastAPI app. The README's own example is four lines of code beyond the imports.

1. Install the package

   The project recommends uv; pip works the same way.

```bash
uv add fastapi-mcp
# or
pip install fastapi-mcp
```

2. Mount the MCP server on your app

   Wrap the FastAPI instance and call mount(). The MCP server is then served at https://app.base.url/mcp.

```python
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()
```

3. Keep your existing auth

   Because the generated tools run inside your app, the dependencies you already use for authentication and authorization apply to them too — see the documentation's auth section for the patterns.

4. Deploy separately if you need to

   The documentation covers running the MCP server apart from the original FastAPI app, for cases where the two should be scaled or exposed differently.

## When to use it

- Reach for it when an agent needs to call an internal service you have already built in FastAPI, without writing an MCP server by hand
- Expose a subset of an API to agents while keeping the same dependency-based authentication the human-facing routes use
- Give agents tools whose schemas and descriptions match your Swagger docs, so tool definitions stay in sync with the API
- Run the MCP surface as a separate deployment when agent traffic should not share the main app's process
