home / mcp / rust docs mcp server

Rust Docs MCP Server

Provides up-to-date Rust crate documentation and a query tool for API usage.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "govcraft-rust-docs-mcp-server": {
      "command": "rustdocs_mcp_server",
      "args": [
        "serde@^1.0"
      ],
      "env": {
        "OPENAI_API_KEY": "YOUR_OPENAI_API_KEY"
      }
    }
  }
}

You run an MCP server to provide up-to-date Rust crate documentation to your AI coding assistant. The server downloads crate docs, creates embeddings, and exposes a standard MCP interface so your assistant can ask focused questions about a crate’s API and usage, getting accurate answers from current docs.

How to use

Start one or more MCP servers to target specific Rust crates. Each server runs independently and serves a single crate (with optional features). Your AI coding assistant can query the crate docs through the server’s built-in tool, enabling precise API answers during coding sessions.

To use a server with your MCP client, launch the server for the crate you want to explore, then point your MCP client at that server. You’ll load its tool named query_rust_docs to ask questions about the crate’s API or usage. Each crate/version/feature combination is cached after the first run to speed up subsequent starts.

How to install

Prerequisites you need before running the server:

  • OpenAI API key for generating embeddings and summarizing answers
  • Environment variable accessible to the server (OPENAI_API_KEY)
  • Network access to fetch crate documentation and reach OpenAI APIs

Install or run the server using the explicit crate specifications. You can run separate instances for multiple crates during a single session.

Basic steps to run a local, single-crate server from an installed binary or source build are shown below. Replace placeholder values with your actual crate and API key.

Here is a concrete example of starting a server for a crate with a specific version and features, using the standard stdio MCP interface.

export OPENAI_API_KEY="sk-REPLACE-WITH-YOUR-KEY"

# 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 for async-stripe with a required feature
rustdocs_mcp_server "[email protected]" -F runtime-tokio-hyper-rustls

# Run server for another crate with multiple features
rustdocs_mcp_server "[email protected]" --features feat1,feat2

Additional configuration details

The server stores cached documentation and embeddings in your XDG data directory to speed up subsequent runs. A cache miss triggers a fresh download of crate docs, generation of embeddings, and creation of the internal search index.

You can run multiple crate servers concurrently to provide context for several crates during a single coding session.

MCP interaction and tooling

Each server exposes a single MCP tool to answer crate queries.

Tool: query_rust_docs allows you to ask questions about the crate’s API or usage. The response is generated based on the retrieved documentation context.

The server uses a standard MCP interface over stdio to communicate with your MCP client.

Examples of running with multiple crates

Configure separate MCP client entries for each crate you want to query. Each entry points to its own server process and its own crate configuration.

// Example client configuration (conceptual)
{
  "mcpServers": {
    "rust-docs-serde": {
      "command": "/path/to/rustdocs_mcp_server",
      "args": ["serde@^1.0"],
      "env": {"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY"},
      "disabled": false,
      "alwaysAllow": []
    },
    "rust-docs-reqwest": {
      "command": "/path/to/rustdocs_mcp_server",
      "args": ["[email protected]"],
      "env": {"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY"},
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

Available tools

query_rust_docs

Query documentation for the active crate using semantic search and LLM summarization to answer API questions.