基于MCP的代码库记忆:通过Tree-Sitter构建的知识图谱用于LLM代码探索
Codebase-Memory: Tree-Sitter-Based Knowledge Graphs for LLM Code Exploration via MCP
AI总结:
Codebase-Memory通过MCP协议构建Tree-Sitter知识图谱,提升LLM代码探索效率,实现更高准确性与更低资源消耗。
摘要:
大型语言模型(LLM)编码代理通常通过重复文件读取和grep搜索来探索代码库,每次查询消耗数千个标记且缺乏结构理解。我们提出了Codebase-Memory,一个开源系统,通过Model Context Protocol(MCP)构建持久化的Tree-Sitter知识图谱,通过多阶段流水线和并行工作池解析66种语言,包括调用图遍历、影响分析和社区发现。在31个真实世界仓库中评估,Codebase-Memory在答案质量上达到83%,优于文件探索代理的92%,在十倍更少的标记和2.1倍更少的工具调用下实现。对于图原生查询如枢纽检测和调用者排名,它在19种语言中匹配或超过探索器。
英文摘要:
Large Language Model (LLM) coding agents typically explore codebases through repeated file-reading and grep-searching, consuming thousands of tokens per query without structural understanding. We present Codebase-Memory, an open-source system that constructs a persistent, Tree-Sitter-based knowledge graph via the Model Context Protocol (MCP), parsing 66 languages through a multi-phase pipeline with parallel worker pools, call-graph traversal, impact analysis, and community discovery. Evaluated across 31 real-world repositories, Codebase-Memory achieves 83% answer quality versus 92% for a file-exploration agent, at ten times fewer tokens and 2.1 times fewer tool calls. For graph-native queries such as hub detection and caller ranking, it matches or exceeds the explorer on 19 of 31 languages.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。