fastapi_mcp
Expose your FastAPI endpoints as Model Context Protocol (MCP) tools, with Auth!
A Python library that automatically exposes all your existing FastAPI endpoints as MCP tools so AI assistants like Claude or Cursor can discover and call your API during a conversation, with no rebuilding required.
FastAPI-MCP is a Python library that takes an existing FastAPI web application and automatically exposes all of its API endpoints as tools that AI assistants can call. FastAPI is a popular Python framework for building web APIs. MCP, the Model Context Protocol, is a standard that lets AI tools like Claude or Cursor discover and invoke external capabilities during a conversation.
The idea is that if you already have a working FastAPI backend, you should not need to rebuild anything to make it usable by an AI assistant. You add this library, call two functions, and your entire API becomes available to AI tools at a new URL. The library reads your existing FastAPI route definitions, including their documentation and data schemas, and uses that information to describe each endpoint to the AI in the format MCP requires.
The README highlights that this is built as a native FastAPI extension rather than a generic converter. That distinction matters for authentication: instead of creating a separate authentication layer for the MCP interface, you can reuse the same FastAPI dependency functions you already wrote for your regular API. The library also communicates with your FastAPI app directly through its internal interface rather than making HTTP calls to it, which the README notes is more efficient.
Deployment is flexible. You can mount the MCP server onto the same application so it runs as part of your existing service, or you can run it as a separate process if your infrastructure requires that.
Installation is through pip or the uv package manager. Python 3.10 or later is required, with 3.12 recommended. The project is open-source under the MIT license and is maintained by Tadata, which also offers a managed hosted version of the same functionality for teams that prefer not to self-host.
Where it fits
- Expose an existing FastAPI backend to Claude or Cursor as callable tools without rewriting any endpoint logic
- Reuse your existing FastAPI authentication dependencies for the AI tool interface without creating a separate auth layer
- Mount the MCP server directly onto your FastAPI app so it runs as part of your existing service with no extra infrastructure
- Run the MCP server as a separate process if your infrastructure requires it to be isolated from the main app