MCP server exposing rust-analyzer as tools for Claude Code — semantic code navigation without grepping. Saves time and tokens.
| Tool | What it does |
|---|---|
symbols |
Search for symbols by name across the workspace |
hover |
Get type information and docs at a file position |
definition |
Jump to where a symbol is defined |
references |
Find all references to a symbol |
implementations |
Find all trait/method implementations |
symbol_references |
Find a symbol by name + get all references (one call) |
document_symbols |
List all symbols in a file (structural overview) |
- Python 3.11+
- rust-analyzer in your PATH
Install rust-analyzer:
# Via rustup (recommended)
rustup component add rust-analyzer
# Via Homebrew (macOS)
brew install rust-analyzergit clone https://github.com/riccajason/mcp-rust-analyzer.git
cd mcp-rust-analyzer
python3 -m venv .venv
.venv/bin/pip install -e .Add to your project's .mcp.json:
{
"mcpServers": {
"rust-analyzer": {
"command": "/path/to/mcp-rust-analyzer/.venv/bin/python3",
"args": ["-m", "mcp_rust_analyzer"],
"env": {
"WORKSPACE_ROOT": "/path/to/your/rust/project"
}
}
}
}The MCP server starts when Claude Code connects. First connection takes ~20 seconds while rust-analyzer indexes the workspace. Subsequent tool calls are instant.
| Variable | Default | Description |
|---|---|---|
WORKSPACE_ROOT |
Current directory | Path to the Rust project root |
RUST_ANALYZER_PATH |
rust-analyzer |
Path to the rust-analyzer binary |
The server automatically reads .vscode/settings.json in your workspace and forwards any rust-analyzer.* settings. Projects with custom targets (embedded, no_std, cross-compilation) work without extra configuration:
{
"rust-analyzer.cargo.target": "x86_64-unknown-none",
"rust-analyzer.check.allTargets": false
}Claude Code ──MCP/stdio──> mcp-rust-analyzer ──LSP/JSON-RPC──> rust-analyzer
The server spawns rust-analyzer as a subprocess, speaks the Language Server Protocol over its stdio, and translates MCP tool calls into LSP requests. rust-analyzer stays warm between calls — no re-indexing per query.
File changes are tracked via mtime. When a file is modified between tool calls, the server pushes the update to rust-analyzer automatically.
MIT