The Rust Docs MCP Server allows you to give AI coding assistants up-to-date knowledge about Rust crates by providing them with a tool to query current documentation. This server helps bridge the gap between AI training cutoffs and the latest APIs in the Rust ecosystem.
OPENAI_API_KEY
environment variable..zip
for Windows, .tar.gz
for Linux/macOS)rustdocs_mcp_server
(or rustdocs_mcp_server.exe
) binaryPATH
(e.g., /usr/local/bin
, ~/bin
)If you prefer to build from source, you'll need the Rust Toolchain installed:
git clone https://github.com/Govcraft/rust-docs-mcp-server.git
cd rust-docs-mcp-server
cargo build --release
When using the server with a crate for the first time (or with a new version/feature set), it needs to download documentation and generate embeddings. This process can take time and requires an internet connection and OpenAI API key.
It's recommended to run the server once directly from your command line for any new crate configuration before adding it to your AI coding assistant. This allows the initial embedding generation and caching to complete.
Launch the server from the command line with the Package ID Specification for the target crate:
# Set your OpenAI API key
export OPENAI_API_KEY="sk-..."
# Run server for the latest 1.x version of serde
rustdocs_mcp_server "serde@^1.0"
# Run server for a specific version of reqwest
rustdocs_mcp_server "[email protected]"
# Run server for the latest version of tokio
rustdocs_mcp_server tokio
# Run server with required features
rustdocs_mcp_server "[email protected]" -F runtime-tokio-hyper-rustls
# Run server with multiple features
rustdocs_mcp_server "[email protected]" --features feat1,feat2
On first run, the server will:
Subsequent runs will use the cached data, making startup much faster.
Configure multiple server instances in Roo Code's mcp_settings.json
:
{
"mcpServers": {
"rust-docs-reqwest": {
"command": "/path/to/your/rustdocs_mcp_server",
"args": [
"[email protected]"
],
"env": {
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE"
},
"disabled": false,
"alwaysAllow": []
},
"rust-docs-async-stripe": {
"command": "rustdocs_mcp_server",
"args": [
"[email protected]",
"-F",
" runtime-tokio-hyper-rustls"
],
"env": {
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE"
},
"disabled": false,
"alwaysAllow": []
}
}
}
For Claude Desktop, configure the server in MCP settings:
{
"mcpServers": {
"rust-docs-serde": {
"command": "/path/to/your/rustdocs_mcp_server",
"args": [
"serde@^1.0"
]
},
"rust-docs-async-stripe-rt": {
"command": "rustdocs_mcp_server",
"args": [
"[email protected]",
"-F",
"runtime-tokio-hyper-rustls"
]
}
}
}
Remember to set the OPENAI_API_KEY
environment variable where Claude Desktop can access it.
The server communicates using the Model Context Protocol over stdio and exposes:
query_rust_docs
Query documentation for the specific Rust crate using semantic search and LLM summarization.
Input Schema:
{
"type": "object",
"properties": {
"question": {
"type": "string",
"description": "The specific question about the crate's API or usage."
}
},
"required": ["question"]
}
Example MCP Call:
{
"jsonrpc": "2.0",
"method": "callTool",
"params": {
"tool_name": "query_rust_docs",
"arguments": {
"question": "How do I make a simple GET request with reqwest?"
}
},
"id": 1
}
crate://<crate_name>
Provides the name of the Rust crate this server instance is configured for.
~/.local/share/rustdocs-mcp-server/
)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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.