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#

DimensionDetail
Languages158 via vendored tree-sitter + Hybrid LSP type resolution for 10 (Python, TS/JS, Go, Rust, Java, C/C++, C#, PHP, Kotlin, Perl)
ContentCode + infrastructure-as-code (Dockerfiles, K8s manifests, Kustomize overlays)
StorageSQLite + FTS5 full-text search + vector indexes
Query15 MCP tools + read-only Cypher engine + semantic vector search
LicenseMIT
One-linerThe 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#

ToolFreshness MechanismUser Action Required
GraphifyManual --update or git hooksYes — run command or set up hooks
GitNexusManual incremental / PostToolUse staleness hooksYes — re-run after changes
CodeGraphNative OS file watching (FSEvents/inotify). 2-second debounce.None — fully automatic
codebase-memory-mcpBackground 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?#

ToolCode LanguagesNon-Code Content
Graphify36 (tree-sitter)Docs, PDFs, images, video/audio, YouTube, Google Workspace
GitNexus14 (tree-sitter)Markdown sections, API routes, ORM models, DI patterns
CodeGraph20+ (tree-sitter)Code only — but understands framework routing and dynamic dispatch
codebase-memory-mcp158 (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?

PatternGraphifyGitNexusCodeGraphcodebase-memory-mcp
Callbacks (registrar/dispatcher)NoNoYesNo
EventEmitter (.on/.emit)NoNoYesYes (EMITS/LISTENS_ON, 8 languages)
React setState/JSX dispatchNoNoYes (re-render edges)Partial (JSX → component via Hybrid LSP, no re-render flow)
Interface/abstract dispatchNoYesNoYes (Hybrid LSP type resolution)
Framework routingNoYesYes (22 frameworks)Yes (HTTP/gRPC/GraphQL/tRPC)
Cross-service HTTP callsNoYes (route_map: route → handler → consumer; cross-repo via Contract Registry)NoYes (route ↔ call-site matching with confidence scoring)
Channel/pub-sub patternsNoNoNoYes (Socket.IO, EventEmitter, 8 langs)
Dependency injectionNoYesNoNo
Swift ↔ Objective-C bridgingNoNoYesNo

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#

ToolMCP ToolsQuery LanguageUnique Capability
Graphify7Natural language + BFS/DFS traversalGraph community exploration
GitNexus17Specialized tool endpointsDedicated tool for every architecture question
CodeGraph1Natural languageOne question in, full answer out
codebase-memory-mcp15Cypher + structured params + semantic vectorArbitrary 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#

ToolMulti-Repo SupportTeam Sharing
GraphifyGlobal graph registry. Merge multiple project graphs.Commit graphify-out/ to git
GitNexusRepository groups + Contract Registry. Cross-repo impact analysis..gitnexus/ per-repo with global registry
CodeGraphSingle project only.None
codebase-memory-mcpCROSS_* 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#

ToolVisualization Options
GraphifyInteractive vis.js HTML, D3 tree, SVG, Obsidian vault, Neo4j Cypher, GraphML, markdown wiki
GitNexusSigma.js + Graphology WebGL web UI, Cypher queries, wiki generation
CodeGraphNone — CLI only, designed for agents not humans
codebase-memory-mcp3D 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.

ToolToken EfficiencyIndexing Speed (large codebase)Research Backing
Graphify71.5x fewer tokens (benchmarked, 52-file corpus)Minutes (LLM calls for non-code content)Internal benchmark
GitNexusNot benchmarkedMinutes (incremental after first run)None
CodeGraph58% fewer tool calls; 23–64% token savings (benchmarked)Seconds for incremental updatesInternal benchmark
codebase-memory-mcp120x on 5-query benchmark; 10x across 31 repos (preprint)Linux kernel (28M LOC): 3 minutesResearch 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#

ToolInstall CommandRuntime DependenciesSetup Complexity
Graphifyuv tool install graphifyyPython 3.10+, tree-sitter native bindingsLow — but needs Python environment
GitNexusnpx gitnexus analyzeNode.js 18+Low — but needs Node.js
CodeGraphcurl install script + codegraph initNode.js or standalone binaryVery low
codebase-memory-mcpcurl install scriptNone — single static C binaryMinimal — 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#

RoundWinner
Index FreshnessCodeGraph (2s real-time) > codebase-memory-mcp (5–60s auto)
Language Breadthcodebase-memory-mcp (158 languages)
Non-Code ContentGraphify (PDFs, images, video)
Dynamic Dispatch (frontend)CodeGraph (callbacks, React re-render)
Cross-Service Patternscodebase-memory-mcp (HTTP/gRPC/GraphQL/pub-sub)
Query Powercodebase-memory-mcp (Cypher + semantic search)
Multi-RepoGitNexus (Contract Registry, group sync)
VisualizationGraphify (7+ export formats)
Token Efficiencycodebase-memory-mcp (120x best-case, 10x across 31 repos)
Zero-Dependency Setupcodebase-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.

Rendering diagram...

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:

  1. 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.

  2. Embedded semantic search — Nomic nomic-embed-code embeddings (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.

  3. Architecture Decision Records (ADR) — Persist architectural decisions ("we chose PostgreSQL over MongoDB because...") that survive across sessions. Your agent remembers why decisions were made.

  4. Runtime trace ingestion — Feed real traffic data via ingest_traces to validate that static HTTP_CALLS edges match actual runtime behavior. Bridges the gap between what the code says and what it does.

  5. 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.

  6. Research-backed claims — A research preprint with reproducible benchmarks across 31 repositories. Not marketing numbers — published methodology and results you can verify.

  7. 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:

LimitationDetailWho Should Care
No real-time file watchingGit-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 contentCannot index PDFs, images, video, or documents. Graphify is the only tool that does.Teams with architecture diagrams or research docs
No callback/registrar dispatchDoesn't trace CodeGraph-style callback pairs matched by shared field names.Frontend-heavy projects with complex callback patterns
RAM-hungry during indexingThe 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 dispatchUnder heavy concurrent querying from multiple agents, queries are processed sequentially.Teams with many agents hitting one server
Hybrid LSP covers 10 languagesRemaining 148 languages fall back to syntactic resolution — cross-module type chains may not resolve.Codebases primarily in uncovered languages
Static analysis ceilingSame 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#

Rendering diagram...

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?