Skip to main content
Glama

ckg — deterministic code knowledge graph for coding agents

ckg turns a repository into a deterministic, local-first knowledge graph — files, classes, functions, their containment, references, and functional relationships — and serves it to coding agents over MCP. Instead of dumping your repo into a prompt, an agent navigates the graph: it asks "where does auth begin?" and gets the entry point, the call path, and just the source that matters.

  • Deterministic. The same code always produces a byte-identical graph (two-hash Merkle design). No sampling, no drift.

  • Zero-config. No network, no auth, no API key, no model download. Parsing is tree-sitter compiled to WASM — plain Node, all platforms.

  • Self-healing. There is no build step to remember. Every query triggers an incremental refresh: unchanged files are reused via content hashes, so a clean tree costs a hash sweep, not a re-parse.

  • Committable cache. Everything in .ckg/ is keyed by content hash. Commit it and every clone gets a warm graph — including LLM summaries one contributor paid for once.

  • Local-first, zero egress. Nothing leaves your machine. The one optional outbound step (summaries) goes through your own Claude CLI.

Quickstart

Claude Code

ckg install

Run inside your repo — this writes .mcp.json (and configs for any other detected hosts). Or manually:

claude mcp add ckg -- npx -y ckg mcp

Cursor / Windsurf

ckg install detects them, or add to .cursor/mcp.json:

{ "mcpServers": { "ckg": { "command": "npx", "args": ["-y", "ckg", "mcp"] } } }

Codex CLI

ckg install writes .codex/config.toml, or:

codex mcp add ckg -- npx -y ckg mcp

That's it. The first query builds the graph (seconds on a mid-size repo); every later query self-heals incrementally.

Related MCP server: codeembed

Optional enhancements

ckg summarize   # LLM summaries on every node, via your Claude CLI (cached, resumable)
ckg embed       # local embeddings for semantic search (downloads a small ONNX model)

Both write into .ckg/, keyed by content hash. Commit .ckg/ and your whole team — and every fresh clone — inherits the summaries and vectors without re-running anything. (.ckg/models/ is machine-local and gitignored.)

CLI

The same engine the agents use, from your terminal:

ckg locate "where do we resolve import aliases"   # ranked hits + snippet of the top hit
ckg search "rate limiting"                        # hybrid symbol/lexical/semantic search
ckg map                                           # repo map ranked by PageRank
ckg build                                         # explicit (re)build — optional, for CI / prepaying

ckg --help for everything, --json on any query for machine-readable output.

MCP tools

locate, entry_point, search, get_context, get_source, neighbors, expand, get_repo_map, pack_neighborhood, get_minimal_context. Summaries are cheap; source is a deliberate separate call — the agent reads the map before it reads the territory.

How it works

Discovery → tree-sitter parse → containment tree → two-hash Merkle (identity + content) → reference resolution (pluggable per-language resolvers) → graph in .ckg/graphs/self/graph.json (canonical JSON, stable key across clones). Summaries and embeddings are separate content-hash-keyed caches layered on top. See plan/ for the full design docs.

Languages: TypeScript/TSX, JavaScript, Python, Go, Rust, Java, C, C++, C#. Adding one means adding a tree-sitter grammar + a small language spec (queries for definitions, imports, entries) — the core is language-agnostic.

Development

npm install
npm run typecheck
npm run build            # tsup → dist/, `node bin/ckg.mjs`
npm run test:determinism # byte-identical rebuild — the flagship invariant
npm run test:m3          # incrementality
npm run test:m6          # retrieval + MCP

The former Electron desktop shell is parked under legacy/electron/; its React graph explorer will return as ckg ui (localhost web page). Deferred designs (dominator-based entry points beyond what's shipped, graph version control, graph-driven review) live in plan/.

License

MIT

Available Tools

10 tools
entry_pointA

Where does a feature BEGIN? Returns the entry/boundary that dominates the feature (route handler, CLI command, main, or exported API) — its file is where to start reading — plus the call path down through it. Use for "where do I start to understand X"; for "where is symbol X defined" use locate.

Inputs: query (required), k.

expandA

BFS up to k hops along ONE edge family (e.g. calls) from a node.

Inputs: id (required), edge_type (required), k.

get_contextB

A node's generated summary/context (title, summary, description, signature, domain, keywords). Pass id for one, or ids to fetch several in one turn.

Inputs: id, ids.

get_minimal_contextA

Optional ~100-token orientation: stats + the top nodes by importance. Call only if you want a quick lay of the land — it is NOT a prerequisite for the other tools.

Inputs: no named parameters.

get_repo_mapA

The routing table: file/package summaries ranked by PageRank, packed to a token budget. Reach for it to orient on an unfamiliar repo.

Inputs: budget.

get_sourceA

Raw source for a node — the deliberate 'expensive' read. locate already includes a snippet of the top hit, so you often don't need this. Pass id for one, or ids for several.

Inputs: id, ids.

locateA

Find where a feature or symbol lives in ONE call: ranked hits with their summaries, plus a source snippet of the top hit to confirm. Start here for "where is X" / "where do we do Y" — usually all you need; no setup call required first.

Inputs: query (required), k.

neighborsC

All adjacent nodes of an id, grouped by edge family (calls, imports, contains, related, …).

Inputs: id (required).

pack_neighborhoodC

A node's k-hop dependency neighborhood, source packed in topological order to a token budget (the single-shot static fallback).

Inputs: id (required), hops, budget.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 10 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: locate finds definitions, entry_point finds starting points, search is hybrid, get_context retrieves summaries, get_source retrieves raw code, neighbors returns adjacent nodes, expand does BFS, get_repo_map gives an overview, pack_neighborhood packs dependency context, and get_minimal_context offers a quick orientation. No two tools are easily confused.

    Naming Consistency4/5

    Tool names mostly follow a verb-based or get_ prefix pattern (locate, search, expand, get_context, get_source, get_repo_map). However, entry_point, neighbors, and pack_neighborhood deviate from the verb-first pattern, causing minor inconsistency. Still, all names are descriptive and lowercase.

    Tool Count5/5

    With 10 tools, the server is well-scoped for navigating a code knowledge graph. Each tool serves a specific need in the exploration workflow, from quick lookup to deep context gathering, without redundancy.

    Completeness4/5

    The toolset covers major aspects of codebase exploration: finding symbols (locate), entry points (entry_point), searching (search), retrieving context/source (get_context, get_source), graph traversal (neighbors, expand), overview (get_repo_map), and packing context (pack_neighborhood). A minor gap might be a dedicated tool for listing all entry points or finding usages, but the existing tools largely compensate.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      C
      maintenance
      Local-first codebase intelligence engine providing AI coding agents with a typed MCP toolset for understanding and navigating code repositories.
      100
      54
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Embeds your codebase into a local vector and graph database and exposes it as an MCP tool, enabling AI assistants to perform fast semantic search over your code using Graph RAG.
      4
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Indexes a Python/JS/TS repository into a local SQLite knowledge graph so agents can trace callers, callees, imports, subclasses and covering tests, measure impact radius, rank diff risk, and summarize architecture without grepping files. Exposes these queries as MCP tools alongside an equivalent CLI, with no daemon, embeddings, or network access.
      10
      MIT