Rust Docs MCP server

Fetches and returns Rust crate documentation from docs.rs, providing essential context for working with Rust code.
Back to servers
Provider
0xKoda
Release date
Mar 06, 2025
Language
TypeScript
Stats
30 stars

This MCP server fetches and presents documentation for Rust crates, providing essential context for Large Language Models working with Rust code. It connects to docs.rs to retrieve the latest documentation for any publicly available Rust crate, formats it for readability, and delivers it in a way that's optimized for LLM consumption.

Installation

Prerequisites

  • Node.js
  • npm

Setup

# Clone the repository
git https://github.com/0xKoda/mcp-rust-docs.git
cd mcp-rust-docs

# Install dependencies
npm install

Usage

Starting the Server

You can start the server directly with:

npm start

Integrating with Claude Desktop

To integrate the server with Claude Desktop, add the following to your Claude Desktop configuration file (claude_desktop_config.json):

{
  "mcpServers": {
    "rust-docs": {
      "command": "node",
      "args": ["/absolute/path/to/index.js"]
    }
  }
}

Be sure to replace /absolute/path/to/index.js with the actual absolute path to the index.js file in the repository.

Example Queries

Once the server is running and configured with your AI assistant, you can ask questions such as:

  • "Look up the documentation for the 'tokio' crate"
  • "What features does the 'serde' crate provide?"
  • "Show me the documentation for 'ratatui'"
  • "Can you explain the main modules in the 'axum' crate?"

The AI will use the lookup_crate_docs tool to fetch and display the relevant documentation.

Testing with MCP Inspector

You can verify the server is working correctly using the MCP Inspector:

npx @modelcontextprotocol/inspector

Then select the "Connect to a local server" option and follow the prompts to test the functionality.

How It Works

The server implements a single MCP tool called lookup_crate_docs that:

  1. Takes a Rust crate name as input (defaults to 'tokio' if not provided)
  2. Fetches the documentation from docs.rs
  3. Converts the HTML to plain text for better readability
  4. Truncates content if it exceeds 8000 characters to avoid overwhelming the client
  5. Returns the formatted documentation in the proper MCP response format

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