Sandbox
@snowmead/rust-docs-mcp

MCP server for Rust docs and source analysis

Rustdocs MCP Server gives agents access to Rust crate docs, source code, dependency graphs, and module trees through MCP. It caches crates from crates.io, GitHub, or local paths, then lets you search items, inspect details, read source, and trace dependencies.

135 starsβ€’11 forksβ€’Rustβ€’Updated 7d ago
Who it's for

Builders who use an agent to inspect Rust crates before coding.

What it delivers

You can ask your agent to explore Rust crates deeply instead of guessing from stale examples.

What it does

Crate caching

Downloads crates from crates.io, GitHub, or local paths and stores them for later use.

Documentation search

Searches crate items by pattern, kind, or path, with preview and fuzzy search modes.

Item inspection

Returns signatures, fields, methods, docs, and source for specific Rust items.

Dependency analysis

Shows direct and transitive dependencies with metadata.

Module structure views

Generates hierarchical module trees through `cargo-modules` integration.

Offline access

Keeps cached crates available for repeated analysis without hitting the network.

CLI and MCP modes

Runs as a stdio MCP server or as one-shot CLI commands like `call cache-crate` and `call search-items-fuzzy`.

How to get it

  1. 1Run
    curl -sSL https://raw.githubusercontent.com/snowmead/rust-docs-mcp/main/install.sh | bash
  2. 2Run
    curl -sSL https://raw.githubusercontent.com/snowmead/rust-docs-mcp/main/install.sh | bash
  3. 3Run
    curl -sSL https://raw.githubusercontent.com/snowmead/rust-docs-mcp/main/install.sh | bash -s -- --install-dir /usr/local/bin
  4. 4Run
    cargo install rust-docs-mcp
  5. 5Rust nightly toolchain (for Rustdoc JSON generation)
    rustup toolchain install nightly-2026-05-22
  6. 6Runtime prefers nightly-2026-05-22, which provides rustc 1.97.0-nightly (e96c36b6f…
    export RUST_DOCS_MCP_TOOLCHAIN=nightly

README

rust-docs banner

Rustdocs MCP Server

Crates.io License: MIT Discord Build Status Ask DeepWiki

Rust is the language of AI

An MCP (Model Context Protocol) server that provides comprehensive access to Rust crate documentation, source code analysis, dependency trees, and module structure visualization. Built for agents to gain quality insights into Rust projects and build with confidence.

Warning

This is an entirely vibe coded project and was created as an experiment to see if LLMs can build a fully functional tool without human oversight.

The Problem: Agents Building in the Dark

The rise of AI agents has revolutionized software development, with new tools and libraries emerging at an unprecedented pace. However, this rapid evolution creates a critical challenge: agents cannot reliably build with tools they weren't trained on.

When an agent tries to use a new Rust crate:

  • 🚫 Training data is outdated β€” The model hasn't seen recent crates or API changes
  • 🚫 Documentation scraping is inefficient β€” Web scraping GitHub or docs.rs is slow and unreliable
  • 🚫 Examples aren't enough β€” Copy-pasting README examples provides surface-level understanding
  • 🚫 Internal structure is opaque β€” Agents can't explore how modules, traits, and types interconnect

This leads to frustrated developers watching their agents fail repeatedly, guessing at APIs, and producing broken code.

The Solution: Deep Crate Intelligence

This MCP server gives agents the tools they need to truly understand Rust crates:

  • πŸ” Explore internal structure β€” Navigate module hierarchies and type relationships
  • πŸ“– Access complete documentation β€” Full rustdoc with signatures, fields, and methods
  • πŸ”— Trace dependencies β€” Understand what a crate depends on and why
  • πŸ’Ύ Work offline β€” Cache crates locally for instant, reliable access
  • 🎯 Query precisely β€” Search by pattern, kind, or path to find exactly what's needed

With these capabilities, agents can build confidently with any Rust crate β€” even ones released yesterday.

Agent Capabilities

  • Multi-source caching β€” crates.io, GitHub repositories, local filesystem paths
  • Workspace support β€” Individual member analysis and caching for cargo workspaces
  • Documentation search β€” Pattern matching with kind/path filtering and preview modes
  • Item inspection β€” Detailed signatures, fields, methods, and documentation strings
  • Source code access β€” Line-level precision with parameterized surrounding context
  • Dependency analysis β€” Direct and transitive dependency trees with metadata
  • Module structure β€” Hierarchical tree generation via cargo-modules integration
  • Offline operation β€” Full functionality after initial crate caching
  • Token management β€” Response truncation and preview modes for LLM compatibility

MCP Tools

Cache Management

  • cache_crate - Download and cache a crate from various sources. Set source_type to one of: cratesio, github, or local
    • For cratesio: Provide version (e.g., {crate_name: "serde", source_type: "cratesio", version: "1.0.215"})
    • For github: Provide github_url and either branch OR tag (e.g., {crate_name: "my-crate", source_type: "github", github_url: "https://github.com/user/repo", tag: "v1.0.0"})
    • For local: Provide path, optional version (e.g., {crate_name: "my-crate", source_type: "local", path: "~/projects/my-crate"})
    • Optional features: Specific features to enable instead of --all-features. Use for crates with mutually exclusive features (e.g., {crate_name: "leptos-use", source_type: "cratesio", version: "0.15.8", features: ["axum"]})
  • remove_crate - Remove cached crate versions to free disk space
  • list_cached_crates - View all cached crates with versions and sizes
  • list_crate_versions - List cached versions for a specific crate
  • get_crates_metadata - Batch metadata queries for multiple crates
  • cache_operations - Manage and monitor background caching operations (list, status, cancel, clear)

Documentation Queries

  • list_crate_items - Browse all items in a crate with optional filtering
  • search_items - Full search with complete documentation (may hit token limits)
  • search_items_preview - Lightweight search returning only IDs, names, and types
  • get_item_details - Detailed information about specific items (signatures, fields, etc.)
  • get_item_docs - Extract just the documentation string for an item
  • get_item_source - View source code with configurable context lines

Dependency Analysis

  • get_dependencies - Analyze direct and transitive dependencies with filtering

Structure Analysis

  • structure - Generate hierarchical module tree using integrated cargo-modules

Search

  • search_items_fuzzy - Fuzzy search with typo tolerance and semantic similarity

Configuration

Cache Directory

By default, crates are cached in ~/.rust-docs-mcp/cache/. You can customize this location using:

# Command line option
rust-docs-mcp --cache-dir /custom/path/to/cache
# or set the environment variable
export RUST_DOCS_MCP_CACHE_DIR=/custom/path/to/cache
rust-docs-mcp

GitHub Authentication

To access private repositories or increase GitHub API rate limits, set the GITHUB_TOKEN environment variable:

export GITHUB_TOKEN=your_github_personal_access_token

Benefits of authentication:

  • Access private repositories β€” Cache and analyze private Rust crates
  • Higher rate limits β€” 5,000 requests/hour (vs 60 unauthenticated)
  • Avoid rate limit errors β€” Essential for caching multiple GitHub-hosted crates

Each crate version stores

  • Complete source code in source/ directory
  • Cache metadata and timestamps in metadata.json
  • For workspace crates, individual members in members/ directory:
    • members/{member-name}/docs.json - Rustdoc JSON documentation
    • members/{member-name}/dependencies.json - Cargo dependency metadata
    • members/{member-name}/metadata.json - Member-specific cache metadata
  • For single crates:
    • docs.json - Rustdoc JSON documentation
    • dependencies.json - Cargo dependency metadata

Installation

Quick Install

curl -sSL https://raw.githubusercontent.com/snowmead/rust-docs-mcp/main/install.sh | bash

Installation Options

One-liner (Recommended)

curl -sSL https://raw.githubusercontent.com/snowmead/rust-docs-mcp/main/install.sh | bash

Custom install directory

curl -sSL https://raw.githubusercontent.com/snowmead/rust-docs-mcp/main/install.sh | bash -s -- --install-dir /usr/local/bin

Cargo Install

cargo install rust-docs-mcp

Building from Source

Requirements
  • Rust nightly toolchain (for Rustdoc JSON generation)

    rustup toolchain install nightly-2026-05-22
    

    Runtime prefers nightly-2026-05-22, which provides rustc 1.97.0-nightly (e96c36b6f 2026-05-21), so documentation generation can compile modern crates. The rustdoc-types dependency is kept in sync with that rustdoc JSON format. If the dated toolchain is missing, the runtime falls back to plain nightly, but only when it emits the same rustdoc JSON format version (57); newer nightlies will be rejected. You can override the choice with:

    export RUST_DOCS_MCP_TOOLCHAIN=nightly
    
  • Network access to download crates from crates.io

git clone https://github.com/snowmead/rust-docs-mcp
cd rust-docs-mcp/rust-docs-mcp
cargo build --release
./target/release/rust-docs-mcp install

CLI Commands

rust-docs-mcp                   # Start MCP server (same as `serve`)
rust-docs-mcp serve             # Start MCP server explicitly

# One-shot operations (stateless – print JSON to stdout and exit)
rust-docs-mcp call cache-crate \
  --params '{"crate_name":"serde","source_type":"cratesio","version":"1.0.215"}'

rust-docs-mcp call search-items-fuzzy \
  --params '{"crate_name":"serde","version":"1.0.215","query":"Deserialize","limit":10}'

rust-docs-mcp call list-cached-crates

rust-docs-mcp call list-crate-versions \
  --params '{"crate_name":"serde"}'

# Maintenance commands
rust-docs-mcp install           # Install to ~/.local/bin
rust-docs-mcp install --force   # Force overwrite existing installation
rust-docs-mcp doctor            # Verify system environment and dependencies
rust-docs-mcp doctor --json     # Output diagnostic results in JSON format
rust-docs-mcp update            # Update to latest version from GitHub
rust-docs-mcp --help            # Show help

Note: call cache-crate is blocking β€” it downloads the crate, generates documentation, and builds the search index before returning. This is different from MCP mode where cache_crate returns a task ID immediately and completes in the background. If a one-shot tool returns an error JSON response, the CLI prints that JSON to stdout and exits with status 1.

Available one-shot tools: cache-crate, search-items-fuzzy, search-items-preview, search-items, list-crate-items, get-item-details, get-item-docs, get-item-source, list-cached-crates, list-crate-versions, get-dependencies, structure.

Troubleshooting

If you encounter issues during installation or runtime, run the doctor command to diagnose common problems:

rust-docs-mcp doctor

The doctor command checks:

  • Rust toolchain availability (stable + nightly)
  • Git installation
  • Network connectivity to crates.io and GitHub
  • Cache directory permissions and disk space
  • Rustdoc JSON generation capability
  • Optional dependencies (e.g., codesign on macOS)

For programmatic integration, use --json flag to get structured output.

MCP Configuration

Add the server to your MCP configuration:

{
  "rust-docs": {
    "command": "/path/to/rust-docs-mcp/target/release/rust-docs-mcp",
    "transport": "stdio"
  }
}

Files in the repo

Repository payloadβ€’19 top-level entries
  • .claude
  • .github
  • .specstory
  • assets
  • cargo-modules
  • docs
  • patches
  • rust-docs-mcp
  • .gitignore
  • Cargo.lock
  • Cargo.toml
  • CLAUDE.md
  • flake.lock
  • flake.nix
  • install.sh
  • justfile
  • LICENSE
  • README.md
  • rust-toolchain.toml

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More connectors

Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified situational awareness interface

86k

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph β€” average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

43k

Universal provider proxy for OpenAI Codex & Claude Code β€” use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama…) with Codex CLI, App, SDK, and Claude Code

14k
okf-memory/
okf-agent-memory

Git-native persistent memory for AI coding agents. Implements Google OKF v0.2 with sub-300Β΅s in-memory BM25 search, embedded MCP server, and progressive disclosure. Slashes token bloat by 80% with zero external databases or dependencies. Built in pure Go.

547
tirth8205/
code-review-graph

Local-first code intelligence graph for MCP and CLI. Builds a persistent map of your codebase so AI coding tools read only what matters, with benchmarked context reductions on reviews and large-repo workflows.

31k
2akouwu/
reverify

Stop your AI from making things up β€” it proposes, deterministic tools decide, every claim checked against ground truth with evidence. Grounded facts and context survive resets. Reverse engineering is the proving ground. MCP server + CLI.

1.1k