CodeGraphContext
Python MCP server and CLI toolkit that indexes codebases into a graph database using Tree-sitter parsing. Enables relationship-aware code queries (callers, dependencies, blast radius, dead code) without reading every file. GitHub:CodeGraphContext/CodeGraphContext — v0.4.9, ~3.2k stars.
Architecture
- KuzuDB (default) — embedded, all platforms, no setup
- FalkorDB Lite — Unix only; faster for large repos
- Neo4j — enterprise/Docker; persistent across machine restarts
compile_commands.json (generated by cmake/bear). C# needs .csproj. All other languages work without it.
Supported Languages (20)
Python, JavaScript, TypeScript, TSX, Java, C, C++, C#, Go, Rust, Ruby, PHP, Swift, Kotlin, Dart, Perl, Lua, Scala, Haskell, Elixir.Install + Setup
.cgcignore (gitignore syntax) controls exclusions — place at repo root.
MCP Tools
Query Routing Table
Use this to decide between grep, CGC, and qmd:
Grep only finds definitions. CGC finds relationships. Never substitute grep for relationship queries.
When to Index (Decision Threshold)
Index with CGC if ANY of:- 2+ distinct source languages in the repo
-
100 source files
- Infra files present (Dockerfile, docker-compose, CI YAML, Terraform, k8s)
claude-init skill Step 0.5.
Persistence Model
Flag-first state machine
CGC status is recorded in.claude/profile.md. Claude always checks this flag first — before running any bash commands or asking any questions:
disabled is a permanent no. To override: user must explicitly say “check CGC for this repo”.
Relation to Existing Wiki
- Agent Harness — CGC is a knowledge tool that improves harness quality by reducing blind grep loops
- Local Wiki RAG: LightRAG Graph Stack — complementary to qmd (wiki/docs) and LightRAG (concept graph); CGC covers code graph
- Context Degradation Patterns — CGC reduces context distraction by returning precise relationship facts instead of raw file dumps
- Tool Design for Agents —
list_indexed_repositoriesas idempotency gate follows agent-tool design principles