Skip to content
Fastapi logo

Fastapi

Verified

Expose FastAPI endpoints as MCP tools with built-in authentication.

MCP ServerAI & KnowledgeLocal (stdio) 11.9k
View on GitHub
Updated 2026-06-15

What is the Fastapi MCP server?

FastAPI-MCP mounts an MCP server at a chosen path on the same FastAPI application or runs it separately. All endpoint schemas, docstrings, and Pydantic models are preserved automatically so LLM clients receive accurate tool definitions.

Because it uses the ASGI interface, no extra HTTP layer is introduced between the MCP client and the original endpoints. Authentication and authorization continue to rely on the same Depends() functions already present in the FastAPI codebase.

Install & connect

Add this to your MCP client config. Pick your client below and copy.

{
  "mcpServers": {
    "fastapi_mcp": {
      "command": "uvx",
      "args": [
        "fastapi-mcp"
      ]
    }
  }
}

Package: fastapi-mcp (pypi)

Other ways to install

pip

pip
pip install fastapi-mcp

Example prompts

Once connected, try asking your AI client:

List all available tools from my FastAPI app
Call the /users endpoint through MCP with the current auth token
Show me the request schema for the create_order tool
Mount the MCP server at /mcp on my existing FastAPI instance

Security & permissions

Runs locally via stdio or mounts inside the FastAPI process; inherits all existing dependency-based authentication and never transmits secrets outside the application.

What you can do with Fastapi

Add MCP access to existing APIs

Developers can attach an MCP interface to production FastAPI services without rewriting route logic or duplicating auth code.

Rapid prototyping of AI agents

Teams expose internal business endpoints to LLM agents in minutes by mounting the MCP server during development.

Unified deployment

Single ASGI process serves both REST clients and MCP clients, reducing infrastructure complexity for small teams.

How to use Fastapi

  1. 1Install with uv add fastapi-mcp or pip install fastapi-mcp
  2. 2Import FastApiMCP from fastapi_mcp in your FastAPI application file
  3. 3Instantiate FastApiMCP with your app object
  4. 4Call mcp.mount() to attach the MCP server at /mcp
  5. 5Run the FastAPI app normally; the MCP endpoint is now available

Fastapi: pros & cons

Pros

  • +Native FastAPI dependency reuse for authentication
  • +Preserves exact request/response schemas and documentation
  • +Zero boilerplate beyond a few lines of mounting code
  • +Supports both mounted and separate deployment modes

Cons

  • Only works with existing FastAPI applications
  • MCP tools are limited to what the underlying API already exposes
  • Documentation and examples are still maturing
Did you find this helpful?

Frequently asked questions

No, existing endpoints and dependencies work unchanged.

User reviews

Verified reviews from the community shape this listing's rating.

Loading reviews…

Sign in to review

Promote Fastapi

Add this badge to your website, or share the tool.

DFeatured on DhanasviFastapi 1