Skip to main content
Glama
FastAPI Docs MCP Server

FastAPI Docs MCP Server


An MCP (Model Context Protocol) server that provides real-time access to FastAPI documentation. Use it with Claude, GitHub Copilot, or any MCP-compatible client to instantly query FastAPI docs.

Features

  • Real-time documentation — Fetches directly from fastapi.tiangolo.com

  • Smart search — Find docs by keyword with common alias support

  • Full sitemap access — Browse all available documentation pages

  • Code examples — Get just the code, no prose

  • Compare approaches — Side-by-side comparisons of different patterns

Related MCP server: FastAPI Knowledge Base MCP Server

Tools

Tool

Description

get_fastapi_docs(path)

Fetch any documentation page by path

search_fastapi_docs(query)

Search docs by keyword (with alias support)

list_fastapi_pages()

List all available documentation pages

get_fastapi_example(topic)

Get just the code examples, no prose

compare_fastapi_approaches(topic)

Compare different approaches side-by-side

get_fastapi_best_practices(topic)

Get combined best practices from multiple pages

Examples

Once connected, ask your AI assistant:

  • "How do I set up CORS in FastAPI?"

  • "Show me the FastAPI security documentation"

  • "What are FastAPI dependencies?"

  • "List all FastAPI tutorial pages"

  • "Give me a code example for JWT authentication"

  • "Compare sync vs async in FastAPI"

  • "What are the best practices for testing in FastAPI?"

Installation

git clone https://github.com/jaredthivener/fastapi-docs-mcp.git
cd fastapi-docs-mcp
uv sync

Usage

With Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "fastapi-docs": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/fastapi-docs-mcp", "fastapi-docs-mcp"]
    }
  }
}

With VS Code (GitHub Copilot)

Add to .vscode/mcp.json in your workspace:

{
  "servers": {
    "fastapi-docs": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/fastapi-docs-mcp", "fastapi-docs-mcp"]
    }
  }
}

With Docker

Build the image locally:

docker build -t fastapi-docs-mcp .

Then use this MCP server config:

{
  "servers": {
    "fastapi-docs": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "fastapi-docs-mcp"
      ],
      "type": "stdio"
    }
  }
}

Standalone

uv run fastapi-docs-mcp

Development

# Install dev dependencies
uv sync --extra dev

# Run tests
uv run pytest

# Lint
uv run ruff check .

# Format
uv run ruff format .

# Type check
uv run mypy src/fastapi_docs_mcp

How It Works

The server fetches documentation directly from the official FastAPI website:

  1. Sitemap-based discovery — Uses sitemap.xml to find all available pages

  2. Real-time fetching — Retrieves current documentation on each request

  3. Smart extraction — Extracts readable content from HTML pages

  4. Keyword aliases — Maps common terms (e.g., "auth" → "security")

Content Limits

To keep responses fast and avoid overloading AI context windows, documentation content is truncated to a maximum length (currently 15,000 characters). If a page exceeds that limit, the response ends with a truncation notice and a link to the full page.

Changelog

See CHANGELOG.md.

License

MIT

Available Tools

6 tools
compare_fastapi_approachesA
Read-only

Compare FastAPI approaches side-by-side (e.g. sync vs async, auth methods).

Inputs: topic (required).

get_fastapi_best_practicesA
Read-only

Combine best-practice content from all doc pages matching a topic.

Inputs: topic (required).

get_fastapi_docsA
Read-only

Fetch FastAPI documentation content for a page by its path.

Inputs: path (required).

get_fastapi_exampleA
Read-only

Get code examples (no prose) for a FastAPI topic.

Inputs: topic (required).

list_fastapi_pagesA
Read-only

List all available FastAPI doc pages, categorized by section.

Inputs: no named parameters.

search_fastapi_docsA
Read-only

Search the docs by keyword and return the best-matching page.

Common aliases are supported (e.g. "auth" finds security pages).

Inputs: query (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool targets a distinct task: comparing approaches, best practices, fetching docs, examples, listing pages, and searching. No overlap in functionality.

    Naming Consistency4/5

    All names use snake_case and follow a verb_fastapi_noun pattern. Minor variation in verbs like 'compare' vs 'get' but overall consistent.

    Tool Count5/5

    Six tools is well-scoped for a documentation server, covering essential operations without being excessive or insufficient.

    Completeness4/5

    The surface covers common documentation needs (browse, search, fetch, examples, comparisons). Minor gap: no explicit tool for random page or offline caching, but core workflows are complete.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to fetch, index, and perform semantic RAG-based searches on API documentation from various sources. It provides tools for hybrid search and collection management, allowing users to access up-to-date documentation from projects like Gemini and FastMCP.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI clients to search and read FastAPI documentation through hybrid semantic and keyword retrieval, returning ranked, citable sections and full pages as structured, typed results. All retrieved text is screened by a prompt-injection guard that strips suspicious instructions and flags the results, so only indexed pages can be read and nothing hostile reaches the model.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to search, retrieve, and cite the FastAPI documentation while they work, using BM25 or optional embedding retrieval. It exposes read-only tools for ranked passage search, full-page retrieval, and page listing through the Model Context Protocol.
      2
      3
      MIT