codebase-memory-mcp:代码知识图谱,Agent第二大脑
说实话,我最近一直在想一个问题:AI编码助手越来越强了,但为什么每次打开一个新项目,它还是像个第一次进城的乡下人?
上下文窗口塞满,token哗哗地烧,它还在那翻来覆去地读同一个文件。你让它改个函数,它先把整个模块重新读一遍,明明上周刚改过。
直到我刷到了 GitHub 上的 codebase-memory-mcp。
它解决了一个真实痛点
AI编码助手有个致命的短板:没有记忆。每次对话都是全新的开始。
你花了一周重构的项目结构,它不知道。你刚修好的那个bug,它不记得。你精心设计的架构模式,它理解不了。
传统方案是什么?把整个代码库塞进上下文。然后 token 账单让你怀疑人生。
codebase-memory-mcp 的思路完全不同。它给 AI 编码助手装了一个"第二大脑",一个持久化的知识图谱,记录了代码库的结构、依赖、类型信息。下次再问,毫秒级响应,不用重新读文件。
技术亮点
扒了一下它的实现,几个点确实有点东西:
158种语言支持。不是那种"支持100种语言"的营销话术,它真的用 tree-sitter 做了精确的语法解析,不是简单的正则匹配。从 Go 到 Haskell,从 Rust 到 COBOL,全覆盖。
毫秒级查询。索引完成后,查询响应时间在亚毫秒级别。对比一下,让 AI 重新读一遍 10 万行代码的项目,光 token 消耗就够你喝一壶的。
99% 更少的 token 消耗。这是它最实在的价值。MCP 协议让 AI 编码助手可以直接查询知识图谱,而不是把整个文件塞进上下文。说白了,就是让 AI 学会"查资料"而不是"背书"。
单静态二进制,零依赖。编译完就一个文件,扔服务器上就能跑。没有 Node_modules 的噩梦,没有 Python 环境的依赖地狱。
实际用起来怎么样?
我试着跑了一下。安装过程简单到离谱,下载二进制,配个 MCP 配置文件,搞定。
索引一个中型 Go 项目(大概 5 万行),花了不到 10 秒。然后我问了几个问题:
- "这个项目的核心数据结构是什么?" → 0.3ms
- "auth 模块依赖哪些外部包?" → 0.1ms
- "找到所有实现了 Handler 接口的类型" → 0.5ms
说实话,这个速度让我有点意外。不是那种"理论上很快"的架构图,是真实可感的快。
但它不是银弹
讲真,没有什么是完美的。codebase-memory-mcp 也有它的局限:
- 动态语言的精度有限。Python、JavaScript 这种动态类型语言,tree-sitter 能解析语法结构,但类型推断就别想了。类型信息要靠 TypeScript 的 type checker 或者 Python 的 type hint 来补。
- 跨项目引用不好处理。如果你的项目依赖几十个 npm 包,它只能索引你仓库里的代码,node_modules 里的不会碰。
- 不是代码搜索引擎。它擅长回答结构性问题("这个函数在哪里定义的"),但不适合做语义搜索("找找有没有内存泄漏")。
适合谁用?
如果你在用 Cursor、Claude Code、Codex 或者任何支持 MCP 协议的 AI 编码工具,而且你的项目超过 1 万行代码,这个工具能帮你省下不少 token 钱。
如果你是个 solo developer,项目就几千行代码,那可能感受不到太大区别。但团队项目、大型 monorepo、遗留系统,这玩意能显著提升 AI 助手的表现。
说两句
代码智能这个方向,我一直觉得是被低估的。大家都在卷更大的模型、更长的上下文,但很少有人认真想过:AI 真的需要把整个代码库都读一遍才能回答一个简单的问题吗?
codebase-memory-mcp 给出了一个优雅的答案:不需要。建个索引,查一下,完事。就像你不会为了查一个电话号码把整本通讯录背下来一样。
项目地址:https://github.com/DeusData/codebase-memory-mcp
codebase-memory-mcp: Code knowledge graph, agent’s second brain
To be honest, I've been thinking about a problem recently: AI coding assistants are getting stronger, but why does it still feel like a stranger entering a new project every time?
The context window is full, tokens are flying away, yet it still reads the same file over and over. You ask it to modify a function, it re-reads the entire module from scratch, even though it was edited last week.
Then I stumbled upon codebase-memory-mcp on GitHub.
It solves a real pain point.
AI coding assistants have a fatal flaw: lack of memory. Every conversation starts from zero.
The project structure you spent a week refactoring? It doesn’t know. The bug you just fixed? It doesn’t remember. The architecture patterns you carefully designed? It can’t grasp them.
The traditional solution is to stuff the entire codebase into the context — then the token bill makes you question life choices.
codebase-memory-mcp takes a completely different approach. It gives the AI a “second brain” — a persistent knowledge graph recording the codebase’s structure, dependencies, and type information. Next time you ask, it responds in milliseconds without re-reading files.
Technical Highlights
After digging into its implementation, a few things stand out:
Supports 158 languages. Not marketing fluff — it actually uses tree-sitter for precise syntax parsing across Go, Haskell, Rust, COBOL, etc.
Millisecond-level queries. Once indexed, response times are sub-millisecond. Compare that to making the AI read 100k+ lines of code — your token budget bleeds.
99% fewer tokens consumed. This is the real value. Via MCP, the AI directly queries the graph instead of loading raw text. Think of it as the AI learning to “lookup” instead of “memorize”.
Single static binary, zero dependencies. Compile once, drop it on a server — no Node_modules nightmares or Python env issues.
How Does It Perform?
I ran a test. Installation was trivial — download binary, configure MCP, done.
Indexed a medium-sized Go project (~50k lines) in under 10 seconds. Then I asked:
“What’s the core data structure?” → 0.3 ms
“What external packages does auth depend on?” → 0.1 ms
“Find all types implementing Handler interface” → 0.5 ms
The speed genuinely surprised me — not theoretical, but visibly fast in practice.
But It’s Not a Silver Bullet
Nothing’s perfect. codebase-memory-mcp has limitations:
Single binary deployment model— while efficient, may not scale for massive distributed setups without tweaking.
Limited precision for dynamic languages. tree-sitter parses syntax well for Python/JS, but without type annotations or inferencing, queries about types are speculative.
Cross-project references are challenging. If your project depends on 50 npm packages, it only indexes local code — not node_modules.
Not a code search engine. It excels at structural queries (“where is this function defined?”), not semantic ones (“find memory leaks”).
Who Should Use It?
If you’re using Cursor, Claude Code, Codex, or any MCP-compatible AI tool, and your projects exceed 10k lines, this can save significant token costs.
For solo devs with small projects, the impact is minor. But for teams, large monorepos, or legacy systems, it drastically improves the AI’s performance and efficiency.
Final Thoughts
I believe code intelligence is undervalued. Everyone chases bigger models and longer contexts, but rarely asks: does the AI *need* to read the whole codebase for every question?
codebase-memory-mcp answers: no. Build an index, look it up, move on. Just like you don’t memorize a phone book to dial a number — you check the directory.
Project URL: https://github.com/DeusData/codebase-memory-mcp