|
1 | 1 | # mcp-server-python-docs |
2 | 2 |
|
3 | | -A read-only, version-aware MCP server for Python standard library documentation. Gives Claude and other LLM clients precise, section-level answers to Python stdlib questions -- without flooding the context window with entire doc pages. |
| 3 | +A read-only, version-aware MCP server for Python standard library documentation, optimized for low-token, section-level retrieval. |
| 4 | + |
| 5 | +It gives Claude, Cursor, and other MCP clients precise answers to Python stdlib questions without dumping whole documentation pages into the context window. |
| 6 | + |
| 7 | +## Why this exists |
| 8 | + |
| 9 | +General-purpose doc retrieval is often noisy for Python stdlib questions: |
| 10 | + |
| 11 | +- symbol lookups like `asyncio.TaskGroup` need exact resolution |
| 12 | +- answers should be version-aware (`3.12` vs `3.13`) |
| 13 | +- full-page fetches waste tokens when one section is enough |
| 14 | +- official Python docs are the source of truth, but not packaged for MCP out of the box |
| 15 | + |
| 16 | +This server builds a local index from official Python documentation and exposes a small MCP tool surface tuned for high-signal retrieval. |
| 17 | + |
| 18 | +## What you get |
| 19 | + |
| 20 | +- exact symbol lookup from Python `objects.inv` |
| 21 | +- section-level retrieval with truncation and pagination |
| 22 | +- local SQLite + FTS5 index, no runtime web scraping |
| 23 | +- version-aware results across indexed Python versions |
| 24 | +- read-only MCP tools with deterministic behavior |
| 25 | + |
| 26 | +## Quick example |
| 27 | + |
| 28 | +**Prompt** |
| 29 | + |
| 30 | +> What does `asyncio.TaskGroup` do in Python 3.13? |
| 31 | +
|
| 32 | +**Typical flow** |
| 33 | + |
| 34 | +1. `search_docs("asyncio.TaskGroup", kind="symbol", version="3.13")` |
| 35 | +2. call `get_docs(...)` using the slug and anchor returned by the best hit |
| 36 | + |
| 37 | +**Result** |
| 38 | + |
| 39 | +The model gets the exact symbol match and the relevant documentation section instead of a full-page dump. |
4 | 40 |
|
5 | 41 | ## Install |
6 | 42 |
|
@@ -66,13 +102,23 @@ Add to your Cursor MCP settings (`.cursor/mcp.json` in your project or global se |
66 | 102 |
|
67 | 103 | ## Tools |
68 | 104 |
|
69 | | -The server exposes three MCP tools: |
| 105 | +The server currently exposes four MCP tools: |
70 | 106 |
|
71 | 107 | | Tool | Description | |
72 | 108 | |------|-------------| |
73 | 109 | | `search_docs` | Search Python stdlib docs by query. Supports symbol lookup (`asyncio.TaskGroup`), module search (`json`), and free-text search. Returns ranked hits with BM25 scoring and snippet excerpts. | |
74 | | -| `get_docs` | Retrieve a specific documentation section by slug and optional anchor. Returns markdown content with budget-enforced truncation and pagination. | |
| 110 | +| `get_docs` | Retrieve a specific documentation page or section by slug and optional anchor. Returns markdown content with budget-enforced truncation and pagination. | |
75 | 111 | | `list_versions` | List all indexed Python versions with their metadata. | |
| 112 | +| `detect_python_version` | Detect the user's local Python version and report whether it matches an indexed documentation version. Helpful when `get_docs` defaults to the local runtime version. | |
| 113 | + |
| 114 | +The core docs surface is still intentionally small: search, retrieve, and inspect available versions. `detect_python_version` is a convenience helper for local workflows. |
| 115 | + |
| 116 | +## Positioning |
| 117 | + |
| 118 | +If you're evaluating whether this is useful in practice, the key point is simple: |
| 119 | + |
| 120 | +**this is not a generic web fetcher for Python docs.** |
| 121 | +It is a purpose-built MCP server for official Python documentation with exact symbol resolution, version awareness, and token-efficient section retrieval. |
76 | 122 |
|
77 | 123 | ## Diagnostics |
78 | 124 |
|
@@ -142,7 +188,7 @@ After running `build-index` to update the documentation index, you must restart |
142 | 188 |
|
143 | 189 | Tested on macOS and Linux. Windows should work (uses `platformdirs` + `pathlib` for cross-platform paths) but is not verified on every release. |
144 | 190 |
|
145 | | -Python 3.12 and 3.13 are supported. The index ships with documentation for both versions; queries default to 3.13 unless a specific version is requested. |
| 191 | +Python 3.12 and 3.13 are supported. When `search_docs` is called without a version, it searches across indexed versions. When `get_docs` is called without a version, it can default to the detected local Python runtime if a matching index exists. |
146 | 192 |
|
147 | 193 | ## License |
148 | 194 |
|
|
0 commit comments