Skip to main content
Glama

AI 编码智能体在翻找你的代码库时,浪费了大部分工具调用在 grepcatfind 和文件读取上。rpg-encoder 解决了这个问题。它通过 Tree-sitter 为你的代码构建一个语义图——不仅是谁调用了谁,还包括每个函数做什么——并通过 MCP 在一次工具调用中让你的 AI 助手获得对整个代码库的理解。


快速开始

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

一条命令。适用于 Claude Code、Cursor、opencode、Windsurf 或任何兼容 MCP 的智能体。无需 Rust 工具链、无需克隆、无需构建——npx 会为你的平台下载预构建的二进制文件。

然后打开任意仓库,告诉你的智能体:

“为这个仓库构建并提升 RPG”

你的智能体会处理一切:索引实体(几秒钟)、阅读每个函数并添加意图级别的特征(几分钟)、将它们组织成语义层次结构,并为你的团队提交 .rpg/graph.json

对于拥有 ~100 个以上实体的仓库,lifting_status 会告诉你的智能体把提升循环委托给子智能体或更便宜的模型——特征提取是模式匹配,而不是新颖推理。如果你的运行时没有子智能体机制,请在终端中运行 rpg-encoder lift --provider anthropic|openai 并带上 API 密钥——CLI 会直接驱动外部 LLM,不需要智能体参与。CLI 完成后,在会话中调用 reload_rpg 以加载更新后的图。CLI 只提升没有特征的实体;重新提升过时实体(代码变更后特征仍存在但已过时)由会话内的 MCP 流程处理,而非 CLI。

提升完成后,试试:

  • “什么处理身份验证?” —— 即使没有任何东西命名为 "auth",也能找到相关代码

  • “显示所有依赖数据库连接的内容”

  • “规划一个为 API 端点添加速率限制的变更”

Related MCP server: code-intel

grepcatfind 之前使用 RPG

服务器指令告诉你的智能体,对于任何关于代码结构或行为的问题,首先要使用 RPG 工具。这种习惯很重要——grepcat 和临时的文件读取会消耗 token,并且遗漏 RPG 已经知晓的语义关系。

如果你原本会使用...

改用这个

grep -r / rg(按意图)

search_node(query="...")

grep -r / rg(按名称)

search_node(query="...", mode="snippets")

cat / 读取一个函数

fetch_node(entity_id="file:name")

对调用方/被调用方进行链式 grep

explore_rpg(entity_id="...", direction="...")

递归 grep 查找“什么依赖于 X”

impact_radius(entity_id="...")

wc -l / find / tree

rpg_info

读取许多文件以获取上下文

semantic_snapshot

手动搜索 → 获取 → 探索链

context_pack(query="...")

“如何安全地重构 X”

plan_change(goal="...")

仅当查询涉及字面文本(字符串搜索、注释、TODO、日志消息)——而非结构——时才回退到 grepcat 或文件读取。

工作原理

  1. 解析 —— Tree-sitter 从 15 种语言中提取实体(函数、类、方法)和依赖边(导入、调用、继承)。

  2. 提升 —— 一个 LLM(你的智能体,或像 Haiku 这样廉价的 API)阅读每个实体并编写“动词-宾语”特征:“验证 JWT 令牌”“将配置序列化到磁盘”

  3. 组织 —— 特征聚合成一个 3 级语义层次结构(领域 → 类别 → 子类别),它

工具

描述

auto_lift

通过廉价 LLM API(Haiku、GPT-4o-mini、OpenRouter、Gemini)实现一键式自主提升

lifting_status

仪表盘 — 覆盖率、各区域进度、下一步

get_entities_for_lifting

获取实体源代码供你的智能体分析

submit_lift_results

将智能体的语义特征提交回图

finalize_lifting

聚合文件级特征,重建层次结构元数据

get_files_for_synthesis

获取文件级实体特征以进行整体综合

submit_file_syntheses

提交整体文件级摘要

build_semantic_hierarchy

获取领域发现 + 层次结构分配提示词

submit_hierarchy

将层次结构分配应用到图

get_routing_candidates

获取需要语义路由的实体(已漂移或新提升)

submit_routing_decisions

提交路由决策(层次结构路径或 "keep")


支持的语言

通过 Tree-sitter 支持 15 种语言:

语言

实体提取

依赖解析

Python

函数、类、方法

imports、调用、继承

Rust

函数、结构体、trait、impl 方法

use、调用、trait 实现

TypeScript

函数、类、方法、接口

imports、调用、继承

JavaScript

函数、类、方法

imports、调用、继承

Go

函数、结构体、方法、接口

imports、调用

Java

类、方法、接口

imports、调用、继承

C / C++

函数、类、方法、结构体

includes、调用、继承

C#

类、方法、接口

using、调用、继承

PHP

函数、类、方法

use、调用、继承

Ruby

类、方法、模块

require、调用、继承

Kotlin

函数、类、方法

imports、调用、继承

Swift

函数、类、结构体、协议

imports、调用、继承

Scala

函数、类、对象、trait

imports、调用、继承

Bash

函数

source、调用


安装

MCP 服务器(推荐)

# Claude Code
claude mcp add rpg -- npx -y -p rpg-encoder rpg-mcp-server

# Cursor — add to ~/.cursor/mcp.json
{
  "mcpServers": {
    "rpg": {
      "command": "npx",
      "args": ["-y", "-p", "rpg-encoder", "rpg-mcp-server"]
    }
  }
}

服务器会自动从当前工作目录检测项目根目录 — 无需路径参数。

npm install -g rpg-encoder

# Build a graph
rpg-encoder build

# Query
rpg-encoder search "parse entities from source code"
rpg-encoder fetch "src/parser.rs:extract_entities"
rpg-encoder explore "src/parser.rs:extract_entities" --direction both --depth 2
rpg-encoder info

# Autonomous lifting via API
rpg-encoder lift --provider anthropic --dry-run  # estimate cost
rpg-encoder lift --provider anthropic           # lift with Haiku (~$0.02/100 entities)

# Incremental update
rpg-encoder update

# Pre-commit hook (auto-updates graph on commit)
rpg-encoder hook install
git clone https://github.com/userFRM/rpg-encoder.git
cd rpg-encoder && cargo build --release

然后将你的 MCP 配置指向 target/release/rpg-mcp-server


文档


灵感与参考

rpg-encoder 基于 RPG-Encoder 研究论文的理论框架构建,并借鉴代码智能领域各工具进行了原创扩展:

  • RPG-Encoder 论文 (Luo et al., 2026, Microsoft Research) — 语义提升模型、三层层次结构构建、增量演化算法、形式化图模型 G = (V_H ∪ V_L, E_dep ∪ E_feature)

  • GitNexus — 预计算的关系智能、爆炸半径分析、Claude Code 钩子。这表明,代码图工具必须隐形才能成为必需品。

  • Serena — 通过 LSP 实现符号级精度。证明了实时代码感知比批量分析更重要。

  • TOON — Token-Oriented Object Notation,为 LLM 优化输出而设计。

这是一个独立实现。所有代码均为 MIT 许可下的原创工作。与微软无关,也未获得微软的认可。


许可证

MIT

A
license - permissive license
-
quality - not tested
C
maintenance

Maintenance

Maintainers
3hResponse time
Release cycle
Releases (12mo)
Commit activity
Issues opened vs closed

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    A
    maintenance
    Supercharges AI coding agents with a pre-indexed semantic code graph, enabling instant symbol relationships, impact analysis, and context retrieval across 20+ languages.
    83,491
    66,716
    MIT
  • A
    license
    -
    quality
    C
    maintenance
    Provides semantic code search and code insights via a knowledge graph, enabling AI to understand, navigate, and modify complex projects with deep dependency and architecture analysis.
    MIT
  • A
    license
    -
    quality
    C
    maintenance
    Provides a semantic understanding of your codebase by parsing with tree-sitter and building a graph of symbols and dependencies. Enables AI assistants to navigate code, analyze changes, and discover architecture using 18 tools with minimal context overhead.
    12
    1
    MIT
  • A
    license
    -
    quality
    B
    maintenance
    Supercharges AI coding agents with semantic code intelligence, providing pre-built knowledge graphs for surgical context, faster answers, and fewer tool calls.
    MIT

View all related MCP servers

Related MCP Connectors

  • Give your AI agent a persistent map of your project's structure, dependencies, and bugs.

  • Your company's brain for AI agents. Cited, permission-aware knowledge across every system.

  • AI Agent with Architectural Memory. Impact analysis (free), tests and code from the graph (pro).

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/userFRM/rpg-encoder'

If you have feedback or need assistance with the MCP directory API, please join our Discord server