This is an MCP (Model Context Protocol) server that provides tools for Rust crate documentation lookup. It allows LLMs to look up documentation for Rust crates they are unfamiliar with.
- 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
git clone https://github.com/promptexecution/cratedocs-mcp.git
cd cratedocs-mcp
cargo build --release
cargo install --path .
There are multiple ways to run the documentation server:
The unified command-line interface provides subcommands for all server modes:
# Run in STDIN/STDOUT mode
cargo run --bin cratedocs stdio
# Run in HTTP/SSE mode (default address: 127.0.0.1:8080)
cargo run --bin cratedocs http
# Run in HTTP/SSE mode with custom address
cargo run --bin cratedocs http --address 0.0.0.0:3000
# Enable debug logging
cargo run --bin cratedocs http --debug
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 (step by step)
cargo run --bin cratedocs test --tool list_crate_items --crate-name serde --version 1.0.0 --item-type struct
cargo run --bin cratedocs test --tool list_crate_items --crate-name tokio --version 1.28.0 --visibility pub --module tokio::sync
# 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
# Look up documentation for a specific version
cargo run --bin cratedocs test --tool lookup_item --crate-name serde --item-path Serialize --version 1.0.147
# Look up a trait in a crate (e.g., the Serialize trait in serde) & a specific version
cargo run --bin cratedocs test --tool lookup_item --crate-name serde --item-path serde::Serialize --version 1.0.160
# 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
cargo run --bin cratedocs test --tool lookup_crate --crate-name tokio --format text
# Save output to a file
cargo run --bin cratedocs test --tool lookup_crate --crate-name tokio --output tokio-docs.md
# Summarize output by stripping LICENSE and VERSION sections, limits to xxxxx tokens (uses huggingface tokenizer)
cargo run --bin cratedocs test --tool lookup_crate --crate-name tokio --tldr --max_tokens 48000
By default, the HTTP server will listen on http://127.0.0.1:8080/sse
.
The server provides the following tools:
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"
}
}
- 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
This 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"
],
}
}
}
// Roo Code, use bunx or npx, sessionId=
{
"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"
]
}
}
}
Enumerates all items in a specified Rust crate and version, optionally filtering by item type, visibility, or module path. Useful for exploring crate structure, generating concise listings for LLMs, or programmatically analyzing crate APIs.
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"
}
}
Example Output (stub):
Stub: list_crate_items for crate: serde, version: 1.0.0, filters: Some(ItemListFilters { item_type: Some("struct"), visibility: None, module: None })
When implemented, the output will be a structured list of items matching the filters.
MIT License