fastapi_mcp

fastapi_mcp

4.2

FastAPI-MCP is a tool that allows you to expose your FastAPI endpoints as Model Context Protocol (MCP) tools with built-in authentication.

FastAPI-MCP is a powerful extension for FastAPI applications, enabling developers to expose their API endpoints as Model Context Protocol (MCP) tools. This integration is seamless, requiring minimal configuration and leveraging FastAPI's native capabilities. The tool ensures that authentication is built-in using existing FastAPI dependencies, preserving the schemas and documentation of request and response models. FastAPI-MCP is designed to be FastAPI-native, meaning it is not just a converter but a fully integrated solution that uses FastAPI's ASGI interface for efficient communication. This allows for flexible deployment options, whether mounting the MCP server directly to the FastAPI app or deploying it separately. The tool is ideal for developers looking to enhance their FastAPI applications with MCP capabilities without the need for extensive modifications.

Features

  • Authentication built in, using your existing FastAPI dependencies
  • FastAPI-native: Not just another OpenAPI -> MCP converter
  • Zero/Minimal configuration required - just point it at your FastAPI app and it works
  • Preserving schemas of your request models and response models
  • Flexible deployment - Mount your MCP server to the same app, or deploy separately

Usage with Different Platforms

basic_usage

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