Fetches Rust crate documentation from docs.rs using the rustdoc JSON API, allowing lookup of entire crates or specific items like structs, functions, and traits with version specification support
Provides access to Rust language documentation, with tools for looking up specific crates, items, and API documentation with version-specific support
Uses SQLite for cache persistence, allowing for database querying and management of cached documentation with support for custom SQL queries
🦀 MCP Rust Docs Server
A Model Context Protocol (MCP) server for fetching Rust crate documentation from docs.rs using the rustdoc JSON API
Features • Installation • Usage • Building • Development • Notes • Contributing • License
✨ Features
- 🚀 Fast Documentation Fetching - Direct access to rustdoc JSON API for comprehensive crate documentation
- 🔍 Item-Level Lookup - Query specific structs, functions, traits, and more within crates
- 💾 Smart Caching - Built-in LRU cache with SQLite backend for optimal performance
- 🎯 Version Support - Fetch docs for specific versions or use semver ranges
- 🖥️ Cross-Platform - Standalone executables for Linux, macOS, and Windows
- 📦 Zero Dependencies - Single executable with everything bundled
- 🔧 TypeScript - Full type safety with modern ES modules
- 🗜️ Compression Support - Automatic Zstd decompression for efficient data transfer
📦 Installation
Using Bun
Using Pre-built Executables
Download the latest release for your platform from the Releases page:
Linux
- x64/AMD64 (GLIBC):
mcp-docsrs-linux-x64
- For Ubuntu, Debian, Fedora, etc. - ARM64 (GLIBC):
mcp-docsrs-linux-arm64
- For ARM64 systems, AWS Graviton - x64/AMD64 (MUSL):
mcp-docsrs-linux-x64-musl
- For Alpine Linux, Docker containers (requires libstdc++) - ARM64 (MUSL):
mcp-docsrs-linux-arm64-musl
- For Alpine on ARM64, minimal containers (requires libstdc++)
macOS
- Intel:
mcp-docsrs-darwin-x64
- For Intel-based Macs - Apple Silicon:
mcp-docsrs-darwin-arm64
- For M1/M2/M3 Macs
Windows
- x64:
mcp-docsrs-windows-x64.exe
- For 64-bit Windows
🚀 Usage
Starting the Server
Using npm or Bun
Using Executable
🛠️ Available Tools
lookup_crate_docs
Fetches comprehensive documentation for an entire Rust crate.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
crateName | string | ✅ | Name of the Rust crate |
version | string | ❌ | Specific version or semver range (e.g., "1.0.0", "~4") |
target | string | ❌ | Target platform (e.g., "i686-pc-windows-msvc") |
formatVersion | string | ❌ | Rustdoc JSON format version |
Example:
lookup_item_docs
Fetches documentation for a specific item within a crate.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
crateName | string | ✅ | Name of the Rust crate |
itemPath | string | ✅ | Path to the item (e.g., "struct.MyStruct", "fn.my_function") |
version | string | ❌ | Specific version or semver range |
target | string | ❌ | Target platform |
Example:
📊 Resources
The server provides resources for querying and inspecting the cache database:
cache://stats
Returns cache statistics including total entries, size, and oldest entry.
Example:
cache://entries?limit={limit}&offset={offset}
Lists cached entries with metadata. Supports pagination.
Parameters:
limit
- Number of entries to return (default: 100)offset
- Number of entries to skip (default: 0)
Example:
cache://query?sql={sql}
Execute SQL queries on the cache database (SELECT queries only for safety).
Example:
Note: SQL queries in the URI should be URL-encoded. The server will automatically decode them.
cache://config
Returns the current server configuration including all runtime parameters.
Example response:
⚙️ Configuration
Configure the server using environment variables or command-line arguments:
Variable | CLI Flag | Default | Description |
---|---|---|---|
CACHE_TTL | --cache-ttl | 3600000 | Cache time-to-live in milliseconds |
MAX_CACHE_SIZE | --max-cache-size | 100 | Maximum number of cached entries |
REQUEST_TIMEOUT | --request-timeout | 30000 | HTTP request timeout in milliseconds |
DB_PATH | --db-path | : | Path to SQLite database file (use :memory: for in-memory) |
Example:
🔌 MCP Configuration
Add to your MCP configuration file:
Or using the executable:
🏗️ Building
Prerequisites
- Bun v1.2.14 or later
- macOS, Linux, or Windows
Build Commands
Build Output
All executables are created in the dist/
directory with bytecode compilation for fast startup:
File | Platform | Type | Size |
---|---|---|---|
mcp-docsrs-linux-x64 | Linux x64/AMD64 | GLIBC + Bytecode | ~99MB |
mcp-docsrs-linux-arm64 | Linux ARM64 | GLIBC + Bytecode | ~93MB |
mcp-docsrs-linux-x64-musl | Linux x64/AMD64 | MUSL (static) + Bytecode | ~92MB |
mcp-docsrs-linux-arm64-musl | Linux ARM64 | MUSL (static) + Bytecode | ~88MB |
mcp-docsrs-darwin-x64 | macOS Intel | Bytecode | ~64MB |
mcp-docsrs-darwin-arm64 | macOS Apple Silicon | Bytecode | ~58MB |
mcp-docsrs-windows-x64.exe | Windows x64 | Bytecode | ~113MB |
👨💻 Development
Development Workflow
Testing
The project includes comprehensive tests for all major components:
Test Output
Tests are configured to provide clean output by default:
- ✅ Expected errors (like
CrateNotFoundError
in 404 tests) show as green checkmarks:✓ Expected CrateNotFoundError thrown
- ❌ Unexpected errors are shown with full stack traces in red
- ℹ️ Info logs are shown to track test execution
This makes it easy to distinguish between:
- Tests that verify error handling (expected errors)
- Actual test failures (unexpected errors)
To see full error details for debugging, set LOG_EXPECTED_ERRORS=true
.
Project Structure
📝 Notes
- 📅 The rustdoc JSON feature on docs.rs started on 2025-05-23, so releases before that date won't have JSON available
- 🔄 The server automatically handles redirects and format version compatibility
- ⚡ Cached responses significantly improve performance for repeated lookups
- 📦 Built executables include all dependencies - no runtime installation required
- ⚠️ MUSL builds limitation: Due to a known Bun issue, MUSL builds are not fully static and require
libstdc++
to run. For Docker/Alpine deployments, installlibstdc++
with:apk add libstdc++
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for the Rust community
This server cannot be installed
A Model Context Protocol (MCP) server for fetching Rust crate documentation from docs.rs using the rustdoc JSON API.
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol (MCP) server that provides JSON-RPC functionality through OpenRPC.Last updated -2733JavaScriptApache 2.0
- -securityFlicense-qualityAn MCP server that provides AI tools with access to Rust documentation from docs.rs, enabling search for crates, documentation, type information, feature flags, version information, and source code.Last updated -3TypeScript
- AsecurityAlicenseAqualityA documentation server based on MCP protocol designed for various development frameworks that provides multi-threaded document crawling, local document loading, keyword searching, and document detail retrieval.Last updated -237JavaScriptMIT License
- -securityAlicense-qualityA Model Context Protocol (MCP) server that scrapes, indexes, and searches documentation for third-party software libraries and packages, supporting versioning and hybrid search.Last updated -231129TypeScriptMIT License