$git clone https://github.com/tadata-org/fastapi_mcp</div>
| 1 | <p align="center"><a href="https://github.com/tadata-org/fastapi_mcp"><img src="https://github.com/user-attachments/assets/7e44e98b-a0ba-4aff-a68a-4ffee3a6189c" alt="fastapi-to-mcp" height=100/></a></p> |
| 2 | |
| 3 | <div align="center"> |
| 4 | <span style="font-size: 0.85em; font-weight: normal;">Built by <a href="https://tadata.com">Tadata</a></span> |
| 5 | </div> |
| 6 | |
| 7 | <h1 align="center"> |
| 8 | FastAPI-MCP |
| 9 | </h1> |
| 10 | |
| 11 | <div align="center"> |
| 12 | <a href="https://trendshift.io/repositories/14064" target="_blank"><img src="https://trendshift.io/api/badge/repositories/14064" alt="tadata-org%2Ffastapi_mcp | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a> |
| 13 | </div> |
| 14 | |
| 15 | <p align="center">Expose your FastAPI endpoints as Model Context Protocol (MCP) tools, with Auth!</p> |
| 16 | <div align="center"> |
| 17 | |
| 18 | [](https://pypi.org/project/fastapi-mcp/) |
| 19 | [](https://pypi.org/project/fastapi-mcp/) |
| 20 | [](#) |
| 21 | [](https://github.com/tadata-org/fastapi_mcp/actions/workflows/ci.yml) |
| 22 | [](https://codecov.io/gh/tadata-org/fastapi_mcp) |
| 23 | |
| 24 | </div> |
| 25 | |
| 26 | |
| 27 | <p align="center"><a href="https://github.com/tadata-org/fastapi_mcp"><img src="https://github.com/user-attachments/assets/b205adc6-28c0-4e3c-a68b-9c1a80eb7d0c" alt="fastapi-mcp-usage" height="400"/></a></p> |
| 28 | |
| 29 | |
| 30 | ## Features |
| 31 | |
| 32 | - **Authentication** built in, using your existing FastAPI dependencies! |
| 33 | |
| 34 | - **FastAPI-native:** Not just another OpenAPI -> MCP converter |
| 35 | |
| 36 | - **Zero/Minimal configuration** required - just point it at your FastAPI app and it works |
| 37 | |
| 38 | - **Preserving schemas** of your request models and response models |
| 39 | |
| 40 | - **Preserve documentation** of all your endpoints, just as it is in Swagger |
| 41 | |
| 42 | - **Flexible deployment** - Mount your MCP server to the same app, or deploy separately |
| 43 | |
| 44 | - **ASGI transport** - Uses FastAPI's ASGI interface directly for efficient communication |
| 45 | |
| 46 | |
| 47 | ## Hosted Solution |
| 48 | |
| 49 | If you prefer a managed hosted solution check out [tadata.com](https://tadata.com). |
| 50 | |
| 51 | ## Installation |
| 52 | |
| 53 | We recommend using [uv](https://docs.astral.sh/uv/), a fast Python package installer: |
| 54 | |
| 55 | ```bash |
| 56 | uv add fastapi-mcp |
| 57 | ``` |
| 58 | |
| 59 | Alternatively, you can install with pip: |
| 60 | |
| 61 | ```bash |
| 62 | pip install fastapi-mcp |
| 63 | ``` |
| 64 | |
| 65 | ## Basic Usage |
| 66 | |
| 67 | The simplest way to use FastAPI-MCP is to add an MCP server directly to your FastAPI application: |
| 68 | |
| 69 | ```python |
| 70 | from fastapi import FastAPI |
| 71 | from fastapi_mcp import FastApiMCP |
| 72 | |
| 73 | app = FastAPI() |
| 74 | |
| 75 | mcp = FastApiMCP(app) |
| 76 | |
| 77 | # Mount the MCP server directly to your FastAPI app |
| 78 | mcp.mount() |
| 79 | ``` |
| 80 | |
| 81 | That's it! Your auto-generated MCP server is now available at `https://app.base.url/mcp`. |
| 82 | |
| 83 | ## Documentation, Examples and Advanced Usage |
| 84 | |
| 85 | FastAPI-MCP provides [comprehensive documentation](https://fastapi-mcp.tadata.com/). Additionaly, check out the [examples directory](examples) for code samples demonstrating these features in action. |
| 86 | |
| 87 | ## FastAPI-first Approach |
| 88 | |
| 89 | 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: |
| 90 | |
| 91 | - **Native dependencies**: Secure your MCP endpoints using familiar FastAPI `Depends()` for authentication and authorization |
| 92 | |
| 93 | - **ASGI transport**: Communicates directly with your FastAPI app using its ASGI interface, eliminating the need for HTTP calls from the MCP to your API |
| 94 | |
| 95 | - **Unified infrastructure**: Your FastAPI app doesn't need to run separately from the MCP server (though [separate deployment](https://fastapi-mcp.tadata.com/advanced/deploy#deploying-separately-from-original-fastapi-app) is also supported) |
| 96 | |
| 97 | This design philosophy ensures minimum friction when adding MCP capabilities to your existing FastAPI services. |
| 98 | |
| 99 | |
| 100 | ## Develo |