rust-cargo-docs-rag-mcp is an MCP (Model Context Protocol) server that provides Rust crate documentation lookup and search tools intended for LLM assistants and other tooling.
This README focuses on how to build, version, release, and install the project using two common paths:
- pkgx (build/install locally from source)
- Docker image (published to GitHub Container Registry — GHCR)
This repository is wired to Cocogitto via cog.toml. Typical flow to create a release:
-
Install Cocogitto (once)
cargo install cocogitto
-
Bump the version / create the tag from main (on your machine):
git checkout main git pull origin main cog bump patch # or `cog bump minor` / `cog bump major`cog bumpruns the pre_bump_hooks/post_bump_hooks defined incog.toml.- This will update Cargo.toml, Cargo.lock and CHANGELOG.md, and create a signed tag
vX.Y.Z.
-
Push commit + tag to GitHub:
git push --follow-tags origin main
When the tag is pushed, the Release & Publish (GHCR) workflow will run:
- It builds multi-arch (amd64/arm64) Docker images with Docker Buildx and pushes them to GHCR at:
- ghcr.io/<org_or_user>/rust-cargo-docs-rag-mcp:
- ghcr.io/<org_or_user>/rust-cargo-docs-rag-mcp:latest
- It creates a GitHub Release for that tag and uploads the release binary (target/release/cratedocs) as an asset.
Repository requirements:
- Ensure GitHub Actions has permission to publish packages (Packages / Container registry). The release workflow uses the repository's GITHUB_TOKEN and sets packages: write in workflow permissions.
- Ensure
mainis the branch you wantcogto operate from (cog.toml has branch_whitelist = ["main"] by default).
Prebuilt images are published to GitHub Container Registry (GHCR) on release tags.
Pull the image (replace OWNER with the GH org or username that owns the repo; tags look like v0.3.0):
docker pull ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:latest
# or a specific version:
docker pull ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:v0.3.0Run the container in HTTP mode (default):
docker run --rm -p 8080:8080 ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:latestRun in stdio mode:
docker run --rm -e CRATEDOCS_MODE=stdio -i ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:latestCRATEDOCS_MODE(default:http) — set tostdioto run the stdio MCP serverCRATEDOCS_ADDRESS(default:0.0.0.0:8080) — bind address for HTTP modeCRATEDOCS_DEBUG(default:false) — set totrueto enable debug logging
You can also pass custom arguments directly to the cratedocs binary:
docker run --rm -p 3000:3000 ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:latest \
http --address 0.0.0.0:3000 --debugpkgx is a universal package manager that can build and run this project without requiring a system-wide Rust installation:
# Install using pkgx (automatically handles Rust dependencies)
pkgx install
# Or build directly with pkgx
pkgx +rust +cargo cargo build --release
# Run without installing
pkgx +rust +cargo cargo run --bin cratedocs -- stdioThe project includes a package.yml file for pkgx integration, making it easy to build and test across different environments.
git clone https://github.com/promptexecution/rust-cargo-docs-rag-mcp.git
cd rust-cargo-docs-rag-mcp
cargo build --release
cargo install --path .After installation, you can run:
# STDIN/STDOUT mode
cratedocs stdio
# HTTP/SSE mode
cratedocs http --address 127.0.0.1:8080
# With debug logging
cratedocs http --address 127.0.0.1:8080 --debug- Lookup crate documentation: Get general documentation for a Rust crate
- Search crates: Search for crates on crates.io based on keywords
- Lookup item documentation: Get documentation for a specific item (e.g., struct, function, trait) within a crate
- List crate items: Enumerate all items in a crate with optional filtering
The server provides the following tools via the MCP protocol:
Retrieves documentation for a specified Rust crate.
Parameters:
crate_name(required): The name of the crate to look upversion(optional): The version of the crate (defaults to latest)
Example:
{
"name": "lookup_crate",
"arguments": {
"crate_name": "tokio",
"version": "1.28.0"
}
}Searches for Rust crates on crates.io.
Parameters:
query(required): The search querylimit(optional): Maximum number of results to return (defaults to 10, max 100)
Example:
{
"name": "search_crates",
"arguments": {
"query": "async runtime",
"limit": 5
}
}Retrieves documentation for a specific item in a crate.
Parameters:
crate_name(required): The name of the crateitem_path(required): Path to the item (e.g., 'std::vec::Vec')version(optional): The version of the crate (defaults to latest)
Example:
{
"name": "lookup_item",
"arguments": {
"crate_name": "serde",
"item_path": "serde::Deserialize",
"version": "1.0.160"
}
}Enumerates all items in a specified Rust crate and version, optionally filtering by item type, visibility, or module path.
Parameters:
crate_name(required): The name of the crateversion(required): The version of the crateitem_type(optional): Filter by item type (struct, enum, trait, fn, macro, mod)visibility(optional): Filter by visibility (pub, private)module(optional): Filter by module path (e.g., serde::de)
Example:
{
"name": "list_crate_items",
"arguments": {
"crate_name": "serde",
"version": "1.0.0",
"item_type": "struct"
}
}You can directly test the documentation tools from the command line without starting a server:
# Get help for the test command
cargo run --bin cratedocs test --tool help
# Enumerate crate items
cargo run --bin cratedocs test --tool list_crate_items --crate-name serde --version 1.0.0 --item-type struct
# Look up crate documentation
cargo run --bin cratedocs test --tool lookup_crate --crate-name tokio
# Look up item documentation
cargo run --bin cratedocs test --tool lookup_item --crate-name tokio --item-path sync::mpsc::Sender
# Search for crates
cargo run --bin cratedocs test --tool search_crates --query logger --limit 5
# Output in different formats (markdown, text, json)
cargo run --bin cratedocs test --tool search_crates --query logger --format json
# Summarize output (strip LICENSE and VERSION sections, limit tokens)
cargo run --bin cratedocs test --tool lookup_crate --crate-name tokio --tldr --max_tokens 48000This server implements the Model Context Protocol (MCP) which allows it to be easily integrated with LLM clients that support the protocol. For more information about MCP, visit the MCP repository.
# compile & install cratedocs in ~/.cargo/bin
cargo install --path . in mcp_settings.json:
{
"mcpServers":{
"rust-crate-local": {
"command": "cratedocs",
"args": [
"stdio"
]
}
}
}{
"mcpServers":{
"rust-crate-docs": {
"command": "bunx",
"args": [
"-y",
"mcp-remote@latest",
"http://127.0.0.1:3000/sse?sessionId=",
"--allow-http",
"--transport sse-only",
"--debug"
]
}
}
}You can use the Docker image directly in your MCP configuration:
{
"mcpServers": {
"rust-crate-docs-docker": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:latest",
"stdio"
]
}
}
}Or if you want to run the HTTP/SSE server in Docker and connect via mcp-remote:
# Start the HTTP server in Docker
docker run --rm -p 8080:8080 ghcr.io/promptexecution/rust-cargo-docs-rag-mcp:latestThen in mcp_settings.json:
{
"mcpServers": {
"rust-crate-docs-docker-http": {
"command": "bunx",
"args": [
"-y",
"mcp-remote@latest",
"http://localhost:8080/sse",
"--allow-http",
"--transport", "sse-only"
]
}
}
}If you have pkgx installed, you can run the server without a system-wide Rust installation:
{
"mcpServers": {
"rust-crate-docs-pkgx": {
"command": "pkgx",
"args": [
"+rust",
"+cargo",
"cargo",
"run",
"--manifest-path",
"/path/to/rust-cargo-docs-rag-mcp/Cargo.toml",
"--bin",
"cratedocs",
"--",
"stdio"
]
}
}
}Or use pkgx to install and run directly:
# Clone and install with pkgx
git clone https://github.com/promptexecution/rust-cargo-docs-rag-mcp.git
cd rust-cargo-docs-rag-mcp
pkgx +rust +cargo cargo install --path .Then reference it normally in mcp_settings.json:
{
"mcpServers": {
"rust-crate-docs": {
"command": "cratedocs",
"args": ["stdio"]
}
}
}- The server includes a caching mechanism to prevent redundant API calls for the same documentation
- It interfaces with docs.rs for crate documentation and crates.io for search functionality
- Results are returned as plain text/HTML content that can be parsed and presented by the client
MIT License
This fork builds on the original d6e/cratedocs-mcp work by:
- wiring the crate-documentation helpers into a full MCP server with both
stdioand HTTP/SSE launch modes - documenting the new unified CLI, RooCode/VSCode integration examples, and the
list_crate_itemstool surface - adding guidance on testing individual tools directly from the CLI plus notes on caching and output formatting
If you decide to keep these changes upstream, could you please add a short linkback to promptexecution/rust-cargo-docs-rag-mcp in your README? That attribution helps other developers understand where this MCP-focused variant originated and makes it easier for them to follow improvements across both projects.