R rust-code-mcp v2
v2 Now with a HIR-driven workspace hypergraph & 45+ MCP tools

A workspace hypergraph,
for Rust agents.

An MCP server that combines hybrid BM25 + vector search with a HIR-driven workspace hypergraph built on rust-analyzer — exposing 45+ tools for symbol navigation, call-graph traversal, structural audits, and semantic neighborhood queries.

45+// MCP tools
26// Claude skills
5// embed profiles
13// tool categories
// features

From keyword search to a queryable model of your workspace.

v2 layers a HIR-driven hypergraph on top of hybrid search — so your agent can audit structure, trace call relationships, and detect duplicate logic with the same query plane.

Hybrid search with RRF fusion

BM25 keyword matching fused with vector similarity via reciprocal-rank fusion. Find code by what it does, not just what it's called.

Persisted hypergraph

HIR-driven LMDB snapshot of cross-crate imports, exports, re-exports, call edges, attributes, signatures, statics, and unsafe blocks.

Pluggable embedding models

Local GPU (Qwen3 on Candle/CUDA), local CPU (BGE on ONNX), or API-backed (OpenRouter). New API models added via config — no recompile.

Safety & quality audits

unsafe_audit, mut_static_audit, recursion_check, channel-capacity, fn-body unwrap/panic/lock-across-await detection.

Call graph & structure

who_calls, calls_from, dead-pub detection, name collisions, forbidden cross-crate edges, Robert Martin instability metrics.

Codemap & semantic overlap

build_codemap produces task-conditioned Mermaid subgraphs; semantic_overlaps clusters duplicate logic across the workspace.

// tools

45+ MCP tools, grouped into 13 categories.

Plug the server into Claude Code (or any MCP client) and each tool becomes callable from your agent. Full parameter reference in TOOLS.md.

Query

3
search get_similar_code read_file_content

Symbol analysis

6
find_definition find_references rename_symbol get_dependencies get_call_graph analyze_complexity

Index lifecycle

3
index_codebase health_check clear_cache

Hypergraph build

1
build_hypergraph

Imports / exports

4
get_imports get_exports get_reexports get_declared_reexports

Reverse lookup

3
who_imports who_uses who_uses_summary

Call graph

5
who_calls calls_from call_graph callers_in_crate recursive_callers_count

Workspace structure

6
dead_pub_in_crate dead_pub_report crate_edges overlaps module_tree workspace_stats

Architecture rules

2
forbidden_dependency_check crate_dependency_metric

Signatures & attributes

5
function_signature functions_with_filter enum_variants item_attributes items_with_attribute

Safety & quality audits

5
unsafe_audit mut_static_audit recursion_check channel_capacity_audit fn_body_audit

Doc / API audits

4
missing_docs_audit derive_audit pub_use_pub_type_audit re_export_chain

Semantic & codemap

3
similar_to_item semantic_overlaps build_codemap
// claude code skills

26 ready-made audit recipes.

The skills/ directory composes these tools into self-contained Claude Code skills. Each is a SKILL.md with prerequisites, step-by-step prompts, and hand-offs to related skills. Install once and invoke as /<skill-name>.

Workspace · 7
Crate · 3
Symbol · 7
Quality · 7
Planning · 2
install skills
mkdir -p ~/.claude/skills
ln -s "$(pwd)/skills/"rmc-* ~/.claude/skills/

# then in Claude Code:
> /rmc-workspace-overview # kick off a tour of a new repo
// embedding models

Pick your quality / speed / privacy tradeoff.

Semantic search and the embedding-backed audits run on a configurable embedding profile. Switch by passing embedding_profile to the search tools; each profile gets its own independent index.

Profile Model Runtime Dim
local-gpu-small default Qwen3-Embedding-0.6B local Candle / CUDA 1024
local-qwen3-4b Qwen3-Embedding-4B local Candle / CUDA 2560
local-qwen3-8b Qwen3-Embedding-8B local Candle / CUDA 4096
local-cpu-small BGE-small-en-v1.5 local ONNX / CPU 384
openrouter-qwen3-8b Qwen3-Embedding-8B OpenRouter API 4096
embedding_profiles.toml
# add an API model without recompiling
[[profile]]
name     = "openrouter-text-embedding-3-small"
model_id = "openai/text-embedding-3-small"
dim      = 1536
max_len  = 8191
env
# OpenRouter keys come from the env, never config files
export OPENROUTER_API_KEY=sk-or-...

# local CPU / GPU profiles need no key
// installation

Build, wire it in, index.

Three steps to running. The Nix flake is the easiest path — it ships a dev shell with nightly Rust and the full CUDA toolchain.

1 · build
# clone and build the release binary
git clone https://github.com/molaco/rust-code-mcp.git
cd rust-code-mcp
cargo build --release

# or, with the Nix flake (recommended for CUDA)
nix develop github:molaco/rust-code-mcp
cargo build --release

# binary at target/release/rust-code-mcp
2 · .mcp.json
{
  "mcpServers": {
    "rust-code-mcp": {
      "command": "/abs/path/to/rust-code-mcp",
      "env": {
        "RUST_LOG": "info",
        "CUDA_HOME": "/usr/local/cuda",
        "LD_LIBRARY_PATH": "/usr/local/cuda/lib64"
      }
    }
  }
}
3 · index, build the hypergraph & query
# inside Claude Code:
> index_codebase at /abs/path/to/my-rust-project
> build_hypergraph # persisted in LMDB, fingerprinted, reused on next call

# then call any of 45+ tools — for example:
> unsafe_audit                  # list every unsafe block, with context
> dead_pub_report               # find dead pub items across crates
> crate_dependency_metric       # rank by instability / abstractness
> rename_symbol "parse_expr" -> "parse_expression"  # preview only
> build_codemap seeded by "main"  # Mermaid + outline subgraph
// architecture

One workspace, four indexes, one query plane.

A document index, a vector store, a HIR-driven hypergraph, and rust-analyzer's IDE engine — kept in sync by a Merkle-tree watcher.

01 · source
Rust workspace
Files on disk. Hashed via Merkle tree to detect change; re-sync every 5 min.
02 · text + vector
tantivy + lancedb
BM25 document index alongside an embedded vector store, fused with RRF.
03 · hypergraph
ra_ap_hir + heed (LMDB)
Persisted HIR snapshot: imports, exports, call edges, attrs, signatures, unsafe.
04 · surface
rmcp · MCP server
45+ tools exposed to any MCP client. 26 Claude Code skills compose them.
// performance

Indexing throughput, by profile.

Measured on the project's own repository (~2,280 chunks) with an RTX 3090. Embedding is ~95%+ of indexing time; vector search is exact brute-force KNN — fast at workspace scale regardless of dimension.

local-gpu-small
~55chunks/sec
Qwen3-0.6B on local GPU. Private, deterministic, no API calls.
openrouter-qwen3-8b
~45–50chunks/sec
API; per-request latency varies. Same model as local-qwen3-8b, no local GPU.
MIT licensed · self-hosted · agent-friendly

Give your agent a real model of your codebase.

Clone the repo, plug it into Claude Code, and tell us how you use it — we want to hear about people's workflows.