MCP server/other

FastAPI MCP Server

Introspect and analyze FastAPI applications using natural language.

Nabeelshar/fastapi-mcp-server ↗by Nabeelsharupdated
1

Add it to Claude Code

claude mcp add fastapi-mcp -- python -m fastapi_mcp_server.server
2

Make your agent remember this setup

fastapi-mcp's config, env vars, and the gotchas you hit — recalled in every future Claude Code, Cursor, and Codex session.

npx conare@latest

Free · one command · indexes the sessions already on disk. Set up in the browser instead →

What it does

  • Introspect FastAPI route structures and configurations
  • Extract and view Pydantic model schemas
  • Analyze dependency injection hierarchies
  • Search and filter API endpoints by method or tag
  • Retrieve source code for specific route handlers

Tools 9

load_fastapi_appLoad a FastAPI application from a module path
list_routesList all routes with optional filtering
get_route_detailsGet comprehensive details about a specific route
get_openapi_schemaExtract the OpenAPI schema
list_modelsList all Pydantic models used in the app
get_model_schemaGet detailed schema for a specific model
search_routesSearch routes by query and criteria
analyze_dependenciesAnalyze dependency injection usage
get_route_sourceView the source code of route handlers

Try it

List all GET routes in my FastAPI application.
Show me the schema for the User Pydantic model.
Search for all routes related to authentication.
Analyze the dependency injection hierarchy for my app.
Get the source code for the POST /users endpoint.
Original README from Nabeelshar/fastapi-mcp-server

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.

Frequently Asked Questions

What are the key features of FastAPI MCP Server?

Introspect FastAPI route structures and configurations. Extract and view Pydantic model schemas. Analyze dependency injection hierarchies. Search and filter API endpoints by method or tag. Retrieve source code for specific route handlers.

What can I use FastAPI MCP Server for?

Quickly discover and understand existing API endpoints. Generate documentation by extracting OpenAPI schemas. Debug route configurations and dependency injection issues. Understand API structure before implementing new features. Validate parameter requirements for test case generation.

How do I install FastAPI MCP Server?

Install FastAPI MCP Server by running: pip install -e .

What MCP clients work with FastAPI MCP Server?

FastAPI MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Conare · memory for coding agents

Turn this server into reusable context

Keep FastAPI MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Set up free$npx conare@latest