
Rpg Encoder
io.github.userFRMPublished by GitHub account userFRMv0.6.7Updated Oct 24, 2026
Semantic code graph for AI-assisted code understanding via tree-sitter and MCP.
Overview
Builds a semantic graph of a local codebase so an assistant can search, explore, and plan changes by intent instead of grepping files.
- What you can do
- Indexes a repository with Tree-sitter across 15 languages, extracting functions, classes, methods, and dependency edges. An LLM then labels each entity with verb-object features, which are clustered into a three-level semantic hierarchy. Tools include build_rpg, update_rpg, semantic_snapshot, search_node, fetch_node, explore_rpg, context_pack, impact_radius, plan_change, analyze_health, and detect_cycles. The graph re-syncs automatically when the working tree changes.
- When to use it
- Useful when an assistant needs whole-repository understanding: locating code by behavior rather than name, tracing callers and dependents, assessing the blast radius of a change, or planning a refactor. It is aimed at larger codebases where repeated grep, cat, and file reads waste tokens.
- Requirements
- Runs locally as a stdio process, installed via npx from the npm package rpg-encoder; no Rust toolchain or build step is needed. It auto-detects the project root from the working directory. Optional autonomous lifting calls an external LLM provider and needs an API key, which can be resolved from an environment variable such as ANTHROPIC_API_KEY.
Installation
In SourceWeft
- Open Rpg Encoder in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
rpg-encoder
Give your AI agent a brain for your codebase.
[CI] [MIT License] [Rust 1.85+] [npm] [MCP] [Stars]
AI coding agents waste most of their tool calls fumbling through your codebase with grep, cat, find, and file reads. rpg-encoder fixes that. It builds a semantic graph of your code with Tree-sitter — not just what calls what, but what every function does — and gives your AI assistant whole-repo understanding via MCP in a single tool call.
Quick Start
One command. Works with Claude Code, Cursor, opencode, Windsurf, or any MCP-compatible agent. No Rust toolchain, no cloning, no building — npx downloads a pre-built binary for your platform.
Then open any repo and tell your agent:
"Build and lift the RPG for this repo"
Your agent handles everything: indexes entities (seconds), reads each function and adds intent-level features (a few minutes), organizes them into a semantic hierarchy, and commits .rpg/graph.json for your team.
For repos with ~100+ entities, lifting_status will tell your agent to delegate the lifting loop to a sub-agent or a cheaper model — feature extraction is pattern-matching, not novel reasoning. If your runtime has no sub-agent mechanism, run rpg-encoder lift --provider anthropic|openai from the terminal with an API key — the CLI drives an external LLM directly with no agent involvement. After the CLI finishes, call reload_rpg in your session to load the updated graph. The CLI lifts entities with no features; re-lifting stale entities (features present but outdated after code changes) is handled by the in-session MCP flow, not the CLI.
Once lifted, try:
- "What handles authentication?" — finds code even when nothing is named "auth"
- "Show everything that depends on the database connection"
- "Plan a change to add rate limiting to API endpoints"
Use RPG before grep, cat, find
The server instructions tell your agent to reach for RPG tools FIRST for any
question about code structure or behavior. That reflex matters — grep, cat,
and ad-hoc file reads burn tokens and miss semantic relationships RPG already
knows.
Fall back to grep, cat, or file reads only when the query is about literal text
(string search, comments, TODOs, log messages) — not about structure.
How It Works
- Parse — Tree-sitter extracts entities (functions, classes, methods) and dependency edges (imports, calls, inheritance) from 15 languages.
- Lift — An LLM (your agent, or a cheap API like Haiku) reads each entity and writes verb-object features: "validate JWT tokens", "serialize config to disk".
- Organize — Features cluster into a 3-level semantic hierarchy (Area → Category → Subcategory) that emerges from what the code does, not the file tree.
- Understand —
semantic_snapshotcompresses the whole graph into ~25K tokens. Your LLM reads it once and knows the repo.
The semantic snapshot
Instead of grepping through files, the LLM calls semantic_snapshot once and receives:
- Hierarchy — every functional area with aggregate features
- Entities — every function, class, method grouped by area, with its semantic features
- Dependency skeleton — condensed call graph with qualified names
- Hot spots — top 10 most-connected entities (the architectural backbone)
~25K tokens covers ~1000 entities. That's 2-3% of a 1M context window — the LLM starts every session already knowing your repo.
Self-maintaining graph
Whenever your working tree changes — committed, staged, or unstaged — the MCP server automatically re-syncs before responding to the next query. A changeset hash over (path, size, mtime) means repeated saves of the same file trigger one sync, and idle queries trigger none. Reverts are detected too: if a previously-dirty file returns to its HEAD state, the graph is restored.
Two ways to lift
auto_lift calls a cheap external LLM directly — your coding subscription never touches the lifting work. Use api_key_env to resolve keys from environment variables so they never appear in tool call transcripts.
Architecture
Seven Rust crates, one MCP server binary, one CLI binary:
MCP Tools (27)
Build & Maintain (4 tools)
Navigate & Search (5 tools)
Plan & Analyze (7 tools)
Semantic Lifting (11 tools)
Supported Languages
15 languages via Tree-sitter:
Install
MCP server (recommended)
The server auto-detects the project root from the current working directory — no path argument needed.
CLI
Build from source
Then point your MCP config at target/release/rpg-mcp-server.
Documentation
- How RPG Compares — honest comparison with GitNexus, Serena, Repomix, and others
- Paper Fidelity — algorithm-by-algorithm comparison with the research paper
- Use Cases — practical examples of what RPG enables
- CHANGELOG — release history
Inspirations & References
rpg-encoder is built on the theoretical framework from the RPG-Encoder research paper, with original extensions inspired by tools across the code intelligence landscape:
- RPG-Encoder paper (Luo et al., 2026, Microsoft Research) — semantic lifting model, 3-level hierarchy construction, incremental evolution algorithms, formal graph model
G = (V_H ∪ V_L, E_dep ∪ E_feature). - GitNexus — precomputed relational intelligence, blast radius analysis, Claude Code hooks. Showed that a code graph tool must be invisible to be essential.
- Serena — symbol-level precision via LSP. Demonstrated that real-time code awareness matters more than batch analysis.
- TOON — Token-Oriented Object Notation for LLM-optimized output.
This is an independent implementation. All code is original work under the MIT license. Not affiliated with or endorsed by Microsoft.
License
Source: README.md at commit 26b24ee
Tools
0Version history
1- v0.6.7LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts