Rust Docs MCP server

Efficiently loads and processes Rust crate documentation using LlamaIndex's HTML reader, with intelligent file selection logic to handle duplicate files and optional comprehensive parsing modes.
Back to servers
Provider
Govcraft
Release date
Mar 26, 2025
Language
TypeScript
Stats
71 stars

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.

Prerequisites

  • OpenAI API Key: Required for generating embeddings and summarizing answers. Set this in the OPENAI_API_KEY environment variable.
  • Internet Access: Needed to download crate dependencies and communicate with the OpenAI API.

Installation

Pre-compiled Binaries (Recommended)

  1. Visit the GitHub Releases page
  2. Download the appropriate archive for your system (.zip for Windows, .tar.gz for Linux/macOS)
  3. Extract the rustdocs_mcp_server (or rustdocs_mcp_server.exe) binary
  4. Place the binary in a directory included in your system's PATH (e.g., /usr/local/bin, ~/bin)

Building from Source

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

Usage

Important Note for New Crates

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.

Running the Server

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:

  1. Download the crate documentation
  2. Parse the HTML documentation
  3. Generate embeddings using OpenAI API
  4. Cache the content and embeddings
  5. Start the MCP server

Subsequent runs will use the cached data, making startup much faster.

Client Configuration

Roo Code Configuration

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": []
    }
  }
}

Claude Desktop Configuration

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.

MCP Interaction

The server communicates using the Model Context Protocol over stdio and exposes:

Tool: 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
}

Resource: crate://<crate_name>

Provides the name of the Rust crate this server instance is configured for.

Caching

  • Cached documentation and embeddings are stored in the XDG data directory (typically ~/.local/share/rustdocs-mcp-server/)
  • Different feature sets are cached separately
  • If the cache is missing or corrupted, the server automatically regenerates the documentation and embeddings

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later