# rpg-encoder [Health: Active]

**Category:** 🤖 Coding Agents  
**Repository:** https://github.com/userFRM/rpg-encoder  
**GitHub Stars:** 33  
**npm Downloads (last month):** 296  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/rpg-encoder

## Description
Semantic code graph for AI-assisted code understanding via tree-sitter and MCP.

## Tools
Capabilities this server exposes over MCP:

- **build_rpg** — Index the codebase (run once, instant)
- **update_rpg** — Incremental update from git changes
- **reload_rpg** — Reload graph from disk after external changes
- **rpg_info** — Graph statistics, hierarchy overview, per-area lifting coverage
- **semantic_snapshot** — Whole-repo semantic understanding in one call (~25K tokens for 1000 entities)
- **search_node** — Search entities by intent or keywords (hybrid embedding + lexical scoring)
- **fetch_node** — Get entity metadata, source code, dependencies, and hierarchy context
- **explore_rpg** — Traverse dependency graph (upstream, downstream, or both)
- **context_pack** — Single-call search + fetch + explore with token budget
- **impact_radius** — BFS reachability analysis — "what depends on X?"
- **plan_change** — Change planning — find relevant entities, modification order, blast radius
- **find_paths** — K-shortest dependency paths between two entities
- **slice_between** — Extract minimal connecting subgraph between entities
- **analyze_health** — Code health: coupling, instability, god objects, clone detection
- **detect_cycles** — Find circular dependencies and architectural cycles
- **reconstruct_plan** — Dependency-safe reconstruction execution plan
- **auto_lift** — One-call autonomous lifting via cheap LLM API (Haiku, GPT-4o-mini, OpenRouter, Gemini)
- **lifting_status** — Dashboard — coverage, per-area progress, NEXT STEP
- **get_entities_for_lifting** — Get entity source code for your agent to analyze
- **submit_lift_results** — Submit the agent's semantic features back to the graph
- **finalize_lifting** — Aggregate file-level features, rebuild hierarchy metadata
- **get_files_for_synthesis** — Get file-level entity features for holistic synthesis
- **submit_file_syntheses** — Submit holistic file-level summaries
- **build_semantic_hierarchy** — Get domain discovery + hierarchy assignment prompts
- **submit_hierarchy** — Apply hierarchy assignments to the graph
- **get_routing_candidates** — Get entities needing semantic routing (drifted or newly lifted)
- **submit_routing_decisions** — Submit routing decisions (hierarchy path or "keep")

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "rpg-encoder": {
    "command": "npx",
    "args": ["-y","-p","rpg-encoder","rpg-mcp-server"]
  }
}
```

## Documentation

## What rpg-encoder MCP server does

The rpg-encoder MCP server turns a codebase into a graph of functions, classes, methods, and dependency relationships. It uses Tree-sitter to extract entities and links such as imports, calls, and inheritance across 15 languages. The resulting graph is stored on disk and made available to an MCP-compatible coding agent.

The graph supports both structural and semantic understanding. Structural data includes source code, metadata, hierarchy, and dependencies. Semantic lifting adds short intent-level features, such as the operation performed by a function, so searches can find relevant code even when names do not match the query.

## How it works

Run `build_rpg` to create the initial index. Later, `update_rpg` applies additions, changes, and removals based on Git changes, while `reload_rpg` loads a graph changed outside the current server session. The server also checks for working-tree changes before responding and can restore graph state when files revert.

Navigation tools cover several levels of detail. `semantic_snapshot` returns a compact whole-repository representation with hierarchy, entity features, dependency structure, and highly connected entities. `search_node` combines embedding and lexical matching. `fetch_node` returns an entity's source, metadata, dependencies, and hierarchy context. `explore_rpg`, `impact_radius`, `find_paths`, and `slice_between` support dependency and reachability analysis.

For multi-step investigation, `context_pack` combines search, retrieval, and graph exploration under a token budget. `plan_change` identifies relevant entities, an order for modifications, and the likely blast radius. `analyze_health` checks coupling, instability, large central objects, and clones; `detect_cycles` finds circular dependencies.

## Setup and configuration

The documented quick-start command is:

```bash
claude mcp add rpg -- npx -y -p rpg-encoder rpg-mcp-server
```

This uses `npx` to obtain a pre-built platform binary, so the quick-start path does not require cloning the repository, compiling Rust, or installing a Rust toolchain. After connecting the server, ask the agent to build and lift the graph for the repository.

The graph is saved as `.rpg/graph.json`, which can be committed for team use. Autonomous lifting can instead be run with the `rpg-encoder lift` CLI using an Anthropic or OpenAI provider. The MCP `auto_lift` tool also supports Anthropic, OpenAI, OpenRouter, and Gemini providers and can read an API key from an environment-variable name supplied in the tool call.

## Tools and capabilities

The rpg-encoder MCP server provides tools for:

- Building, updating, reloading, and inspecting graph state.
- Searching by intent or keywords and retrieving entity context.
- Traversing upstream and downstream dependencies.
- Producing repository snapshots and token-bounded context packs.
- Measuring impact radius, finding dependency paths, and extracting connecting subgraphs.
- Planning changes and generating dependency-safe reconstruction plans.
- Checking code health and detecting architectural cycles.
- Managing semantic lifting, file synthesis, hierarchy assignment, and routing decisions.

Agent-driven lifting uses `get_entities_for_lifting` and `submit_lift_results`. Additional tools support status reporting, finalization, file-level synthesis, semantic hierarchy construction, and routing decisions. `auto_lift` performs the lifting through a configured external LLM instead.

## Limitations and notes

The server is intended for code structure and behavior questions. Literal text searches, comments, TODOs, and log messages may still require ordinary repository tools. Semantic results depend on the graph being built and, for intent-based features, on lifting having been completed.

For larger repositories, the documented workflow recommends delegating lifting to a sub-agent or cheaper model when available. The CLI can lift entities without features, but stale features after code changes are handled by the in-session MCP workflow rather than that CLI path. External-provider lifting requires the corresponding API access and key configuration.

_Full upstream README: https://allmcps.com/mcp/rpg-encoder/readme_

