A high-performance Model Context Protocol (MCP) server that provides AI agents with instant access to Rust crate documentation through vector search.
# Install and run directly from GitHub (recommended)
uvx --from git+https://github.com/RimoVR/docsrs-mcp.git docsrs-mcp
# Or install from PyPI when published
uvx docsrs-mcp
- 🚀 Zero-install launch with
uvx
- no setup required - 🔍 Semantic vector search with <50ms response times
- 📚 Three-tier documentation system - 80%+ crate coverage via fallback extraction
- ⚡ Smart caching with SQLite + sqlite-vec and LRU eviction
- 🎯 Advanced ranking with MMR diversification for balanced results
- 🔄 Version comparison - Track API changes between crate versions
- 🌍 International support - Handles British/American spelling variations
- 🏃 Zero cold-start - Embeddings warmup eliminates first-query latency
- 📦 Popular crate pre-ingestion - Instant responses for commonly used crates
- 🔗 Re-export discovery - Automatic path alias resolution from rustdoc JSON
- 🦀 Rust stdlib support - Priority ingestion and detection of standard library crates
- 🔍 Dependency filtering - Intelligent filtering of dependency documentation
- 🎯 Advanced Search Modes - Vector (semantic), fuzzy (typo-tolerant), regex (pattern matching), and hybrid search
- 🛡️ ReDoS Protection - Secure regex search with timeout and pattern validation
- 🌐 Cross-Crate Search - Search across up to 5 crates simultaneously with RRF ranking
- ⚖️ Stability Filtering - Filter results by API stability level (stable/unstable/experimental)
- 📖 Progressive Detail Levels - Get documentation at summary, detailed, or expert levels
- 🔬 Usage Pattern Extraction - Automatically extract common patterns from code examples
- 🎓 Learning Path Generation - Generate migration paths or onboarding guides for APIs
# Install uv if needed
curl -LsSf https://astral.sh/uv/install.sh | sh
# Run the server
uvx --from git+https://github.com/RimoVR/docsrs-mcp.git docsrs-mcp
# Install uv
irm https://astral.sh/uv/install.ps1 | iex
# Run the server
uvx --from git+https://github.com/RimoVR/docsrs-mcp.git docsrs-mcp
docker build -t docsrs-mcp .
docker run -p 8000:8000 -v $(pwd)/cache:/app/cache docsrs-mcp
Add to your config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- Linux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"docsrs-mcp": {
"command": "uvx",
"args": ["--from", "git+https://github.com/RimoVR/docsrs-mcp.git", "docsrs-mcp"],
"env": {
"MAX_CACHE_SIZE_GB": "2"
}
}
}
}
# Add the server
claude mcp add docsrs -- uvx --from git+https://github.com/RimoVR/docsrs-mcp.git docsrs-mcp
# With custom settings
claude mcp add docsrs --env MAX_CACHE_SIZE_GB=5 -- uvx --from git+https://github.com/RimoVR/docsrs-mcp.git docsrs-mcp
Tool | Description |
---|---|
get_crate_summary |
Fetch crate metadata and module structure |
search_items |
Semantic search with type filtering and MMR diversification |
get_item_doc |
Full documentation with fuzzy path matching |
get_module_tree |
Navigate module hierarchies |
search_examples |
Find code examples with language detection |
compare_versions |
Analyze API changes between versions |
Tool | Description |
---|---|
start_pre_ingestion |
Pre-load popular crates for instant access |
ingest_cargo_file |
Bulk ingest dependencies from Cargo.toml/Cargo.lock with version resolution |
list_versions |
List all available crate versions |
Tool | Description |
---|---|
getDocumentationDetail |
Get documentation with progressive detail levels (summary/detailed/expert) |
extractUsagePatterns |
Extract common usage patterns from documentation and code examples |
generateLearningPath |
Generate learning paths for API migration or onboarding |
MCP Client Compatibility: All parameters are accepted as strings to ensure maximum compatibility with MCP clients like Claude Code. The server automatically converts these to appropriate types.
- Numeric parameters must be passed as strings (e.g.,
k="5"
,count="100"
) - Boolean parameters must be passed as strings (e.g.,
force="true"
,deprecated="false"
) - String parameters remain unchanged
- REST API continues to accept both strings and native types for backwards compatibility
{
"crate_name": "tokio",
"query": "spawn async tasks",
"k": "10",
"item_types": "function,struct"
}
{
"count": "100",
"concurrency": "3",
"force": "true"
}
{
"crate_name": "serde",
"item_path": "serde::Serialize",
"detail_level": "expert"
}
{
"crate_name": "tokio",
"limit": "10",
"min_frequency": "2"
}
{
"crate_name": "actix-web",
"from_version": "3.0.0",
"to_version": "4.0.0"
}
{
"file_path": "/path/to/Cargo.toml",
"concurrency": "5",
"skip_existing": "true",
"resolve_versions": "false"
}
- Tier 1: Rustdoc JSON from docs.rs (highest quality, ~15% coverage)
- Tier 2: Source extraction from crates.io CDN (80%+ coverage with macro support)
- Tier 3: Latest version fallback (100% guaranteed coverage)
- Search: <50ms P95 warm latency
- Fuzzy search: <300ms with 90% accuracy for common typos
- Regex search: <500ms with ReDoS protection
- Cross-crate search: <1s for 5 crates in parallel
- Ingestion: ≤3s for crates up to 10MB
- Memory: ≤1GB RSS including embeddings
- Cache: Auto-evicts at 2GB with LRU
- FastAPI + FastMCP for MCP protocol
- sqlite-vec for vector search (<100ms for 1M+ vectors)
- FastEmbed with BAAI/bge-small-en-v1.5 embeddings
- RapidFuzz for intelligent path matching
- ijson for memory-efficient streaming
# Clone and setup
git clone https://github.com/RimoVR/docsrs-mcp.git
cd docsrs-mcp
uv sync --dev
# Run locally
uv run docsrs-mcp
# Run tests
uv run pytest
# Format and lint
uv run ruff format .
uv run ruff check --fix .
# Server configuration
PORT=8000 # Server port
HOST=0.0.0.0 # Bind address
MAX_CACHE_SIZE_GB=2 # Cache size limit
LOG_LEVEL=INFO # Logging level
# Performance tuning
PRE_INGEST_ENABLED=true # Enable popular crate pre-loading
PRE_INGEST_COUNT=100 # Number of crates to pre-load
EMBEDDINGS_WARMUP=true # Eliminate cold-start latency
# Rust stdlib support
STDLIB_PRE_CACHE=true # Prioritize stdlib crates in pre-ingestion
RUSTUP_HOME=~/.rustup # Override rustup location (auto-detected by default)
# Dependency filtering
DEPENDENCY_FILTER=true # Enable dependency filtering in results
BLOOM_FILTER_CAPACITY=100000 # Expected number of dependency items
BLOOM_FILTER_ERROR_RATE=0.001 # Acceptable false positive rate
# Advanced
RANKING_DIVERSITY_WEIGHT=0.1 # MMR diversification strength
RANKING_DIVERSITY_LAMBDA=0.6 # Relevance vs diversity balance
import httpx
async with httpx.AsyncClient() as client:
response = await client.post(
"http://localhost:8000/mcp/tools/search_items",
json={
"crate_name": "tokio",
"query": "spawn async tasks",
"k": "5" # Note: string format for MCP compatibility
}
)
print(response.json())
response = await client.post(
"http://localhost:8000/mcp/tools/compare_versions",
json={
"crate_name": "serde",
"version_a": "1.0.0",
"version_b": "1.0.100"
}
)
# Fuzzy search for typo tolerance
search_items(query="tokio::spwan", search_mode="fuzzy")
# Regex pattern matching
search_items(regex_pattern="async.*spawn", search_mode="regex")
# Cross-crate search
search_items(query="error handling", crates=["tokio", "anyhow", "thiserror"])
# Stability filtering
search_items(query="async runtime", stability_filter="stable")
Issue | Solution |
---|---|
"uvx not found" | Install uv: curl -LsSf https://astral.sh/uv/install.sh | sh |
Port already in use | Change port: PORT=8001 uvx docsrs-mcp |
Rate limiting (429) | Default: 30 req/s per IP, implement backoff |
Memory errors | Ensure ≥256MB RAM available |
MCP validation errors | Ensure all numeric/boolean parameters are passed as strings (e.g., k="5" , force="true" ) |
- ✅ Three-tier fallback system for 80%+ crate coverage
- ✅ Version comparison for API evolution tracking
- ✅ MMR diversification for balanced search results
- ✅ Embeddings warmup for zero cold-start
- ✅ Popular crate pre-ingestion
- ✅ British/American spelling normalization
- ✅ Enhanced error messages with examples
- ✅ Batch processing optimizations
- ✅ Standard library support with fallbacks
- Standard library rustdoc JSON requires local generation via
rustup component add rust-docs-json
- Some older crates may only have Tier 2/3 documentation quality
MIT License - see LICENSE file
Contributions welcome! Please submit pull requests to the GitHub repository.
- Origin allowlist: Only fetches from docs.rs and crates.io
- Size limits: 30MB compressed / 100MB decompressed
- Input validation: Strict Pydantic models with comprehensive validation
- Rate limiting: Built-in protection against abuse
Report security issues to [email protected]