FastAPI MCP Server

FastAPI MCP Server

A Model Context Protocol server that provides tools for introspecting and analyzing FastAPI applications, including route discovery, model schema extraction, and source code viewing. It enables users to explore API structures, generate documentation, and debug dependency injection hierarchies through natural language.

Category
Visit Server

README

FastAPI MCP Server

A Model Context Protocol (MCP) server that provides comprehensive tools for introspecting and working with FastAPI applications.

Features

๐Ÿ”ง Tools

  1. load_fastapi_app - Load a FastAPI application from a module path
  2. list_routes - List all routes with optional filtering
  3. get_route_details - Get comprehensive details about a specific route
  4. get_openapi_schema - Extract the OpenAPI schema
  5. list_models - List all Pydantic models used in the app
  6. get_model_schema - Get detailed schema for a specific model
  7. search_routes - Search routes by query and criteria
  8. analyze_dependencies - Analyze dependency injection usage
  9. get_route_source - View the source code of route handlers

Installation

pip install -e .

Usage

With Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "fastapi": {
      "command": "python",
      "args": [
        "-m",
        "fastapi_mcp_server.server"
      ],
      "cwd": "/path/to/your/fastapi/project"
    }
  }
}

Standalone

# From your FastAPI project directory
python -m fastapi_mcp_server.server

Example Usage

1. Load Your FastAPI App

Tool: load_fastapi_app
Arguments: {"app_path": "main:app"}

2. List All Routes

Tool: list_routes
Arguments: {}

Or with filters:

Tool: list_routes
Arguments: {
  "method_filter": "GET",
  "tag_filter": "users"
}

3. Get Route Details

Tool: get_route_details
Arguments: {
  "path": "/users/{user_id}",
  "method": "GET"
}

4. Search for Routes

Tool: search_routes
Arguments: {
  "query": "authentication",
  "has_auth": true
}

5. View Route Source Code

Tool: get_route_source
Arguments: {
  "path": "/users",
  "method": "POST"
}

6. List All Models

Tool: list_models
Arguments: {}

7. Get Model Schema

Tool: get_model_schema
Arguments: {"model_name": "User"}

8. Get OpenAPI Schema

Tool: get_openapi_schema
Arguments: {}

Or for specific paths:

Tool: get_openapi_schema
Arguments: {
  "include_only": ["/users", "/users/{user_id}"]
}

9. Analyze Dependencies

Tool: analyze_dependencies
Arguments: {}

Example FastAPI App

See example_app.py for a sample FastAPI application to test with.

Use Cases

๐Ÿ” API Discovery

  • Quickly understand what endpoints exist
  • Find routes by functionality or path
  • Explore API structure

๐Ÿ“š Documentation Generation

  • Extract OpenAPI schemas
  • Get detailed parameter information
  • View model schemas with examples

๐Ÿ› Debugging

  • Inspect route configurations
  • View dependency injection hierarchy
  • Check parameter validations

๐Ÿ”จ Development

  • Generate client code from schemas
  • Understand existing APIs before modification
  • Find all routes using specific models

๐Ÿงช Testing

  • List all endpoints for test coverage
  • Get parameter requirements for test cases
  • Validate response models

Requirements

  • Python 3.10+
  • FastAPI 0.100.0+
  • MCP 1.0.0+
  • Pydantic 2.0.0+

Contributing

Contributions are welcome! This tool helps developers work more efficiently with FastAPI applications.

License

MIT License - feel free to use in your projects!

Author

Created as part of the FastAPI ecosystem to improve developer experience with AI-assisted development.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured