Skip to main content
Glama

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

Related MCP server: CodeAlive MCP

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.

A
license - permissive license
Not graded
quality - not tested
D
maintenance

Maintenance

โ€“Maintainers
โ€“Response time
โ€“Release cycle
โ€“Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A FastAPI-based implementation of the Model Context Protocol that enables standardized interaction between AI models and development environments, making it easier for developers to integrate and manage AI tasks.
    10
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    A Model Context Protocol server that enhances AI agents by providing deep semantic understanding of codebases, enabling more intelligent interactions through advanced code search and contextual awareness.
    88
    MIT
  • F
    license
    B
    quality
    D
    maintenance
    A Model Context Protocol server that provides tools for fetching and posting HTTP data, with built-in prompts for URL summarization and API analysis.
    2
  • A
    license
    D
    quality
    D
    maintenance
    A Model Context Protocol server that enables LLMs to explore and interact with API specifications by providing tools for loading, browsing, and getting detailed information about API endpoints.
    4
    17
    14
    ISC

View all related MCP servers

Related MCP Connectors

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yoโ€ฆ

  • A Model Context Protocol server for Wix AI tools

  • MCP server for AI access to Swagger by SmartBear.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Nabeelshar/fastapi-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server