fastapi_mcp logo

fastapi_mcp

Free

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

Model APIsFreeFree tier
Type
Open Source

About fastapi_mcp

FastAPI-MCP is a Python library that automatically exposes your FastAPI endpoints as Model Context Protocol (MCP) tools. It integrates authentication using existing FastAPI dependencies, preserves request/response schemas and documentation, requires zero configuration, and supports flexible deployment (same app or separate). It uses FastAPI's ASGI interface for efficient internal communication. The project is open-source and free to use, with a managed hosted solution available at tadata.com.

Key Features

Authentication built in, using existing FastAPI dependencies
Zero configuration required – just point it at your FastAPI app
Preserves request/response model schemas
Preserves endpoint documentation as in Swagger
Flexible deployment – mount to same app or deploy separately
ASGI interface for efficient internal communication

Pros & Cons

Pros
  • Easy setup: only 3 lines of code required
  • Built-in authentication using FastAPI dependencies
  • No configuration needed – works out of the box
  • Preserves existing schemas and documentation
  • Supports both same-app and separate deployment
  • Open source and free to use
Cons
  • Requires a FastAPI application (not framework-agnostic)
  • Limited to MCP protocol (not general API exposure)
  • Relatively new project, may have smaller community

Best For

Exposing FastAPI endpoints as AI agent tools via MCPSecuring MCP access with existing FastAPI authenticationQuickly creating a managed MCP server for FastAPI applicationsIntegrating FastAPI services with AI agents using the Model Context Protocol

Alternatives to fastapi_mcp

FAQ

What is FastAPI-MCP?
FastAPI-MCP is an open-source library that auto-generates a Model Context Protocol (MCP) server from your FastAPI application, exposing endpoints as MCP tools with built-in authentication.
How do I set up FastAPI-MCP?
After installing the library, add three lines of code: import FastApiMCP from fastapi_mcp, create an instance with your FastAPI app, and call mcp.mount_http(). Your MCP server will be available at /mcp.
Does FastAPI-MCP support authentication?
Yes, it uses your existing FastAPI dependency injection system for authentication, so you don't need to set up separate auth for MCP.
Can I deploy the MCP server separately from my FastAPI app?
Yes, FastAPI-MCP supports flexible deployment – you can mount the MCP server to the same app or deploy it separately.
Is there a hosted/managed version of FastAPI-MCP?
Yes, a managed hosted solution is available at tadata.com.