← Back to directory
F

FastAPI-MCP

Community
Expose your FastAPI endpoints as Model Context Protocol (MCP) tools, with Auth!
GitHub source repository ↗
★ 12.0k Stars Category · Dev Tools Popular Source revision e5cad13cabfc
48FMRS · D
Reliability
6/20
Security and permissions
10/20
Maintenance
10/20
Documentation
10/20
Setup experience
12/20

FastAPI-MCP is a well-established library for converting FastAPI endpoints into MCP tools with authentication support. It takes a FastAPI-native approach, making it especially useful for existing FastAPI users. Documentation and examples are comprehensive, and the community is active with an MIT license. It is not suitable for non-FastAPI projects, and careful attention should be paid to securing sensitive endpoints.

Read the FMRS scoring method →

FastAPI-MCP is a library designed to turn an existing FastAPI application into a Model Context Protocol (MCP) server. It is not just an OpenAPI-to-MCP converter; it is a native extension of FastAPI, allowing you to mount an MCP server directly onto your FastAPI app. It features built-in authentication using your existing FastAPI dependencies, preserves schemas of request and response models, preserves documentation of all endpoints as in Swagger, and supports flexible deployment—you can mount the MCP server to the same app or deploy separately. It uses ASGI transport to communicate directly with the FastAPI app, eliminating the need for HTTP calls from the MCP to your API.

Tools

The tool list has not been reviewed yet.

Setup

Install FastAPI-MCP using uv or pip:

uv add fastapi-mcp

or

pip install fastapi-mcp

Fit and risk

Best for

  • Developers with existing FastAPI applications who want to add MCP support with minimal configuration.
  • Teams that require secure MCP endpoints and want to use existing FastAPI dependencies for authentication and authorization.
  • Use cases where you want to deploy the MCP server together with your FastAPI app or as a standalone service.

Not for

  • Developers not already using FastAPI—this server is designed for FastAPI apps.
  • Clients that require stdio transport—FastAPI-MCP uses ASGI/HTTP transport.
  • Users who need full control over MCP tool definitions without relying on automatic generation from endpoints.

Required permissions

  • Requires access to your FastAPI application instance.
  • May require network access to the MCP endpoints (e.g., via HTTP).
  • Authentication and authorization use existing dependencies in your FastAPI app.

Risks and side effects

  • Exposed MCP endpoints could be an entry for unauthorized access if authentication is not configured properly.
  • Auto-generated tools might expose sensitive endpoints—ensure proper authentication and authorization are set up.
  • Dependency on FastAPI and Python version compatibility—requires Python 3.10+.

Troubleshooting

  1. Ensure you are using Python 3.10 or higher.
  2. Verify that your FastAPI app is initialized correctly and the MCP server is mounted.
  3. Check that authentication dependencies are working as expected to avoid permission errors.
  4. Consult the documentation and examples for advanced configuration and deployment options.

Use cases

Expose existing FastAPI services as MCP tools for AI clients like Claude, Cursor, or Windsurf.
Provide protected API endpoint access to AI agents, leveraging existing FastAPI authentication mechanisms.
Quickly integrate MCP capabilities into a FastAPI service without rewriting the API code.

Supported clients

Supported clients have not been confirmed yet.