Rust Docs MCP Server
About
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.
Details
- Author
- govcraft
- Repository
- Govcraft/rust-docs-mcp-server
- GitHub stars
- 45
- Downloads
- 794
- License
- MIT License
- Categories
- Developer Tools, Knowledge Base, Other, AI, Workplace, File Management
- Tags
- #mobile
Jump to
- Targeted Documentation: Focuses on a single Rust crate per server
instance.
- Feature Support: Allows specifying required crate features for
documentation generation.
- Semantic Search: Uses OpenAI's text-embedding-3-small model to find the
most relevant documentation sections for a given question.
- LLM Summarization: Leverages OpenAI's gpt-4o-mini-2024-07-18 model to
generate concise answers based _only_ on the retrieved documentation context.
- Caching: Caches generated documentation content and embeddings in the
user's XDG data directory (~/.local/share/rustdocs-mcp-server/ or similar)
based on crate, version, _and_ requested features to speed up subsequent
launches.
- MCP Integration: Runs as a standard MCP server over stdio, exposing tools
and resources.
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
Rust Docs MCP ServerCommand (node, npx, python, etc.)/path/to/your/rustdocs_mcp_serverArguments-
Argument 1
reqwest@0.12
Environment-
OPENAI_API_KEY
YOUR_OPENAI_API_KEY_HERE
Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
-
Argument 1
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Example Client Configuration Claude Desktop
For Claude Desktop users, you can configure the server in the MCP settings. Here's an example configuring servers forserdeandasync-stripe:
{ "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": [ "async-stripe@0.40", "-F", "runtime-tokio-hyper-rustls" ] } } }
- Ensurerustdocs_mcp_serveris in your system's PATH or provide the full path (e.g.,/path/to/your/rustdocs_mcp_server).
- The keys (rust-docs-serde,rust-docs-async-stripe-rt) are arbitrary names you choose to identify the server instances.
- Remember to set theOPENAI_API_KEYenvironment variable where Claude Desktop can access it (this might be system-wide or via how you launch Claude Desktop). Claude Desktop's MCP configuration might not directly support setting environment variables per-server like Roo Code.
- The example shows how to add the-Fargument for crates likeasync-stripethat require specific features.
- Location:Cached documentation and embeddings are stored in the XDG data directory, typically under~/.local/share/rustdocs-mcp-server/<crate_name>/<sanitized_version_req>/<features_hash>/embeddings.bin. Thesanitized_version_reqis derived from the version requirement, andfeatures_hashis a hash representing the specific combination of features requested at startup. This ensures different feature sets are cached separately.
- Format:Data is cached usingbincodeserialization.
- Regeneration:If the cache file is missing, corrupted, or cannot be decoded, the server will automatically regenerate the documentation and embeddings.
- Initialization:Parses the crate specification and optional features from the command line usingclap.
- Cache Check:Looks for a pre-existing cache file for the specific crate, version requirement, and feature set.
- Documentation Generation (if cache miss):
- Creates a temporary Rust project depending only on the target crate, enabling the specified features in itsCargo.toml.
- Runscargo docusing thecargolibrary API to generate HTML documentation in the temporary directory.
- Dynamically locates the correct output directory withintarget/docby searching for the subdirectory containingindex.html.
- Walks the generated HTML files within the located documentation directory.
- Uses thescrapercrate to parse each HTML file and extract text content from the main content area (<section id="main-content">).
- Uses theasync-openaicrate andtiktoken-rsto generate embeddings for each extracted document chunk using thetext-embedding-3-smallmodel.
- Calculates the estimated cost based on the number of tokens processed.
- Generates an embedding for the user's question.
- Calculates the cosine similarity between the question embedding and all cached document embeddings.
- Identifies the document chunk with the highest similarity.
- Sends the user's question and the content of the best-matching document chunk to thegpt-4o-mini-2024-07-18model via the OpenAI API.
- The LLM is prompted to answer the question basedonlyon the provided context.
- Returns the LLM's response to the MCP client.
This project is licensed under the MIT License.
Govcraft is a one-person shop—no corporate backing, no investors, just me building useful tools. If this project helps you,sponsoringkeeps the work going.
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
One shared context layer for AI agents and humans — live API specs, DB schemas, and versioned contracts across repos so every agent and teammate works from the same source of truth.
Local stdio MCP server that lets AI coding agents read and maintain structured architecture, rules, and decisions directly from your repository.
Official Context7 MCP server that brings up-to-date, version-specific library documentation and code examples into AI coding prompts.
Remote, no-auth MCP server providing AI-powered codebase context and answers
Create and read feature flags, review experiments, generate flag types, search docs, and interact with GrowthBook's feature flagging and experimentation platform.
Official MCP server for Stimulsoft Reports & Dashboards documentation. Semantic search across FAQ, Programming Manual, Server/User Manual, and Server/Cloud API for .NET, WPF, Avalonia, WEB, Blazor, Angular, React, JS, PHP, Java, and Python platforms.
Search Apple's Developer Documentation with smart search and wildcard support.
Access documentation from the Awesome-llms-txt repository directly in your conversations.
Connect AI tools like Cursor and VS Code to your product documentation using the Biel.ai platform.
MCP server that ingests project docs once and lets Claude search by meaning instead of reading everything — saving tokens on large codebases
query_rust_docs
Query documentation for the specific Rust crate the server was started for, using semantic search and LLM summarization. Input requires a question about the crate's API or usage.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"rust docs mcp server": {
"env": {
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE"
},
"args": [
"reqwest@0.12"
],
"command": "/path/to/your/rustdocs_mcp_server"
}
}
}
Linux
{
"env": {
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE"
},
"args": [
"reqwest@0.12"
],
"command": "/path/to/your/rustdocs_mcp_server"
}
Macos
{
"env": {
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE"
},
"args": [
"reqwest@0.12"
],
"command": "/path/to/your/rustdocs_mcp_server"
}
Windows
{
"env": {
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE"
},
"args": [
"reqwest@0.12"
],
"command": "/path/to/your/rustdocs_mcp_server"
}
⭐Like this project? Pleasestar the repositoryon GitHub to show your support and stay updated!⭐
Modern AI-powered coding assistants (like Cursor, Cline, Roo Code, etc.) excel at understanding code structure and syntax but often struggle with the specifics of rapidly evolving libraries and frameworks, especially in ecosystems like Rust where crates are updated frequently. Their training data cutoff means they may lack knowledge of the latest APIs, leading to incorrect or outdated code suggestions.
This MCP server addresses this challenge by providing a focused, up-to-date knowledge source for a specific Rust crate. By running an instance of this server for a crate (e.g.,serde,tokio,reqwest), you give your LLM coding assistant a tool (query_rust_docs) it can usebeforewriting code related to that crate.
When instructed to use this tool, the LLM can ask specific questions about the crate's API or usage and receive answers derived directly from thecurrentdocumentation. This significantly improves the accuracy and relevance of the generated code, reducing the need for manual correction and speeding up development.
Multiple instances of this server can be run concurrently, allowing the LLM assistant to access documentation for several different crates during a coding session.
This server fetches the documentation for a specified Rust crate, generates embeddings for the content, and provides an MCP tool to answer questions about the crate based on the documentation context.
- Targeted Documentation:Focuses on a single Rust crate per server instance.
- Feature Support:Allows specifying required crate features for documentation generation.
- Semantic Search:Uses OpenAI'stext-embedding-3-smallmodel to find the most relevant documentation sections for a given question.
- LLM Summarization:Leverages OpenAI'sgpt-4o-mini-2024-07-18model to generate concise answers basedonlyon the retrieved documentation context.
- Caching:Caches generated documentation content and embeddings in the user's XDG data directory (~/.local/share/rustdocs-mcp-server/or similar) based on crate, version,andrequested features to speed up subsequent launches.
- MCP Integration:Runs as a standard MCP server over stdio, exposing tools and resources.
- OpenAI API Key:Needed for generating embeddings and summarizing answers. The server expects this key to be available in theOPENAI_API_KEYenvironment variable. (The server also requires network access to download crate dependencies and interact with the OpenAI API).
The recommended way to install is to download the pre-compiled binary for your operating system from theGitHub Releases page.
- Go to theReleases page.
- Download the appropriate archive (.zipfor Windows,.tar.gzfor Linux/macOS) for your system.
- Extract therustdocs_mcp_server(orrustdocs_mcp_server.exe) binary.
- Place the binary in a directory included in your system'sPATHenvironment variable (e.g.,/usr/local/bin,~/bin).
If you prefer to build from source, you will need theRust Toolchaininstalled.
- Clone the repository:
git clone https://github.com/Govcraft/rust-docs-mcp-server.git cd rust-docs-mcp-server
When using the server with a crate for the first time (or with a new version/feature set), it needs to download the documentation and generate embeddings. This process can take some time, especially for crates with extensive documentation, and requires an active internet connection and OpenAI API key.
It is recommended to run the server once directly from your command line for any new crate configurationbeforeadding it to your AI coding assistant (like Roo Code, Cursor, etc.). This allows the initial embedding generation and caching to complete. Once you see the server startup messages indicating it's ready (e.g., "MCP Server listening on stdio"), you can shut it down (Ctrl+C). Subsequent launches, including those initiated by your coding assistant, will use the cached data and start much faster.
The server is launched from the command line and requires thePackage ID Specificationfor the target crate. This specification follows the format used by Cargo (e.g.,crate_name,crate_name@version_req). For the full specification details, seeman cargo-pkgidor theCargo documentation.
Optionally, you can specify required crate features using the-For--featuresflag, followed by a comma-separated list of features. This is necessary for crates that require specific features to be enabled forcargo docto succeed (e.g., crates requiring a runtime feature likeasync-stripe).
# Set the API key (replace with your actual key) export OPENAI_API_KEY="sk-..." # Example: Run server for the latest 1.x version of serde rustdocs_mcp_server "serde@^1.0" # Example: Run server for a specific version of reqwest rustdocs_mcp_server "reqwest@0.12.0" # Example: Run server for the latest version of tokio rustdocs_mcp_server tokio # Example: Run server for async-stripe, enabling a required runtime feature rustdocs_mcp_server "async-stripe@0.40" -F runtime-tokio-hyper-rustls # Example: Run server for another crate with multiple features rustdocs_mcp_server "some-crate@1.2" --features feat1,feat2
On the first run for a specific crate versionand feature set, the server will:
- Download the crate documentation usingcargo doc(with specified features).
- Parse the HTML documentation.
- Generate embeddings for the documentation content using the OpenAI API (this may take some time and incur costs, though typically only fractions of a US penny for most crates; even a large crate likeasync-stripewith over 5000 documentation pages cost only $0.18 USD for embedding generation during testing).
- Cache the documentation content and embeddings so that the cost isn't incurred again.
- Start the MCP server.
Subsequent runs for the same crate versionand feature setwill load the data from the cache, making startup much faster.
The server communicates using the Model Context Protocol over standard input/output (stdio). It exposes the following:
- Description:Query documentation for the specific Rust crate the server was started for, 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"] }
{ "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 }
- Description:Provides the name of the Rust crate this server instance is configured for.
- URI:crate://<crate_name>(e.g.,crate://serde,crate://reqwest)
- Content:Plain text containing the crate name.
Logging:The server sends informational logs (startup messages, query processing steps) back to the MCP client vialogging/messagenotifications.
You can configure MCP clients like Roo Code to run multiple instances of this server, each targeting a different crate. Here's an example snippet for Roo Code'smcp_settings.jsonfile, configuring servers forreqwestandasync-stripe(note the added features argument forasync-stripe):
{ "mcpServers": { "rust-docs-reqwest": { "command": "/path/to/your/rustdocs_mcp_server", "args": [ "reqwest@0.12" ], "env": { "OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE" }, "disabled": false, "alwaysAllow": [] }, "rust-docs-async-stripe": { "command": "rustdocs_mcp_server", "args": [ "async-stripe@0.40", "-F", " runtime-tokio-hyper-rustls" ], "env": { "OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE" }, "disabled": false, "alwaysAllow": [] } } }
- Replace/path/to/your/rustdocs_mcp_serverwith the actual path to the compiled binary on your system if it isn't in your PATH.
- ReplaceYOUR_OPENAI_API_KEY_HEREwith your actual OpenAI API key.
- The keys (rust-docs-reqwest,rust-docs-async-stripe) are arbitrary names you choose to identify the server instances within Roo Code.
Example Client Configuration (Claude Desktop)
For Claude Desktop users, you can configure the server in the MCP settings. Here's an example configuring servers forserdeandasync-stripe:
{ "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": [ "async-stripe@0.40", "-F", "runtime-tokio-hyper-rustls" ] } } }
- Ensurerustdocs_mcp_serveris in your system's PATH or provide the full path (e.g.,/path/to/your/rustdocs_mcp_server).
- The keys (rust-docs-serde,rust-docs-async-stripe-rt) are arbitrary names you choose to identify the server instances.
- Remember to set theOPENAI_API_KEYenvironment variable where Claude Desktop can access it (this might be system-wide or via how you launch Claude Desktop). Claude Desktop's MCP configuration might not directly support setting environment variables per-server like Roo Code.
- The example shows how to add the-Fargument for crates likeasync-stripethat require specific features.
- Location:Cached documentation and embeddings are stored in the XDG data directory, typically under~/.local/share/rustdocs-mcp-server/<crate_name>/<sanitized_version_req>/<features_hash>/embeddings.bin. Thesanitized_version_reqis derived from the version requirement, andfeatures_hashis a hash representing the specific combination of features requested at startup. This ensures different feature sets are cached separately.
- Format:Data is cached usingbincodeserialization.
- Regeneration:If the cache file is missing, corrupted, or cannot be decoded, the server will automatically regenerate the documentation and embeddings.
- Initialization:Parses the crate specification and optional features from the command line usingclap.
- Cache Check:Looks for a pre-existing cache file for the specific crate, version requirement, and feature set.
- Documentation Generation (if cache miss):
- Creates a temporary Rust project depending only on the target crate, enabling the specified features in itsCargo.toml.
- Runscargo docusing thecargolibrary API to generate HTML documentation in the temporary directory.
- Dynamically locates the correct output directory withintarget/docby searching for the subdirectory containingindex.html.
- Walks the generated HTML files within the located documentation directory.
- Uses thescrapercrate to parse each HTML file and extract text content from the main content area (<section id="main-content">).
- Uses theasync-openaicrate andtiktoken-rsto generate embeddings for each extracted document chunk using thetext-embedding-3-smallmodel.
- Calculates the estimated cost based on the number of tokens processed.
- Generates an embedding for the user's question.
- Calculates the cosine similarity between the question embedding and all cached document embeddings.
- Identifies the document chunk with the highest similarity.
- Sends the user's question and the content of the best-matching document chunk to thegpt-4o-mini-2024-07-18model via the OpenAI API.
- The LLM is prompted to answer the question basedonlyon the provided context.
- Returns the LLM's response to the MCP client.
This project is licensed under the MIT License.
Govcraft is a one-person shop—no corporate backing, no investors, just me building useful tools. If this project helps you,sponsoringkeeps the work going.
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
One shared context layer for AI agents and humans — live API specs, DB schemas, and versioned contracts across repos so every agent and teammate works from the same source of truth.
Local stdio MCP server that lets AI coding agents read and maintain structured architecture, rules, and decisions directly from your repository.
Official Context7 MCP server that brings up-to-date, version-specific library documentation and code examples into AI coding prompts.
Remote, no-auth MCP server providing AI-powered codebase context and answers
Create and read feature flags, review experiments, generate flag types, search docs, and interact with GrowthBook's feature flagging and experimentation platform.
Official MCP server for Stimulsoft Reports & Dashboards documentation. Semantic search across FAQ, Programming Manual, Server/User Manual, and Server/Cloud API for .NET, WPF, Avalonia, WEB, Blazor, Angular, React, JS, PHP, Java, and Python platforms.
Search Apple's Developer Documentation with smart search and wildcard support.
Access documentation from the Awesome-llms-txt repository directly in your conversations.
Connect AI tools like Cursor and VS Code to your product documentation using the Biel.ai platform.
MCP server that ingests project docs once and lets Claude search by meaning instead of reading everything — saving tokens on large codebases
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





