The MCP Rust Docs Server provides access to Rust crate documentation from docs.rs using the rustdoc JSON API. It implements the Model Context Protocol (MCP) to make Rust documentation easily accessible to language models and tools that support the MCP standard.
Download the latest release for your platform from the Releases page:
# For Ubuntu, Debian, Fedora, etc.
wget https://github.com/vexxvakan/mcp-docsrs/releases/latest/download/mcp-docsrs-linux-x64
chmod +x mcp-docsrs-linux-x64
# For Apple Silicon Macs
wget https://github.com/vexxvakan/mcp-docsrs/releases/latest/download/mcp-docsrs-darwin-arm64
chmod +x mcp-docsrs-darwin-arm64
Download mcp-docsrs-windows-x64.exe
directly from the releases page.
# Pull the latest image
docker pull ghcr.io/vexxvakan/mcp-docsrs:latest
# Run the server
docker run --rm -i ghcr.io/vexxvakan/mcp-docsrs:latest
bun install
bun run build:bytecode # or bun run build:all for all platforms
# Show help
./mcp-docsrs --help
# Run with default settings
./mcp-docsrs
# Run with custom configuration
./mcp-docsrs --cache-ttl 7200000 --max-cache-size 200
# Production mode
npm start
# or
bun start
# Development mode with hot reload
npm run dev
# or
bun run dev
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:
{
"tool": "lookup_crate_docs",
"arguments": {
"crateName": "serde",
"version": "latest"
}
}
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:
{
"tool": "lookup_item_docs",
"arguments": {
"crateName": "tokio",
"itemPath": "runtime.Runtime"
}
}
Search for Rust crates on crates.io with fuzzy/partial name matching.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
query |
string | ✅ | Search query for crate names (supports partial matches) |
limit |
number | ❌ | Maximum number of results to return (default: 10) |
Example:
{
"tool": "search_crates",
"arguments": {
"query": "serde",
"limit": 5
}
}
The server provides resources for querying and inspecting the cache database:
Returns cache statistics including total entries, size, and oldest entry.
Lists cached entries with metadata. Supports pagination.
Execute SQL queries on the cache database (SELECT queries only for safety).
Returns the current server configuration including all runtime parameters.
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 |
:memory: | Path to SQLite database file |
Example:
# Environment variables
CACHE_TTL=7200000 MAX_CACHE_SIZE=200 npm start
# Command-line arguments (executable)
./mcp-docsrs --cache-ttl 7200000 --max-cache-size 200
# Use persistent database to cache documentation between sessions
./mcp-docsrs --db-path ~/.mcp-docsrs
Add to your MCP configuration file:
{
"mcpServers": {
"rust-docs": {
"command": "/path/to/mcp-docsrs"
}
}
}
Or using Docker:
{
"mcpServers": {
"rust-docs": {
"command": "docker",
"args": ["run", "--rm", "-i", "ghcr.io/vexxvakan/mcp-docsrs:latest"]
}
}
}
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "rust-docs" '{"command":"/path/to/mcp-docsrs"}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"rust-docs": {
"command": "/path/to/mcp-docsrs"
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"rust-docs": {
"command": "/path/to/mcp-docsrs"
}
}
}
3. Restart Claude Desktop for the changes to take effect