Rust Documentation at Your Fingertips with rust-docs MCP
Source: Dev.to
docs.rs is a treasure trove of information, but searching through it can sometimes slow down your development process.
rust-docs is a Mastra MCP server that provides your AI assistant with direct access to Rust documentation from docs.rs.
GitHub repo:
The Problem
When using AI coding assistants, they often rely on their training data, which can be outdated or lack knowledge of specific crate versions. This leads to “hallucinations” – code that looks correct but uses non‑existent APIs or incorrect syntax.
In Rust, small version differences (or feature flags) can change what types and methods are available, making these hallucinations especially painful.
The Solution: rust-docs
rust-docs connects your AI editor to the live documentation on docs.rs. This means:
- Up‑to‑Date Info – Your AI can look up the exact signature of a function or struct in the specific version of the crate you are using.
- Crate Exploration – Discover new crates and modules without leaving your IDE.
- Expert Assistance – With access to the official docs, your AI becomes a much more reliable Rust expert.
What to Ask For (to Get the Best Results)
The more you “name the thing”, the easier it is for the tool to retrieve the correct documentation:
- Crate + module path: “Look up
reqwest::ClientBuilder” - Macro syntax: “Show
tokio::select!examples and common pitfalls” - Trait bounds: “What trait does
?require on my error type?”
You can also ask version‑sensitive questions, e.g.:
“In
axum0.7, what’s the recommended way to extract JSON and validate it?”
Even when the assistant doesn’t know your version ahead of time, rust-docs gives it a way to verify what exists.
How to Use
The server is available as an MCP tool. Configure it in your compatible editor to start querying Rust docs immediately.
Example queries
- “How do I use the
tokio::select!macro?” - “What are the features available in
serde?”
The AI will fetch the relevant pages from docs.rs to provide a precise answer.
When It Shines
- Crate upgrades – sanity‑check API changes without bouncing between tabs.
- Feature flags – confirm whether a type/method is behind a feature.
- Macros – get the exact invocation patterns from real docs (instead of folklore).
Wrapping Up
rust-docs helps bridge the gap between Rust’s extensive documentation and the immediate context needed by AI assistants. It’s a small tool that makes a big difference in daily Rust development.
Quick Setup (Mastra Cloud)
SSE Endpoint (best for editors that keep a persistent connection)
Example Config (npx + mcp‑remote)
{
"mcpServers": {
"rust-docs": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://rust-docs.mastra.cloud/api/mcp/rust-docs/sse"
]
}
}
}