Rust is known for its steep learning curve but also for its excellent documentation. docs.rs is a treasure trove of information, but searching through it can sometimes slow down your development process.
To solve this, I built rust-docs, a Mastra MCP server that provides your AI assistant with direct access to Rust documentation from docs.rs.
GitHub repo: https://github.com/Michael-Obele/rust-docs
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, that can be especially painful because small version differences (or feature flags) change what types and methods are available.
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 like:
"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. You can configure it in your compatible editor to start querying Rust docs immediately.
For example, you can ask:
"How do I use the
tokio::select!macro?"
"What are the features available inserde?"
And 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):
https://rust-docs.mastra.cloud/api/mcp/rust-docs/sse
Example config (npx + mcp-remote):
{
"mcpServers": {
"rust-docs": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://rust-docs.mastra.cloud/api/mcp/rust-docs/sse"
]
}
}
}
HTTP endpoint (handy for one-off calls/scripts):
https://rust-docs.mastra.cloud/api/mcp/rust-docs/mcp
If this helped, consider starring the repo and sharing the post.
Top comments (0)