Skip to main content

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

Parsing: Tree-sitter — fast, grammar-based, language-specific. No compiler required for most languages. Graph DB options:
  • KuzuDB (default) — embedded, all platforms, no setup
  • FalkorDB Lite — Unix only; faster for large repos
  • Neo4j — enterprise/Docker; persistent across machine restarts
SCIP optional: C/C++ needs 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)
Triggered automatically by the 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