fastapi-docs-mcp
Provides tools to search and browse the bundled snapshot of the FastAPI documentation: ranked passage search returning page, section and URL for citations, full-page retrieval by page id or docs URL, and listing page ids by prefix.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@fastapi-docs-mcp How do I force every request to use HTTPS in FastAPI?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
fastapi-docs-mcp
An MCP server that lets AI assistants such as Claude Code, Claude Desktop and Cursor search the FastAPI documentation while they work, and cite it.
The retrieval behind it isn't guessed: it comes from rag-eval-lab, where the same chunking and retrievers were measured on 52 labelled questions. Offline it uses BM25 (recall@5 0.885); with an OpenAI key it switches to embeddings (recall@5 0.962).
In Claude Code
Claude Code calls search_docs (embedding mode), then get_page on advanced/middleware, and
answers with HTTPSRedirectMiddleware, quoting the page. Keyword search alone misses this
question (its top hits are middleware basics, SQL databases and testing), which is why the
server switches to embeddings when a key is available.
Related MCP server: FastAPI Knowledge Base MCP Server
Tools
Tool | Input | Returns |
|
| Ranked passages with page, section, URL and score |
|
| The whole page as text, with title and URL |
| optional | Page ids, titles and URLs |
All three are read-only and declare it (readOnlyHint, idempotentHint, no open-world
access), return typed structured output (pydantic models, so clients get an output schema),
and the server sends usage instructions telling the model to search first, cite URLs, and
say when the docs don't cover something.
Use it
Claude Code
# keyword search, no key needed
claude mcp add fastapi-docs -- uvx --from git+https://github.com/ahmedelalfiee/fastapi-docs-mcp fastapi-docs-mcp
# embedding search (better on questions worded differently from the docs)
claude mcp add fastapi-docs -e OPENAI_API_KEY=sk-... -- uvx --from "fastapi-docs-mcp[dense] @ git+https://github.com/ahmedelalfiee/fastapi-docs-mcp" fastapi-docs-mcpClaude Desktop / Cursor (claude_desktop_config.json or .cursor/mcp.json)
{
"mcpServers": {
"fastapi-docs": {
"command": "uvx",
"args": ["--from", "fastapi-docs-mcp[dense] @ git+https://github.com/ahmedelalfiee/fastapi-docs-mcp", "fastapi-docs-mcp"],
"env": { "OPENAI_API_KEY": "optional: enables embedding search" }
}
}
}From a clone
pip install -e ".[dev]" # add ",dense" for embedding search
python -m docs_mcp # stdio server
python -m pytest -q # 8 tests, no keys neededThen ask your assistant something like "Using the FastAPI docs, how do I cap the size of request
bodies?" and it will call search_docs and answer with links.
Configuration
Variable | Effect |
| If set and the |
| Force |
| Where embeddings are cached (default |
Design decisions
1. Return passages, not answers. There is no answer tool. The client is already an LLM; a
server that calls a second LLM would add cost and latency and hide the evidence. Returning
ranked passages with URLs lets the assistant read, combine and cite them itself.
2. Errors the model can recover from. Bad arguments fail schema validation with a readable
message, and an unknown page raises a ToolError that suggests the closest page ids (a typo like
tutorial/request-file returns "Did you mean: tutorial/request-files…"). Unexpected crashes
stay generic so internals don't leak into the conversation.
3. Works with zero setup. The docs snapshot ships inside the package and BM25 needs no key,
so uvx gets a working server in one command. Embeddings are an opt-in upgrade, measured to help
most on questions worded differently from the docs (e.g. "force every request to use HTTPS",
where the docs say HTTPSRedirectMiddleware).
4. Tested the way clients use it. Every test goes through a real MCP client session, one
launches the actual entry point over stdio as a subprocess, and a quality test re-runs the
labelled questions through search_docs and fails CI if recall@5 drops below 0.85.
Limitations
The docs are a snapshot (FastAPI commit
05e6df7, Nov 2026). Rebuilddocs_mcp/data/pages.jsonlwith rag-eval-lab'sscripts/build_corpus.pyto refresh it.English docs only; code examples included by reference in the docs (
{* ... *}) are not indexed.The embedding cache is a JSON file, fine for ~1,000 chunks, not for large corpora.
License
MIT. The bundled documentation is © Sebastián Ramírez under the MIT License (see docs_mcp/data/NOTICE.md).
Available Tools
3 toolsget_pageRead a FastAPI docs pageARead-onlyIdempotent
Return the full text of one documentation page.
Inputs: page (required). Returns: url, page, text, title, +1 more
list_pagesList FastAPI docs pagesARead-onlyIdempotent
List documentation pages, optionally only those under a section.
Inputs: prefix. Returns: count, pages
search_docsSearch the FastAPI docsARead-onlyIdempotent
Find the most relevant passages in the FastAPI documentation for a question.
Inputs: query (required), k. Returns: hits, query, retriever
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
The three tools cover clearly distinct retrieval modes: search returns snippets, get_page returns full page text, and list_pages enumerates the corpus. An agent can unambiguously pick among discovery, enumeration, and full read.
All three follow a consistent verb_noun snake_case pattern (search_docs, get_page, list_pages). No stylistic deviations.
Three tools is on the thin side, but for a read-only documentation lookup server each tool earns its place and covers a distinct retrieval strategy. Nothing feels redundant or padding.
Search, list, and full-page fetch cover the core documentation retrieval lifecycle with no dead ends. Minor gaps like section metadata or version/target-version awareness are missing but not blocking.
Maintenance
Related MCP Connectors
Versioned documentation registry and semantic search for AI tools and coding assistants.
Search and read Vector Panda docs: API operations, pricing, storage tiers, measured benchmarks.
Ingest, manage, and retrieve documents for RAG-powered AI applications
Tailor Platform for AI assistants: search, list and read the platform documentation.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables 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.-
- FlicenseNot gradedqualityDmaintenanceProvides RAG-based FastAPI documentation retrieval and project introspection tools via MCP, enabling LLMs to query reference docs, symbols, and project OpenAPI specs.-
- AlicenseAqualityBmaintenanceProvides AI assistants with real-time access to FastAPI documentation, enabling search, browsing, code examples, and comparisons.64MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol (MCP) server providing local-first access to Pydantic and Pydantic AI documentation with BM25-powered full-text search.91MIT