Rust Docs MCP Server logo

Rust Docs MCP Server

by Govcraft

The Rust Docs MCP Server provides a focused, up-to-date knowledge source for specific Rust crates, addressing the limitations of AI coding assistants with rapidly evolving libraries. It allows LLMs to query current documentation, improving the accuracy and relevance of generated code.

View on GitHub

Last updated: N/A

What is Rust Docs MCP Server?

The Rust Docs MCP Server is a tool that fetches documentation for a specified Rust crate, generates embeddings for the content using OpenAI, and provides an MCP tool to answer questions about the crate based on the documentation context. It runs as a standard MCP server over stdio, exposing tools and resources to AI coding assistants.

How to use Rust Docs MCP Server?

  1. Install the server by downloading the pre-compiled binary or building from source.
  2. Set the OPENAI_API_KEY environment variable.
  3. Run the server from the command line, specifying the crate package ID (e.g., rustdocs_mcp_server "serde@^1.0"). Optionally, specify crate features using -F or --features.
  4. Configure your MCP client (like Roo Code or Claude Desktop) to use the server, providing the command and arguments.
  5. Use the query_rust_docs tool in your MCP client to ask questions about the crate's API or usage.

Key features of Rust Docs MCP Server

  • Targeted Documentation: Focuses on a single Rust crate per server instance.

  • Feature Support: Allows specifying required crate features for documentation generation.

  • Semantic Search: Uses OpenAI's text-embedding-3-small model.

  • LLM Summarization: Leverages OpenAI's gpt-4o-mini-2024-07-18 model.

  • Caching: Caches generated documentation content and embeddings.

  • MCP Integration: Runs as a standard MCP server over stdio.

Use cases of Rust Docs MCP Server

  • Improving the accuracy of code suggestions in AI coding assistants.

  • Providing up-to-date documentation for rapidly evolving Rust crates.

  • Enabling LLMs to answer specific questions about crate APIs and usage.

  • Supporting multiple Rust crates concurrently by running multiple server instances.

FAQ from Rust Docs MCP Server

What is an MCP server?

MCP stands for Model Context Protocol. It's a protocol that allows tools (like this server) to communicate with AI coding assistants.

Do I need an OpenAI API key?

Yes, the server uses the OpenAI API for generating embeddings and summarizing answers.

Where are the documentation and embeddings cached?

Cached data is stored in the XDG data directory, typically under ~/.local/share/rustdocs-mcp-server/.

How do I specify crate features?

Use the -F or --features flag when running the server, followed by a comma-separated list of features (e.g., rustdocs_mcp_server "[email protected]" -F runtime-tokio-hyper-rustls).

Why does the first run take so long?

The first run requires downloading the crate documentation and generating embeddings, which can take time depending on the size of the crate. Subsequent runs will use the cached data.