符号图
    
语义代码智能MCP服务器-构建代码库的知识图,以增强人工智能辅助的代码探索。
symgraph是一个rust实现https://github.com/colbymchenry/codegraph.为什么?正在对汇编进行探索 MCP服务器的二进制部署。
特性
- 多语言支持:Rust、TypeScript、JavaScript、Python、Go、Java、C、C++
- 符号提取:函数、类、方法、结构、接口、特征、枚举、常量
- 关系跟踪:调用、包含、导入、导出、扩展、实现
- 影响分析:通过代码库跟踪更改的影响
- 高级代码智能:
- 查找函数之间的调用路径 - 检测未使用/死代码 - 探索类层次结构 - 查找所有接口实现 - 按线范围分析变更影响
- 增量索引:仅使用内容哈希重新索引更改的文件
- 双重运输:stdio(默认)和HTTP服务器模式
安装
macOS和Linux
curl -fsSL https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.sh | bash要将符号图配置为Claude Code和Claude Desktop的MCP服务器,请执行以下操作:
curl -fsSL https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.sh | bash -s -- --mcp安装特定版本:
SYMGRAPH_VERSION=2026.3.30 curl -fsSL https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.sh | bashWindows(PowerShell)
irm https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.ps1 -OutFile install.ps1; .\install.ps1要将符号图配置为Claude Code和Claude Desktop的MCP服务器,请执行以下操作:
irm https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.ps1 -OutFile install.ps1; .\install.ps1 -Mcp安装特定版本:
$env:SYMGRAPH_VERSION="2026.3.30"; irm https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.ps1 -OutFile install.ps1; .\install.ps1这两个脚本都安装到 ~/.symgraph/bin/ 默认情况下。覆盖 SYMGRAPH_INSTALL_DIR.
克劳德桌面(MCPB捆绑包)
下载并安装适用于您平台的MCPB捆绑包:
| 平台 | 下载 |
|---|---|
| macOS(苹果硅) | sympgraph-x.x.x-darwin-arm64.mcpb |
| macOS(英特尔) | sympgraph-x.x.x-darwin-x64.mcpb |
| 窗户 | sympgraph-x.x.x-windows-x64.mcpb |
| Linux | sympgraph-x.x.x-linux-x64.mcpb |
- 下载
.mcpb从以下位置为您的平台创建文件 发布 - 打开克劳德桌面
- 拖放
.mcpb文件到克劳德桌面,或使用 文件>安装MCP服务器 - 在系统提示时配置项目根目录
来源
git clone https://github.com/grahambrooks/symgraph
cd symgraph
make install用法
为代码库建立索引
# Index current directory
symgraph index
# Index specific directory
symgraph index ~/projects/myapp启动MCP服务器
# Start with stdio transport (for Claude Desktop)
symgraph serve
# Start with HTTP transport
symgraph serve --port 8080CLI命令
symgraph index [path] # Index a codebase
symgraph serve # Start MCP server (stdio)
symgraph serve --port
# Start MCP server (HTTP)
symgraph status [path] # Show index statistics
symgraph search # Search for symbols
symgraph context # Build context for a taskMCP工具
核心工具
| 工具 | 说明 |
|---|---|
symgraph-context | 为特定任务构建专注的代码上下文 |
symgraph-search | 按名称快速搜索符号 |
symgraph-callers | 查找某个符号的所有调用者 |
symgraph-callees | 查找某个符号的所有被叫用户 |
symgraph-impact | 分析变化的影响半径 |
symgraph-node | 获取详细的符号信息 |
symgraph-definition | 获取带有上下文的符号的完整源代码 |
symgraph-file | 列出特定文件中定义的所有符号 |
symgraph-references | 查找对某个符号的所有引用 |
symgraph-reindex | 触发已更改文件的增量重新索引 |
symgraph-status | 获取索引统计信息 |
高级工具
| 工具 | 说明 |
|---|---|
symgraph-hierarchy | 获取类/模块层次结构(父/子关系) |
symgraph-path | 查找两个符号之间的呼叫路径 |
symgraph-unused | 查找没有传入引用的未使用/死代码 |
symgraph-implementations | 查找接口/特性的所有实现 |
symgraph-diff-impact | 分析更改特定代码区域的影响 |
示例用例
查找需要清理的死代码:
Use symgraph-unused to find all unused functions and classes了解函数调用链:
Use symgraph-path with from="main" and to="database_query" to see how data flows评估变更影响:
Use symgraph-diff-impact with file_path="src/auth.rs" start_line=45 end_line=60
to see what would be affected by changes in that region探索OOP层次结构:
Use symgraph-hierarchy with symbol="BaseHandler" to see all parent/child relationships查找所有trait实现:
Use symgraph-implementations with symbol="Iterator" to find all structs implementing Iterator项目设置
分两步将符号图添加到项目中:为代码建立索引,然后配置AI工具。
第一步:为你的项目建立索引
cd /path/to/your/project
symgraph index这创建了一个 .symgraph/ 包含SQLite知识图的目录。添加 .symgraph/ 到你的 .gitignore.
重新运行 symgraph index 在重大代码更改后,或使用 symgraph-reindex MCP工具,用于从您的AI工具中增量更新。
第二步:配置你的AI工具
克劳德代码
将符号图注册为您项目的MCP服务器:
cd /path/to/your/project
claude mcp add symgraph -- symgraph serve或添加 .mcp.json 到您的项目根目录:
{
"mcpServers": {
"symgraph": {
"type": "stdio",
"command": "symgraph",
"args": ["serve"]
}
}
}可选:添加 /explore-code 技能 对于引导式代码探索:
mkdir -p .claude/skills
cp -r /path/to/symgraph/.claude/skills/explore-code .claude/skills/然后在Claude Code中使用它:
/explore-code how does the authentication middleware work?
/explore-code what would break if I changed the User struct?克劳德桌面版
通过MCPB束(最简单):
- 下载
.mcpb从以下位置为您的平台创建文件 发布 - 拖放到Claude Desktop上,或使用 文件>安装MCP服务器
- 在系统提示时设置项目根目录
通过手动配置 --添加到 claude_desktop_config.json:
{
"mcpServers": {
"symgraph": {
"command": "symgraph",
"args": ["serve"],
"env": {
"SYMGRAPH_ROOT": "/path/to/your/project"
}
}
}
}GitHub Copilot
每个存储库 --添加 .copilot/mcp.json 对于您的项目:
{
"mcpServers": {
"symgraph": {
"command": "symgraph",
"args": ["serve"]
}
}
}VS代码用户设置 --添加到 settings.json:
{
"github.copilot.chat.mcp.servers": {
"symgraph": {
"command": "symgraph",
"args": ["serve"],
"env": {
"SYMGRAPH_ROOT": "${workspaceFolder}"
}
}
}
}看 了解更多详情。
OpenAI Codex
codex mcp add symgraph --command "symgraph" --args "serve"或添加到 ~/.codex/config.toml:
[mcp_servers.symgraph]
command = "symgraph"
args = ["serve"]看 OpenAI Codex MCP文档 了解更多详情。
HTTP模式(任何MCP客户端)
对于共享或远程设置,请将sympgraph作为HTTP服务器运行:
symgraph serve --port 8080然后将您的MCP客户端指向 http://localhost:8080/mcp.
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
SYMGRAPH_ROOT | 项目根目录 | 当前目录 |
建筑
symgraph/
├── src/
│ ├── main.rs # CLI entry point
│ ├── lib.rs # Core indexing logic
│ ├── types.rs # Type definitions (Node, Edge, etc.)
│ ├── db/ # SQLite database operations
│ ├── extraction/ # Tree-sitter code extraction
│ ├── graph/ # Graph traversal algorithms
│ ├── context/ # Context building for AI tasks
│ └── mcp/ # MCP protocol handlers
└── .symgraph/
└── index.db # SQLite database (per-project)核心概念
- 节点:代码符号(函数、类、方法等)
- 边缘:节点之间的关系(调用、包含、导入等)
- 知识图谱:代码库的完整节点和边集
发展
先决条件
- 锈蚀1.70+
- SQLite(通过rusqlite捆绑)
建筑
make build # Release build
make test # Run tests
make check # Format, lint, and test
make install # Build and install to /usr/local/bin项目结构
| 模块 | 说明 |
|---|---|
types | 核心类型定义(NodeKind、EdgeKind、语言等) |
db | SQLite数据库模式和操作 |
extraction | 基于树的代码解析和符号提取 |
graph | 图形算法(呼叫者、被呼叫者、影响分析) |
context | 用于AI任务辅助的上下文构建器 |
mcp | MCP协议服务器实现 |
许可证
麻省理工学院
