The Code Knowledge Graph Tool I Missed: codebase-memory-mcp
A few weeks ago I published a head-to-head comparison of Graphify, GitNexus, and CodeGraph — three tools that build knowledge graphs of your codebase so AI agents stop wasting tokens reading files one by one. Readers pointed out I missed one. After digging in, I think it might be the most complete of all four.
codebase-memory-mcp is a single static C binary — zero dependencies, no Python, no Node.js, no Docker — that indexes 158 programming languages into a knowledge graph and exposes it through 15 MCP tools. It ships a Cypher query engine, embedded semantic search (no API key), and has a research paper backing its efficiency claims: 120x fewer tokens on structural queries.
This post adds codebase-memory-mcp to every round from the original comparison. If you haven't read that post, the short version: AI coding agents burn massive tokens crawling files to answer structural questions. Knowledge graphs pre-build the map so agents get answers in one call instead of fifteen.
codebase-memory-mcp at a Glance#
| Dimension | Detail |
|---|---|
| Languages | 158 via vendored tree-sitter + Hybrid LSP type resolution for 10 (Python, TS/JS, Go, Rust, Java, C/C++, C#, PHP, Kotlin, Perl) |
| Content | Code + infrastructure-as-code (Dockerfiles, K8s manifests, Kustomize overlays) |
| Storage | SQLite + FTS5 full-text search + vector indexes |
| Query | 15 MCP tools + read-only Cypher engine + semantic vector search |
| License | MIT |
| One-liner | The one that ships 158 languages and a Cypher engine in a single zero-dependency binary |
Head-to-Head: Now a Four-Way Comparison#
Round 1: Keeping the Index Fresh#
| Tool | Freshness Mechanism | User Action Required |
|---|---|---|
| Graphify | Manual --update or git hooks | Yes — run command or set up hooks |
| GitNexus | Manual incremental / PostToolUse staleness hooks | Yes — re-run after changes |
| CodeGraph | Native OS file watching (FSEvents/inotify). 2-second debounce. | None — fully automatic |
| codebase-memory-mcp | Background git-polling watcher (5–60s adaptive intervals) | None — automatic after first index |
Winner: CodeGraph for raw speed (2-second real-time sync). codebase-memory-mcp is a close second — fully automatic but poll-based, so there's a 5–60 second delay between your edit and the graph update. Both are hands-off after initial setup.
Round 2: What Can It Index?#
| Tool | Code Languages | Non-Code Content |
|---|---|---|
| Graphify | 36 (tree-sitter) | Docs, PDFs, images, video/audio, YouTube, Google Workspace |
| GitNexus | 14 (tree-sitter) | Markdown sections, API routes, ORM models, DI patterns |
| CodeGraph | 20+ (tree-sitter) | Code only — but understands framework routing and dynamic dispatch |
| codebase-memory-mcp | 158 (vendored tree-sitter + Hybrid LSP for 10) | Dockerfiles, K8s manifests, Kustomize overlays |
Winner: codebase-memory-mcp for language breadth — 158 languages is 4x more than the next closest (Graphify at 36). Every grammar is compiled into the binary, so there's nothing to download or configure. Graphify still wins for non-code content (PDFs, images, video). codebase-memory-mcp uniquely covers infrastructure-as-code.
Round 3: Understanding Dynamic Code#
Static analysis can see imports and direct function calls. But real-world code has indirect connections — callbacks, events, framework routing — that grep can't follow. How does each tool handle these?
| Pattern | Graphify | GitNexus | CodeGraph | codebase-memory-mcp |
|---|---|---|---|---|
| Callbacks (registrar/dispatcher) | No | No | Yes | No |
| EventEmitter (.on/.emit) | No | No | Yes | Yes (EMITS/LISTENS_ON, 8 languages) |
| React setState/JSX dispatch | No | No | Yes (re-render edges) | Partial (JSX → component via Hybrid LSP, no re-render flow) |
| Interface/abstract dispatch | No | Yes | No | Yes (Hybrid LSP type resolution) |
| Framework routing | No | Yes | Yes (22 frameworks) | Yes (HTTP/gRPC/GraphQL/tRPC) |
| Cross-service HTTP calls | No | Yes (route_map: route → handler → consumer; cross-repo via Contract Registry) | No | Yes (route ↔ call-site matching with confidence scoring) |
| Channel/pub-sub patterns | No | No | No | Yes (Socket.IO, EventEmitter, 8 langs) |
| Dependency injection | No | Yes | No | No |
| Swift ↔ Objective-C bridging | No | No | Yes | No |
Split verdict:
- CodeGraph leads on frontend-specific dynamic dispatch — callbacks, React re-render edges, registrar/dispatcher pairs.
- codebase-memory-mcp leads on cross-service patterns — HTTP route matching, gRPC/GraphQL/tRPC, pub-sub across 8 languages. If you're building microservices, this matters more.
Round 4: Query Power and Agent UX#
| Tool | MCP Tools | Query Language | Unique Capability |
|---|---|---|---|
| Graphify | 7 | Natural language + BFS/DFS traversal | Graph community exploration |
| GitNexus | 17 | Specialized tool endpoints | Dedicated tool for every architecture question |
| CodeGraph | 1 | Natural language | One question in, full answer out |
| codebase-memory-mcp | 15 | Cypher + structured params + semantic vector | Arbitrary graph queries via Cypher |
This is where codebase-memory-mcp introduces something none of the others have: a Cypher query engine. Instead of being limited to pre-built tool endpoints, your agent can write arbitrary graph queries:
-- Find dead code (functions nobody calls)
MATCH (f:Function)
WHERE NOT EXISTS { (f)<-[:CALLS]-() }
RETURN f.name, f.file
LIMIT 20
-- Trace a 3-hop call chain
MATCH path = (a:Function)-[:CALLS*1..3]->(b:Function {name: 'validate'})
RETURN a.name, length(path)
-- Find the most-called functions (hotspots)
MATCH (f:Function)-[:CALLS]->(g)
RETURN g.name, count(f) AS callers
ORDER BY callers DESC
LIMIT 10
It also has embedded semantic search — Nomic embeddings compiled into the binary. No API key, no Ollama, no Docker. Ask "find code related to payment processing" and it returns semantically related functions using an 11-signal scoring system (TF-IDF, MinHash AST similarity, shared callees, type signatures, and more).
Winner depends on what you value:
- For arbitrary structural queries: codebase-memory-mcp (Cypher is a superpower)
- For agent simplicity: CodeGraph (one tool, always used)
- For maximum granularity: GitNexus (17 specialized endpoints)
Round 5: Multi-Repo and Team Use#
| Tool | Multi-Repo Support | Team Sharing |
|---|---|---|
| Graphify | Global graph registry. Merge multiple project graphs. | Commit graphify-out/ to git |
| GitNexus | Repository groups + Contract Registry. Cross-repo impact analysis. | .gitnexus/ per-repo with global registry |
| CodeGraph | Single project only. | None |
| codebase-memory-mcp | CROSS_* edges linking nodes across repos. Multi-galaxy 3D layout. | .codebase-memory/graph.db.zst committed to repo (zstd compressed) |
Winner: GitNexus for structured multi-repo workflows (Contract Registry, group sync, cross-repo blast radius). codebase-memory-mcp is strong here too — cross-repo edges are automatic, and the compressed graph artifact means teammates clone the repo and skip reindexing entirely. No merge conflicts thanks to auto-generated .gitattributes merge=ours.
Round 6: Visualization#
| Tool | Visualization Options |
|---|---|
| Graphify | Interactive vis.js HTML, D3 tree, SVG, Obsidian vault, Neo4j Cypher, GraphML, markdown wiki |
| GitNexus | Sigma.js + Graphology WebGL web UI, Cypher queries, wiki generation |
| CodeGraph | None — CLI only, designed for agents not humans |
| codebase-memory-mcp | 3D interactive graph explorer (embedded HTTP server at localhost:9749) |
Winner: Graphify for export diversity (Obsidian, Neo4j, Gephi, SVG — pick your tool). codebase-memory-mcp's 3D graph UI is a nice addition but only viewable in its own embedded server.
Round 7: Performance and Token Efficiency#
This is codebase-memory-mcp's strongest differentiator — and it has numbers to back it up.
| Tool | Token Efficiency | Indexing Speed (large codebase) | Research Backing |
|---|---|---|---|
| Graphify | 71.5x fewer tokens (benchmarked, 52-file corpus) | Minutes (LLM calls for non-code content) | Internal benchmark |
| GitNexus | Not benchmarked | Minutes (incremental after first run) | None |
| CodeGraph | 58% fewer tool calls; 23–64% token savings (benchmarked) | Seconds for incremental updates | Internal benchmark |
| codebase-memory-mcp | 120x on 5-query benchmark; 10x across 31 repos (preprint) | Linux kernel (28M LOC): 3 minutes | Research preprint (arXiv:2603.27277, 31 repos) |
Two data points tell the story. The tool's own benchmark: five structural queries that cost 412,000 tokens via grep exploration cost approximately 3,400 tokens through codebase-memory-mcp — a 120x reduction. The broader evaluation in their research preprint (arXiv:2603.27277): across 31 real-world repositories, 10x fewer tokens and 2.1x fewer tool calls with 83% answer quality vs. file-by-file exploration.
Indexing speed is impressive too. The full Linux kernel — 28 million lines of code across 75,000 files — indexes in 3 minutes on an Apple M3 Pro, producing 4.81 million nodes and 7.72 million edges. A typical Django project indexes in about 6 seconds.
Winner: codebase-memory-mcp. The research preprint gives confidence these aren't cherry-picked numbers — even the conservative 10x figure across 31 repos is well ahead of the field.
Round 8: Setup and Dependencies#
| Tool | Install Command | Runtime Dependencies | Setup Complexity |
|---|---|---|---|
| Graphify | uv tool install graphifyy | Python 3.10+, tree-sitter native bindings | Low — but needs Python environment |
| GitNexus | npx gitnexus analyze | Node.js 18+ | Low — but needs Node.js |
| CodeGraph | curl install script + codegraph init | Node.js or standalone binary | Very low |
| codebase-memory-mcp | curl install script | None — single static C binary | Minimal — zero dependencies |
Winner: codebase-memory-mcp. A single statically-linked binary with all 158 tree-sitter grammars, SQLite, embeddings, and compression libraries compiled in. No Python, no Node.js, no Docker, no language server processes. The install command auto-detects and configures 43 client surfaces (Claude Code, Cursor, Codex CLI, Gemini CLI, VS Code, Windsurf, and more).
# Install
curl -fsSL https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.sh | bash
# That's it. Restart your agent, then:
# "Index this project"
Updated Scoreboard#
| Round | Winner |
|---|---|
| Index Freshness | CodeGraph (2s real-time) > codebase-memory-mcp (5–60s auto) |
| Language Breadth | codebase-memory-mcp (158 languages) |
| Non-Code Content | Graphify (PDFs, images, video) |
| Dynamic Dispatch (frontend) | CodeGraph (callbacks, React re-render) |
| Cross-Service Patterns | codebase-memory-mcp (HTTP/gRPC/GraphQL/pub-sub) |
| Query Power | codebase-memory-mcp (Cypher + semantic search) |
| Multi-Repo | GitNexus (Contract Registry, group sync) |
| Visualization | Graphify (7+ export formats) |
| Token Efficiency | codebase-memory-mcp (120x best-case, 10x across 31 repos) |
| Zero-Dependency Setup | codebase-memory-mcp (static binary) |
Under the Hood: How codebase-memory-mcp Works#
The system operates in three stages: index everything into memory, dump to SQLite, then serve queries via MCP.
Key design decisions:
-
RAM-first pipeline — All source files are LZ4-compressed into memory. The graph accumulates in an in-memory buffer, then dumps to SQLite in a single atomic write. This is how it indexes the Linux kernel in 3 minutes — no disk I/O during the heavy computation phase.
-
Supervised worker subprocess — Indexing runs in a fork+exec'd child process. If any of the 158 grammar parsers crashes on a malformed file, only the child dies. The MCP server survives and reports the failure. This matters when you're parsing 158 languages — some grammars will hit edge cases.
-
Hybrid LSP — Goes beyond tree-sitter for 10 languages. A lightweight C implementation of type-resolution algorithms resolves cross-module chains that pure AST parsing cannot follow: Python dataclasses, TypeScript generics and JSX dispatch, Go interface satisfaction, Rust trait bounds, Java class hierarchies.
-
Fused Aho-Corasick — Multiple pattern searches (route detection, channel detection, import resolution) are batched into a single automaton pass over each file. One scan instead of three.
-
11-signal similarity — Rather than relying on one similarity metric, it combines TF-IDF, MinHash AST trigrams, shared callees, shared types, module proximity, decorator patterns, control flow profiles, data flow approximation, graph diffusion, and complexity profiles. Vectors stored in 4-bit quantized format (6x memory savings).
What It Does That None of the Others Do#
These capabilities are unique to codebase-memory-mcp:
-
Cypher query engine — A custom read-only openCypher implementation. Not just pre-built tool endpoints — your agent can write arbitrary graph queries with MATCH, WHERE, variable-length paths, aggregations, and 25+ built-in functions. Find dead code, trace call chains, detect hotspots, all with one flexible language.
-
Embedded semantic search — Nomic
nomic-embed-codeembeddings (768d, int8) compiled into the binary. Semantic code search without an API key, without Ollama, without Docker. Ask "find code related to authentication" and get structurally relevant results. -
Architecture Decision Records (ADR) — Persist architectural decisions ("we chose PostgreSQL over MongoDB because...") that survive across sessions. Your agent remembers why decisions were made.
-
Runtime trace ingestion — Feed real traffic data via
ingest_tracesto validate that static HTTP_CALLS edges match actual runtime behavior. Bridges the gap between what the code says and what it does. -
158 languages from one binary — No grammar downloads, no
npm install, no setup per language. Haskell, Zig, Perl, Objective-C, Lua — they all just work. -
Research-backed claims — A research preprint with reproducible benchmarks across 31 repositories. Not marketing numbers — published methodology and results you can verify.
-
SLSA Level 3 supply chain — Cryptographic build provenance, Sigstore cosign signatures, VirusTotal scanning (70+ AV engines), and CodeQL SAST on every release. The most security-conscious release pipeline of the four tools.
Honest Limitations#
Every tool has trade-offs. Here's where codebase-memory-mcp falls short:
| Limitation | Detail | Who Should Care |
|---|---|---|
| No real-time file watching | Git-polling at 5–60s intervals, not OS-level filesystem events. CodeGraph's 2-second sync is faster. | Developers who edit and immediately query |
| No non-code content | Cannot index PDFs, images, video, or documents. Graphify is the only tool that does. | Teams with architecture diagrams or research docs |
| No callback/registrar dispatch | Doesn't trace CodeGraph-style callback pairs matched by shared field names. | Frontend-heavy projects with complex callback patterns |
| RAM-hungry during indexing | The RAM-first pipeline needs headroom for large codebases. Mitigated by supervised subprocess and CBM_MEM_BUDGET_MB cap. | Constrained environments (small containers) |
| Single-threaded query dispatch | Under heavy concurrent querying from multiple agents, queries are processed sequentially. | Teams with many agents hitting one server |
| Hybrid LSP covers 10 languages | Remaining 148 languages fall back to syntactic resolution — cross-module type chains may not resolve. | Codebases primarily in uncovered languages |
| Static analysis ceiling | Same as all four tools — no runtime behavior, no reflection, no eval(). Use a debugger for runtime bugs. | Everyone (fundamental limitation) |
Which One Should You Pick? (Updated)#
"I want my AI agent to be smarter with zero effort and zero dependencies"#
codebase-memory-mcp. One binary, zero dependencies, 158 languages, automatic sync. The token savings alone justify the 3-minute setup.
curl -fsSL https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.sh | bash
# Restart your agent → "Index this project" → done
"I need the fastest possible sync — edits reflected in under 2 seconds"#
CodeGraph. Native OS file watching is genuinely real-time. If immediate freshness matters more than language breadth, this is your tool.
curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh
codegraph install && codegraph init
"My team works across multiple services with API contracts"#
GitNexus. Repository groups, Contract Registry, cross-repo blast radius analysis. Nothing else does structured multi-repo workflows this well.
npx gitnexus analyze && npx gitnexus setup
"My project includes docs, PDFs, research papers, and architecture diagrams"#
Graphify. The only tool that connects non-code knowledge to your code graph.
uv tool install graphifyy && graphify install
"I want to write arbitrary structural queries, not just use pre-built endpoints"#
codebase-memory-mcp. The Cypher engine lets your agent ask any structural question expressible as a graph query. Combined with semantic search, it's the most powerful query layer of the four.
Decision Flowchart#
Final Verdict#
After adding codebase-memory-mcp to the comparison, the landscape shifts. It doesn't win every round — but it wins the ones that matter most for large-scale, multi-language, production codebases: language coverage, token efficiency, query power, and cross-service intelligence.
Pick codebase-memory-mcp if you want the most structurally complete solution: 158 languages, Cypher queries, semantic search, cross-service linking, peer-reviewed efficiency — all from a single binary with zero dependencies.
Pick CodeGraph if you prioritize instant sync and frontend-specific dynamic dispatch (callbacks, React re-render edges).
Pick GitNexus if you need structured multi-repo workflows with contract registries and team-wide group sync.
Pick Graphify if your project includes non-code knowledge that should connect to your code graph.
The good news: they don't conflict. You can run more than one. The real question is — why is your AI agent still flying blind?