Skip to content
Back to search

rust-docs-mcp

MCP server for agents to explore rust docs, analyze source code, and build with confidence

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/snowmead--rust-docs-mcp/badge.svg)](/listings/snowmead--rust-docs-mcp)

HTML

<a href="/listings/snowmead--rust-docs-mcp"><img src="/api/listings/snowmead--rust-docs-mcp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

These steps run a script from the network that findsafeskills does not scan.

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). A newer nightly is accepted only if its JSON format is compatible. You can override the choice with:

  export RUST_DOCS_MCP_TOOLCHAIN=nightly

This override selects the compiler for documentation and dependency metadata; it does not change the toolchain used to compile this executable. There is no automatic compiler switch after an MSRV or unstable-syntax failure. Such errors report the selected toolchain and the override needed to try a newer installed nightly. An incompatible JSON format still requires an application update. `rust-docs-mcp --version` reports the tested pin and configured override without compiling a probe. `rust-docs-mcp doctor` checks the actual selected compiler. Restart a running MCP server after changing the environment variable.

- Network access to download crates from [crates.io](https://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

# Blocking cache commands, with JSON results on stdout
rust-docs-mcp cache list
rust-docs-mcp cache add serde serde_json@1 chrono rand tokio
rust-docs-mcp cache add semver@1.0.0
rust-docs-mcp cache add leptos-use@0.15.8 --features axum
rust-docs-mcp cache update --all
rust-docs-mcp cache update serde tokio

# 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

`cache add` resolves an omitted version to the latest non-yanked stable release. A complete version such as `1.0.0` pins that version exactly; `1`, `1.2`, and quoted requirements such as `'serde@>=1,<2'` select the highest matching release. Prereleases require an explicit matching prerelease requirement.

`cache update` adds the latest stable crates.io release with the cached feature selections. It retains older versions, skips local/Git sources, and skips variants already present at the latest version. Both batch commands continue after an

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 374 lines · 3 findings marked

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. [![rust-docs banner](./assets/rust_docs_banner.jpeg)](https://github.com/snowmead/rust-docs-mcp)
  2. # Rustdocs MCP Server
  3. [![Crates.io](https://img.shields.io/crates/v/rust-docs-mcp.svg)](https://crates.io/crates/rust-docs-mcp)
  4. [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
  5. [![Discord](https://img.shields.io/badge/Discord-Join%20Server-7289DA?logo=discord&logoColor=white)](https://discord.gg/ak2yTNN7)
  6. [![Build Status](https://github.com/snowmead/rust-docs-mcp/workflows/Rust/badge.svg)](https://github.com/snowmead/rust-docs-mcp/actions)
  7. [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/snowmead/rust-docs-mcp)
  8. _Rust is the language of AI_
  9. An MCP (Model Context Protocol) server that provides comprehensive access to
  10. Rust crate documentation, source code analysis, dependency trees, and module
  11. structure visualization. Built for agents to gain quality insights into Rust
  12. projects and build with confidence.
  13. ## Warning
  14. 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.
  15. ## The Problem: Agents Building in the Dark
  16. The rise of AI agents has revolutionized software development, with new tools
  17. and libraries emerging at an unprecedented pace. However, this rapid evolution
  18. creates a critical challenge: **agents cannot reliably build with tools they
  19. weren't trained on**.
  20. When an agent tries to use a new Rust crate:
  21. - 🚫 **Training data is outdated** — The model hasn't seen recent crates or API
  22. changes
  23. - 🚫 **Documentation scraping is inefficient** — Web scraping GitHub or docs.rs
  24. is slow and unreliable
  25. - 🚫 **Examples aren't enough** — Copy-pasting README examples provides
  26. surface-level understanding
  27. - 🚫 **Internal structure is opaque** — Agents can't explore how modules,
  28. traits, and types interconnect
  29. This leads to frustrated developers watching their agents fail repeatedly,
  30. guessing at APIs, and producing broken code.
  31. ## The Solution: Deep Crate Intelligence
  32. This MCP server gives agents the tools they need to **truly understand** Rust
  33. crates:
  34. - 🔍 **Explore internal structure** — Navigate module hierarchies and type
  35. relationships
  36. - 📖 **Access complete documentation** — Full rustdoc with signatures, fields,
  37. and methods
  38. - 🔗 **Trace dependencies** — Understand what a crate depends on and why
  39. - 💾 **Work offline** — Cache crates locally for instant, reliable access
  40. - 🎯 **Query precisely** — Search by pattern, kind, or path to find exactly
  41. what's needed
  42. With these capabilities, agents can build confidently with any Rust crate — even
  43. ones released yesterday.
  44. ## Agent Capabilities
  45. - [x] **Multi-source caching** — crates.io, GitHub repositories, local
  46. filesystem paths
  47. - [x] **Workspace support** — Individual member analysis and caching for cargo
  48. workspaces
  49. - [x] **Documentation search** — Pattern matching with kind/path filtering and
  50. preview modes
  51. - [x] **Item inspection** — Detailed signatures, fields, methods, and
  52. documentation strings
  53. - [x] **Source code access** — Line-level precision with parameterized
  54. surrounding context
  55. - [x] **Dependency analysis** — Direct and transitive dependency trees with
  56. metadata
  57. - [x] **Module structure** — Hierarchical tree generation via cargo-modules
  58. integration
  59. - [x] **Offline operation** — Full functionality after initial crate caching
  60. - [x] **Token management** — Response truncation and preview modes for LLM
  61. compatibility
  62. ## MCP Tools
  63. ### Cache Management
  64. - `cache_crate` - Download and cache a crate from various sources. Set
  65. `source_type` to one of: `cratesio`, `github`, or `local`
  66. - **For cratesio**: Provide `version` (e.g., `{crate_name: "serde", source_type: "cratesio", version: "1.0.215"}`)
  67. - **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"}`)
  68. - **For local**: Provide `path`, optional `version` (e.g., `{crate_name: "my-crate", source_type: "local", path: "~/projects/my-crate"}`)
  69. - **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"]}`)
  70. - `remove_crate` - Remove cached crate versions to free disk space
  71. - `list_cached_crates` - View all cached crates with versions and sizes
  72. - `list_crate_versions` - List cached versions for a specific crate
  73. - `get_crates_metadata` - Batch metadata queries for multiple crates
  74. - `cache_operations` - Manage and monitor background caching operations (list, status, cancel, clear)
  75. Crates.io downloads require an exact version, such as `9.3.1`. If a version is
  76. rejected, the error lists available non-yanked releases in descending semver
  77. order. Choose one and retry. Partial versions such as `9` and `9.3` never select
  78. a release automatically. Cached GitHub and local source versions keep their
  79. original identifiers.
  80. ### Documentation Queries
  81. - `list_crate_items` - Browse all items in a crate with optional filtering
  82. - `search_items` - Full search with complete documentation (may hit token
  83. limits)
  84. - `search_items_preview` - Lightweight search returning only IDs, names, and
  85. types
  86. - `get_item_details` - Detailed information about specific items (signatures,
  87. fields, etc.)
  88. - `get_item_docs` - Extract just the documentation string for an item
  89. - `get_item_source` - View source code with configurable context lines
  90. ### Dependency Analysis
  91. - `get_dependencies` - Analyze direct and transitive dependencies with filtering
  92. ### Structure Analysis
  93. - `structure` - Generate hierarchical module tree using integrated cargo-modules
  94. ### Search
  95. - `search_items_fuzzy` - Fuzzy search with typo tolerance and semantic
  96. similarity
  97. ### Feature selection and re-exports
  98. Cache, documentation, search, and dependency tools accept the same three fields:
  99. | Request | Build behavior |
  100. | --- | --- |
  101. | All three fields omitted | Try all features, then Cargo defaults, then no defaults |
  102. | `features: ["axum"]` | Enable only `axum`, without defaults or fallback |
  103. | `features: ["axum"], no_default_features: false` | Add `axum` to Cargo defaults |
  104. | `features: []` or `no_default_features: true` | Disable default features |
  105. | `no_default_features: false` or `all_features: false` | Use Cargo defaults only |
  106. | `all_features: true` | Enable every feature, without fallback |
  107. `all_features: true` cannot be combined with a feature list or
  108. `no_default_features: true`. Explicit requests never fall back to another set.
  109. Feature selections are separate cache variants. Names are sorted and deduplicated
  110. before computing the cache key. A query must supply the same feature options as
  111. the cache request to use that variant. Omitted options select the automatic
  112. fallback variant, regardless of which variant was cached last. Queries generate
  113. missing variants from the cached source. Item IDs belong to a variant; pass its
  114. feature options when requesting an item's docs, details, or source.
  115. ```json
  116. {"crate_name":"leptos-use","version":"0.15.8","features":["axum"],"pattern":"use_"}
  117. ```
  118. Use this request with `search_items_preview` to search a selected feature set.
  119. `list_cached_crates` and `list_crate_versions` report each variant's requested
  120. features, effective features, and toolchain. Dependency metadata uses the same
  121. successful feature selection as the docs, including automatic fallback.
  122. Search and listing include public `use` declarations and renamed imports.
  123. `get_item_details` returns the import signature and a `reexport` object containing
  124. its source, target path, target crate, and target ID when rustdoc provides them.
  125. For `pub use graphql_client`, search for `graphql_client` in the wrapper crate.
  126. To find `GraphQLQuery` inside that dependency, use `get_dependencies` to resolve
  127. its package/version, then query that crate explicitly. Searching a wrapper does
  128. not download or recursively search its dependencies. External target IDs refer
  129. to the wrapper's rustdoc data; search the target crate for its own item IDs.
  130. ## Configuration
  131. ### Cache Directory
  132. By default, crates are cached in `~/.rust-docs-mcp/cache/`. You can customize
  133. this location using:
  134. ```bash
  135. # Command line option
  136. rust-docs-mcp --cache-dir /custom/path/to/cache
  137. # or set the environment variable
  138. export RUST_DOCS_MCP_CACHE_DIR=/custom/path/to/cache
  139. rust-docs-mcp
  140. ```
  141. ### GitHub Authentication
  142. To access private repositories or increase GitHub API rate limits, set the
  143. `GITHUB_TOKEN` environment variable:
  144. ```bash
  145. export GITHUB_TOKEN=your_github_personal_access_token
  146. ```
  147. Benefits of authentication:
  148. - **Access private repositories** — Cache and analyze private Rust crates
  149. - **Higher rate limits** — 5,000 requests/hour (vs 60 unauthenticated)
  150. - **Avoid rate limit errors** — Essential for caching multiple GitHub-hosted
  151. crates
  152. ### Each crate version stores
  153. - Complete source code in `source/` directory
  154. - Cache metadata and timestamps in `metadata.json`
  155. - `variants/{fingerprint}/` contains `docs.json`, `dependencies.json`,
  156. `search_index/`, and `build.json` for each completed feature selection.
  157. - Workspace members use `members/{member-name}/variants/{fingerprint}/`.
  158. Their source and member metadata remain shared.
  159. Documentation from older releases has no recorded feature selection. It remains
  160. on disk but is regenerated on the first query, using the existing source. A
  161. failed build leaves completed variants intact. `cache_crate` with `update: true`
  162. refreshes the source and invalidates all variants of that crate/version on
  163. success; `remove_crate` removes the source and all its variants.
  164. ## Installation
  165. ### Quick Install
  166. ```bash
  167. curl -sSL https://raw.githubusercontent.com/snowmead/rust-docs-mcp/main/install.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 219 on GitHub
  168. ```
  169. ### Installation Options
  170. #### One-liner (Recommended)
  171. ```bash
  172. curl -sSL https://raw.githubusercontent.com/snowmead/rust-docs-mcp/main/install.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 227 on GitHub
  173. ```
  174. #### Custom install directory
  175. ```bash
  176. curl -sSL https://raw.githubusercontent.com/snowmead/rust-docs-mcp/main/install.sh | bash -s -- --install-dir /usr/local/bin
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 233 on GitHub
  177. ```
  178. #### Cargo Install
  179. ```bash
  180. cargo install rust-docs-mcp
  181. ```
  182. #### Building from Source
  183. ##### Requirements
  184. - Rust nightly toolchain (for Rustdoc JSON generation)
  185. ```bash
  186. rustup toolchain install nightly-2026-05-22
  187. ```
  188. Runtime prefers `nightly-2026-05-22`, which provides rustc
  189. `1.97.0-nightly (e96c36b6f 2026-05-21)`, so documentation generation can
  190. compile modern crates. The `rustdoc-types` dependency is kept in sync with
  191. that rustdoc JSON format. If the dated toolchain is missing, the runtime
  192. falls back to plain `nightly`, but only when it emits the same rustdoc JSON
  193. format version (57). A newer nightly is accepted only if its JSON format is compatible. You can override the
  194. choice with:
  195. ```bash
  196. export RUST_DOCS_MCP_TOOLCHAIN=nightly
  197. ```
  198. This override selects the compiler for documentation and dependency metadata;
  199. it does not change the toolchain used to compile this executable. There is no
  200. automatic compiler switch after an MSRV or unstable-syntax failure. Such errors
  201. report the selected toolchain and the override needed to try a newer installed
  202. nightly. An incompatible JSON format still requires an application update.
  203. `rust-docs-mcp --version` reports the tested pin and configured override without
  204. compiling a probe. `rust-docs-mcp doctor` checks the actual selected compiler.
  205. Restart a running MCP server after changing the environment variable.
  206. - Network access to download crates from [crates.io](https://crates.io)
  207. ```bash
  208. git clone https://github.com/snowmead/rust-docs-mcp
  209. cd rust-docs-mcp/rust-docs-mcp
  210. cargo build --release
  211. ./target/release/rust-docs-mcp install
  212. ```
  213. ### CLI Commands
  214. ```bash
  215. rust-docs-mcp # Start MCP server (same as `serve`)
  216. rust-docs-mcp serve # Start MCP server explicitly
  217. # Blocking cache commands, with JSON results on stdout
  218. rust-docs-mcp cache list
  219. rust-docs-mcp cache add serde serde_json@1 chrono rand tokio
  220. rust-docs-mcp cache add semver@1.0.0
  221. rust-docs-mcp cache add leptos-use@0.15.8 --features axum
  222. rust-docs-mcp cache update --all
  223. rust-docs-mcp cache update serde tokio
  224. # One-shot operations (stateless – print JSON to stdout and exit)
  225. rust-docs-mcp call cache-crate \
  226. --params '{"crate_name":"serde","source_type":"cratesio","version":"1.0.215"}'
  227. rust-docs-mcp call search-items-fuzzy \
  228. --params '{"crate_name":"serde","version":"1.0.215","query":"Deserialize","limit":10}'
  229. rust-docs-mcp call list-cached-crates
  230. rust-docs-mcp call list-crate-versions \
  231. --params '{"crate_name":"serde"}'
  232. # Maintenance commands
  233. rust-docs-mcp install # Install to ~/.local/bin
  234. rust-docs-mcp install --force # Force overwrite existing installation
  235. rust-docs-mcp doctor # Verify system environment and dependencies
  236. rust-docs-mcp doctor --json # Output diagnostic results in JSON format
  237. rust-docs-mcp update # Update to latest version from GitHub
  238. rust-docs-mcp --help # Show help
  239. ```
  240. `cache add` resolves an omitted version to the latest non-yanked stable release.
  241. A complete version such as `1.0.0` pins that version exactly; `1`, `1.2`, and
  242. quoted requirements such as `'serde@>=1,<2'` select the highest matching release.
  243. Prereleases require an explicit matching prerelease requirement.
  244. `cache update` adds the latest stable crates.io release with the cached feature
  245. selections. It retains older versions, skips local/Git sources, and skips variants
  246. already present at the latest version. Both batch commands continue after an
  247. individual failure, print every result in a JSON `results` array, and exit with
  248. status 1 if any crate failed. Progress goes to stderr. `cache list` needs no network.
  249. `--cache-dir` works before or after the subcommand.
  250. > **Note:** `call cache-crate` is **blocking** — it downloads the crate,
  251. > generates documentation, and builds the search index before returning.
  252. > This is different from MCP mode where `cache_crate` returns a task ID
  253. > immediately and completes in the background. If a one-shot tool returns
  254. > an error JSON response, the CLI prints that JSON to stdout and exits with
  255. > status 1.
  256. >
  257. > Available one-shot tools: `cache-crate`, `search-items-fuzzy`,
  258. > `search-items-preview`, `search-items`, `list-crate-items`,
  259. > `get-item-details`, `get-item-docs`, `get-item-source`,
  260. > `list-cached-crates`, `list-crate-versions`, `get-dependencies`,
  261. > `structure`.
  262. ### Troubleshooting
  263. If you encounter issues during installation or runtime, run the doctor command
  264. to diagnose common problems:
  265. ```bash
  266. rust-docs-mcp doctor
  267. ```
  268. The doctor command checks:
  269. - Rust toolchain availability (stable + nightly)
  270. - Git installation
  271. - Network connectivity to crates.io and GitHub
  272. - Cache directory permissions and disk space
  273. - Rustdoc JSON generation capability
  274. - Optional dependencies (e.g., codesign on macOS)
  275. For programmatic integration, use `--json` flag to get structured output.
  276. ### MCP Configuration
  277. Add the server to your MCP configuration:
  278. ```json
  279. {
  280. "rust-docs": {
  281. "command": "/path/to/rust-docs-mcp/target/release/rust-docs-mcp",
  282. "transport": "stdio"
  283. }
  284. }
  285. ```

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.