MCP server for real-time library documentation access across multiple package ecosystems.
Project description
RTFD (Read The F*****g Docs) MCP Server
The RTFD (Read The F*****g Docs) MCP Server acts as a bridge between Large Language Models (LLMs) and real-time documentation. It allows coding agents to query package repositories like PyPI, npm, crates.io, GoDocs, DockerHub, and GitHub to retrieve the most up-to-date documentation and context.
This server solves a common problem where LLMs hallucinate APIs or provide outdated code examples because their training data is months or years old. By giving agents access to the actual documentation, RTFD ensures that generated code is accurate and follows current best practices.
Why use RTFD?
- Accuracy: Agents can access the latest documentation for libraries, ensuring they use the correct version-specific APIs and avoid deprecated methods.
- Context Awareness: Instead of just getting a raw text dump, the server extracts key sections like installation instructions, quickstart guides, and API references, giving the agent exactly what it needs.
- Privacy: Unlike cloud-based documentation services, RTFD runs entirely on your local machine. Your queries and the documentation you access never leave your system, ensuring complete privacy and no data collection.
- Supported Sources: PyPI (Python), npm (JavaScript/TypeScript), crates.io (Rust), GoDocs (Go), Zig docs, DockerHub, and GitHub repositories.
Use Cases
RTFD helps in scenarios like:
-
Refactoring old code: Fetch current
pandasdocs to find deprecated methods and their replacements. Instead of guessing what changed, the LLM reads the actual upgrade guide. -
Unfamiliar libraries: Integrating a Rust crate you've never seen? Look up the exact version, feature flags, and examples directly from the docs instead of guessing the API from general patterns.
-
Libraries after training cutoff: Using a library released after the LLM's training data ends? Fetch the actual README and code examples from GitHub so the LLM can write correct usage instead of hallucinating APIs.
-
Docker optimization: When optimizing a Dockerfile, inspect the official
python:3.11-slimimage to see exactly what packages and OS layers are included, rather than making assumptions. -
Dependency audits: Check PyPI, npm, and crates.io for available updates across all your dependencies. The LLM sees the latest versions and can generate an audit report without manually visiting each registry.
Features
- Documentation Content Fetching: Retrieve actual documentation content (README and key sections) from PyPI, npm, and GitHub rather than just URLs.
- Smart Section Extraction: Automatically prioritizes and extracts relevant sections such as "Installation", "Usage", and "API Reference" to reduce noise.
- Format Conversion: Automatically converts reStructuredText and HTML to Markdown for consistent formatting and easier consumption by LLMs.
- Multi-Source Search: Aggregates results from PyPI, npm, crates.io, GoDocs, Zig docs, DockerHub, and GitHub.
- Pluggable Architecture: Easily add new documentation providers by creating a single provider module.
- Error Resilience: Failures in one provider do not crash the server; the system is designed to degrade gracefully.
Installation
From PyPI (Recommended)
pip install rtfd-mcp
Or with uv:
uv pip install rtfd-mcp
From source
Clone the repository and install:
git clone https://github.com/aserper/RTFD.git
cd RTFD
pip install .
# or: uv pip install -e .
Quickstart
-
Export a GitHub token to avoid strict rate limits (optional but recommended):
export GITHUB_TOKEN=ghp_your_token_here
-
Run the server:
rtfd
-
Configure Documentation Fetching (Optional): Content fetching tools are enabled by default. To disable them and only use metadata tools:
export RTFD_FETCH=false rtfd
-
Configure Token Counting (Optional): To enable token counting in response metadata (useful for debugging usage):
export RTFD_TRACK_TOKENS=true rtfd
-
Configure Caching (Optional): Caching is enabled by default to improve performance and reduce load on providers.
- Enable/Disable:
export RTFD_CACHE_ENABLED=false(default:true) - TTL:
export RTFD_CACHE_TTL=3600(default:604800seconds / 1 week) - Location:
~/.cache/rtfd/cache.db
- Enable/Disable:
Releases & Versioning
For maintainers, see CONTRIBUTING.md for the automated release process.
To release a new version:
- Go to Actions tab on GitHub
- Select "Release to PyPI" workflow
- Click "Run workflow"
- Select version bump type (patch, minor, or major)
- Done! The workflow will:
- Update version in code
- Create a git tag and commit
- Create a GitHub release
- Automatically publish to PyPI
For local version management:
python scripts/bump_version.py patch # 0.1.0 → 0.1.1
python scripts/bump_version.py minor # 0.1.0 → 0.2.0
python scripts/bump_version.py major # 0.1.0 → 1.0.0
Available Tools
All tool responses are returned in JSON format.
Aggregator
search_library_docs(library, limit=5): Combined lookup across all providers (PyPI, npm, crates.io, GoDocs, GitHub). Note: Zig and DockerHub are accessed via dedicated tools.
Cache Management
get_cache_info(): Get cache statistics including entry count, database size, and location.get_cache_entries(): Get detailed information about all cached items including age, size, and content preview.
Documentation Content Fetching
fetch_pypi_docs(package, max_bytes=20480): Fetch Python package documentation from PyPI.fetch_npm_docs(package, max_bytes=20480): Fetch npm package documentation.fetch_godocs_docs(package, max_bytes=20480): Fetch Go package documentation from godocs.io (e.g., 'github.com/gorilla/mux').fetch_github_readme(repo, max_bytes=20480): Fetch README from a GitHub repository (format: "owner/repo").fetch_docker_image_docs(image, max_bytes=20480): Fetch Docker image documentation and description from DockerHub (e.g., "nginx", "postgres", "user/image").fetch_dockerfile(image): Fetch the Dockerfile for a Docker image by parsing its description for GitHub links (best-effort).
Metadata Providers
pypi_metadata(package): Fetch Python package metadata.npm_metadata(package): Fetch JavaScript package metadata.crates_metadata(crate): Get Rust crate metadata.search_crates(query, limit=5): Search Rust crates.godocs_metadata(package): Retrieve Go package documentation.zig_docs(query): Search Zig documentation.docker_image_metadata(image): Get DockerHub Docker image metadata (stars, pulls, description, etc.).search_docker_images(query, limit=5): Search for Docker images on DockerHub.github_repo_search(query, limit=5, language="Python"): Search GitHub repositories.github_code_search(query, repo=None, limit=5): Search code on GitHub.
Integration with Claude Code
Add the following to your ~/.claude/settings.json:
{
"mcpServers": {
"rtfd": {
"command": "rtfd",
"type": "stdio"
}
}
}
Or with environment variables:
{
"mcpServers": {
"rtfd": {
"command": "bash",
"args": ["-c", "export GITHUB_TOKEN=your_token_here && rtfd"],
"type": "stdio"
}
}
}
Pluggable Architecture
The RTFD server uses a modular architecture. Providers are located in src/RTFD/providers/ and implement the BaseProvider interface. New providers are automatically discovered and registered upon server restart.
To add a custom provider, create a new file in the providers directory inheriting from BaseProvider, implement the required methods, and the server will pick it up automatically.
Notes
- Token Counting: Disabled by default. Set
RTFD_TRACK_TOKENS=trueto see token stats in Claude Code logs. - Rate Limiting: The crates.io provider respects the 1 request/second limit.
- Dependencies:
mcp,httpx,beautifulsoup4,markdownify,docutils,tiktoken.
Architecture
- Entry point:
src/RTFD/server.pycontains the main search orchestration tool. Provider-specific tools are insrc/RTFD/providers/. - Framework: Uses
mcp.server.fastmcp.FastMCPto declare tools and run the server over stdio. - HTTP layer:
httpx.AsyncClientwith a shared_http_client()factory that applies timeouts, redirects, and user-agent headers. - Data model: Responses are plain dicts for easy serialization over MCP.
- Serialization: Tool responses use
serialize_response_with_meta()fromutils.py. - Token counting: Optional token statistics in the
metafield (disabled by default). Enable withRTFD_TRACK_TOKENS=true.
Serialization and Token Counting
Tool responses are handled by serialize_response_with_meta() in utils.py:
- Token statistics: When
RTFD_TRACK_TOKENS=true, the response includes a_metafield with token counts (tokens_json,tokens_sent,bytes_json). - Token counting: Uses
tiktokenlibrary withcl100k_baseencoding (compatible with Claude models). - Zero-cost metadata: Token statistics appear in the
_metafield ofCallToolResult, which is visible in Claude Code's special metadata logs but NOT sent to the LLM, costing 0 tokens.
Extensibility & Development
Adding Providers
The RTFD server uses a modular architecture. Providers are located in src/RTFD/providers/ and implement the BaseProvider interface. New providers are automatically discovered and registered upon server restart.
To add a custom provider:
- Create a new file in
src/RTFD/providers/. - Define async functions decorated with
@mcp.tool(). - Ensure tools return
CallToolResultusingserialize_response_with_meta(result_data).
Development Notes
- Dependencies: Declared in
pyproject.toml(Python 3.10+). - Testing: Use
pytestto run the test suite. - Environment: If you change environment-sensitive settings (e.g.,
GITHUB_TOKEN), restart thertfdprocess.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rtfd_mcp-0.1.1.tar.gz.
File metadata
- Download URL: rtfd_mcp-0.1.1.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
298d7023b800cc5ac6abf7620f417843b0e5b4dfd56917338f7f724222a8238f
|
|
| MD5 |
2d6e06b0fc9b47b31e6aa28164a806a5
|
|
| BLAKE2b-256 |
f1755e60f2ca77d8872a28009689e562fb755a4be7f7df9dbab961ac394f6278
|
File details
Details for the file rtfd_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: rtfd_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 35.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7719c3668b1f473aa983869032d66d250057cc036af3a838c484e0f3f8ac640f
|
|
| MD5 |
ab62a2b2c1b75802be9138987676018c
|
|
| BLAKE2b-256 |
ff0574bf2c6333194585de7c483fec23b3813f56476ecc38529d0955d9588309
|