FastAPI Docs MCP Server
README.md
<h1 align="center">🐍 FastAPI Docs MCP Server 🤖</h1>
<p align="center">
<em>Real-time FastAPI documentation access for AI assistants</em>
</p>
<p align="center">
<a href="https://github.com/jaredthivener/fastapi-docs-mcp/actions/workflows/test.yml" target="_blank"><img src="https://github.com/jaredthivener/fastapi-docs-mcp/actions/workflows/test.yml/badge.svg?event=push&branch=main" alt="Test"></a>
<a href="https://github.com/jaredthivener/fastapi-docs-mcp/actions/workflows/codeql.yml" target="_blank"><img src="https://github.com/jaredthivener/fastapi-docs-mcp/actions/workflows/codeql.yml/badge.svg" alt="CodeQL"></a>
<a href="https://github.com/jaredthivener/fastapi-docs-mcp/blob/main/LICENSE" target="_blank"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
<a href="https://github.com/jaredthivener/fastapi-docs-mcp" target="_blank"><img src="https://img.shields.io/badge/python-3.13%2B-blue.svg" alt="Python 3.13+"></a>
</p>
<p align="center">
<img src="docs/hero.png" alt="FastAPI Docs MCP Server hero" width="640">
</p>
---
An [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server that provides real-time access to [FastAPI](https://fastapi.tiangolo.com/) 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
## 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
```bash
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):
```json
{
"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:
```json
{
"servers": {
"fastapi-docs": {
"command": "uv",
"args": ["run", "--directory", "/path/to/fastapi-docs-mcp", "fastapi-docs-mcp"]
}
}
}
```
### With Docker
Build the image locally:
```bash
docker build -t fastapi-docs-mcp .
```
Then use this MCP server config:
```json
{
"servers": {
"fastapi-docs": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"fastapi-docs-mcp"
],
"type": "stdio"
}
}
}
```
### Standalone
```bash
uv run fastapi-docs-mcp
```
## Development
```bash
# 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](CHANGELOG.md).
## License
MIT
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 issues