A read-only, version-aware MCP server for Python standard library documentation, optimized for low-token, section-level retrieval.
It gives Claude, Cursor, Codex, and other MCP clients precise stdlib answers without dumping whole documentation pages into the context window, without API keys, and without depending on a hosted docs provider at query time.
General-purpose docs retrieval is often noisy for Python stdlib questions:
- symbol lookups like
asyncio.TaskGroupneed exact resolution - answers should be version-aware (
3.12vs3.13) - full-page fetches waste tokens when one section is enough
- official Python docs are the source of truth, but they are not packaged for MCP out of the box
This server builds a local index from the official Python documentation and exposes a small MCP tool surface tuned for high-signal retrieval.
- no API keys to provision, rotate, or justify
- official Python docs are the source of truth
- local index, so runtime retrieval does not depend on a third-party hosted API
- read-only behavior with a simple security story
- easy to explain in environments where external dependencies raise friction
- exact symbol lookup from Python
objects.inv - section-level retrieval with truncation and pagination
- local SQLite + FTS5 index with no runtime web scraping
- version-aware results across indexed Python versions
- a deliberately small, read-only MCP tool surface
Prompt
What does
asyncio.TaskGroupdo in Python 3.13?
Typical flow
search_docs("asyncio.TaskGroup", kind="symbol", version="3.13")- Call
get_docs(...)using the slug and anchor returned by the best hit
Result
The model gets the exact symbol match and the relevant documentation section instead of a full-page dump.
Run it directly with uvx:
uvx mcp-server-python-docs --versionOr install it persistently:
pipx install mcp-server-python-docsIf uv is installed but the uv command is not on your PATH, reopen your
shell or use python -m uv ... as a fallback for local contributor commands.
Build the local documentation index:
uvx mcp-server-python-docs build-index --versions 3.10,3.11,3.12,3.13,3.14If you installed the package persistently, you can drop the uvx prefix:
mcp-server-python-docs build-index --versions 3.10,3.11,3.12,3.13,3.14This downloads Python's objects.inv files, clones CPython docs sources, runs
sphinx-build -b json, and writes an SQLite index to your local cache. Expect
the first build to take several minutes.
Add this to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Windows: %APPDATA%\\Claude\\claude_desktop_config.json
{
"mcpServers": {
"python-docs": {
"command": "uvx",
"args": ["mcp-server-python-docs"]
}
}
}Restart Claude Desktop after editing the config file.
Add this to your Cursor MCP settings (.cursor/mcp.json in your project or
global settings):
{
"mcpServers": {
"python-docs": {
"command": "uvx",
"args": ["mcp-server-python-docs"]
}
}
}Add this to .codex/config.toml:
[mcp_servers.python-docs]
command = "uvx"
args = ["mcp-server-python-docs"]The repo makes quality visible with reproducible checks instead of relying on marketing claims.
- CI runs
ruff,pyright, andpyteston macOS and Linux for Python 3.12 and 3.13 - subprocess-based stdio hygiene and smoke tests protect the MCP protocol pipe
- packaging tests verify the wheel contents and CLI entry points
- curated retrieval regression tests cover exact symbol hits, version behavior, missing symbols, truncation, and local-version defaults
- manual MCP QA is documented in
.github/INTEGRATION-TEST.md, with MCP Inspector as the fast-feedback loop and Claude/Cursor as real-client checks
Contributor commands and validation steps live in
CONTRIBUTING.md.
The server currently exposes five MCP tools:
| Tool | Description |
|---|---|
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. |
get_docs |
Retrieve a specific documentation page or section by slug and optional anchor. Returns markdown content with budget-enforced truncation and pagination. Retrieved results are cached on disk by Python docs version and request identity. |
lookup_package_docs |
Look up official PyPI package metadata and return package-declared documentation/homepage/source URLs. This is a controlled PyPI metadata lookup, not generic web search. |
list_versions |
List all indexed Python versions with metadata. |
detect_python_version |
Detect the user's local Python version and report whether it matches an indexed documentation version. |
Use this server when you need:
- exact Python stdlib symbol resolution
- consistent version-aware answers across Python 3.10 through 3.14
- token-efficient section retrieval from official docs
- a local, read-only MCP server with a simple operational story
Use a generic fetcher or broader docs MCP when you need:
- arbitrary third-party package content beyond package-declared PyPI metadata
- arbitrary web pages
- mixed-source research across many frameworks
get_docs responses are cached across MCP client/server restarts in the
platform cache directory:
<platform cache dir>/mcp-python-docs/retrieved-docs-cache.sqlite3
The cache stores completed get_docs results, including page/section content,
for the resolved Python docs version plus request identity (slug, optional
anchor, max_chars, and start_index). Cache misses fall back to the normal
local index retrieval path and then write the retrieved result.
Cache entries are also scoped to a fingerprint of the local index.db file
(path, size, and modification timestamp). If you rebuild or replace the local
docs index, older entries are ignored automatically instead of being returned
for the new index generation. Deleting retrieved-docs-cache.sqlite3 is safe;
it only removes cached retrieval results, not the docs index.
lookup_package_docs queries the official PyPI JSON API documented at
https://docs.pypi.org/api/json/ (GET /pypi/<project>/json) and returns only
sources declared in that package's PyPI metadata: the PyPI project URL,
docs_url, home_page, and allowlisted project_urls labels such as
Documentation, Homepage, Source, and Repository.
The tool makes the trust boundary explicit with
trust_boundary="pypi-declared-metadata". It does not crawl pages, perform web
search, or silently fall back to unofficial community mirrors.
Check the local environment:
uvx mcp-server-python-docs doctorThis checks the runtime Python version, SQLite FTS5, cache/index paths, disk
space, and whether the current interpreter has the venv/ensurepip support
needed by build-index.
Validate an existing index:
uvx mcp-server-python-docs validate-corpusIf you see an error about SQLite FTS5 not being available:
Linux x86-64
pip install 'mcp-server-python-docs[pysqlite3]'macOS / Windows / Linux ARM
Install Python from python.org or use:
uv python installIf doctor reports that build venv support is unavailable, install the venv
package for the same Python minor version that runs the server:
sudo apt install python3.12-venvAdjust 3.12 to match the version shown by doctor. Without this package,
build-index cannot create the disposable Sphinx environment it uses to build
JSON documentation content.
If uvx mcp-server-python-docs runs an old version:
uvx --reinstall mcp-server-python-docsOr clear the uv cache:
uv cache clean mcp-server-python-docsThe MSIX-packaged version of Claude Desktop on Windows may have restricted PATH
access. If uvx is not found, specify the full path in your config:
{
"mcpServers": {
"python-docs": {
"command": "C:\\Users\\YOU\\.local\\bin\\uvx.exe",
"args": ["mcp-server-python-docs"]
}
}
}Replace YOU with your Windows username. Find the exact path with where uvx.
After running build-index, restart your MCP client so it picks up the new
database file. The server opens the index read-only at startup and does not
hot-reload an updated database.
On Windows, close the MCP client before rebuilding if the index file is locked.
For contributor setup and verification:
Tested on macOS and Linux. Windows should work, but it is not verified on every release.
Python documentation versions 3.10 through 3.14 are currently supported.
MIT