Skip to main content
Glama
mohansagark
by mohansagark

claude-graph

A local knowledge graph for Claude Code — structural code intelligence with zero network calls.

PyPI version PyPI downloads CI Python Platform License Network calls


Answer structural questions about your codebase in a single MCP tool call — without sending a single byte of code to the cloud.


Why claude-graph?

Claude Code answers structural questions ("what calls this?", "what breaks if I change this file?") by reading source files into context. On any non-trivial codebase that means:

  • Hundreds of files that may not fit in the context window

  • Thousands of tokens spent on code Claude won't actually use

  • No answer at all for repos larger than the context window

claude-graph solves this by building a persistent call graph (functions → calls → functions, files → imports → files, tests → tests_for → source) stored in a local SQLite database. Claude issues a single MCP tool call and gets back only the relevant nodes and edges — typically 7× to 236× fewer tokens than reading the source files directly.

Everything happens on your machine. No embeddings, no cloud API, no telemetry — ever.


Related MCP server: better-code-review-graph

Real benchmark — Django (3,040 files)

Built with claude-graph build on a shallow clone of Django main.

Build time:  17 seconds
Files:       3,040
Nodes:       45,096   (functions + classes + modules)
Edges:       938,763  (calls + imports + tests_for)

Query

Tokens — naive (send matching files)

Tokens — claude-graph

Reduction

callers_of HttpResponse

112,991

15,455

7× less

callees_of dispatch

92,539

3,143

29× less

callers_of authenticate

46,032

5,278

8× less

search permission

155,915

659

236× less

Dumping the full Django source naively = 1,475,429 tokens — 7.4× Claude's 200k context window. Claude cannot answer structural questions about Django at all without a tool like this.


Quick start

# 1. Install
pip install claude-graph

# 2. Wire it into your project (writes .mcp.json + .claude/skills/)
cd /path/to/your/project
claude-graph install

# 3. Build the graph
claude-graph build

Restart Claude Code (or run /mcp to confirm claude-graph is connected), then ask:

"What calls save() in this repo?" "What breaks if I change auth/middleware.py?" "Is parse_file covered by tests?"


Features

🔍 Structural queries

Ask Claude things it couldn't answer without reading the entire repo:

Query pattern

What it returns

callers_of NAME

Every function that calls NAME

callees_of NAME

Every function that NAME calls

imports_of NAME

Every file that imports NAME

tests_for FILE

Test files linked to FILE

file_summary FILE

All symbols defined in FILE

search KEYWORD

Fuzzy search over all function/class names

📡 Impact radius

Changed a file? Get the blast radius instantly:

claude-graph query callers_of parse_file
# or let Claude Code call get_impact_radius_tool automatically

🗺️ Interactive visualization

claude-graph viz                        # whole graph (capped at 500 nodes)
claude-graph viz --symbol HttpResponse  # direct neighborhood of a symbol
claude-graph viz --impact db/models.py  # visual blast radius of a file
claude-graph viz --max-nodes 0          # uncapped (may be slow on large repos)

The viz renders a self-contained HTML file — no server, works fully offline. Features:

  • Force-directed D3 layout with drag, zoom, and pan

  • Click any node to highlight its direct neighborhood + see file/line

  • Filter panel to toggle node kinds (function / class / module) and edge kinds (calls / imports / tests_for) live

  • Translucent file-cluster hulls grouping nodes that share a file

  • Search box to find any node by name

👁️ File watcher

pip install "claude-graph[watch]"
claude-graph watch   # auto-rebuilds incrementally on every file change

🩺 Health check

claude-graph doctor

Verifies grammars, FTS5, git access, MCP wiring, and graph existence — with a pass/fail table and exit code.


Zero network calls

Built for corporate and regulated environments with one hard requirement: everything stays on your machine.

  • No embeddings, no vector index, no model downloads

  • No cloud API calls — not even for tokenization

  • No telemetry, no daemon, no background process

  • No home-directory writes — everything lives inside your repo (.claude-graph/, .mcp.json, .claude/skills/)

  • Nothing runs automatically — you or Claude Code call build_or_update_graph explicitly

See tests/test_no_network.py for the automated proof: a full build + query + viz + MCP startup cycle with outbound sockets disabled.


MCP tools (used by Claude Code automatically)

Tool

What it does

build_or_update_graph

Full build if no graph exists, incremental update otherwise

get_graph_stats

Node / edge / file counts and detected languages

query_graph_tool

callers_of / callees_of / imports_of / tests_for / file_summary

get_impact_radius_tool

Blast radius of a set of changed files

search_nodes_tool

Keyword search over function/class names and signatures

render_graph_tool

Render the graph (or a scoped neighborhood) to a local HTML file


CLI reference

Command

What it does

claude-graph build

Full parse of every git-tracked file

claude-graph update

Re-parses only files changed since the last build

claude-graph status

Node / edge / file counts (--json for machine-readable output)

claude-graph install

Writes .mcp.json and .claude/skills/ for this repo

claude-graph serve

Starts the MCP server (stdio) — Claude Code launches this itself

claude-graph viz

Interactive HTML graph, opens in browser

claude-graph watch

Auto-rebuild on file change (requires claude-graph[watch])

claude-graph doctor

Health check with pass/fail table

claude-graph query PATTERN TARGET

Run a structural query from the CLI

claude-graph search QUERY

Keyword search from the CLI

Every command accepts --repo PATH to target a repo other than $CWD.
status, install, viz, doctor, query, and search accept --json.


Supported languages

31 built in. Powered by tree-sitter-language-pack which bundles 306 grammars — add any of them with a single .claude-graph/languages.toml entry, no code change needed.

Language

Extensions

Python

.py

JavaScript

.js .jsx .mjs .cjs

TypeScript

.ts

TSX

.tsx

Go

.go

Rust

.rs

Java

.java

C#

.cs

Ruby

.rb

C

.c .h

C++

.cpp .cc .cxx .hpp .hh

Swift

.swift

Kotlin

.kt .kts

Scala

.scala .sc

PHP

.php .phtml

Dart

.dart

Elixir

.ex .exs

Bash / Zsh

.sh .bash .zsh

Lua

.lua

Zig

.zig

Dockerfile

Dockerfile .dockerfile

HCL / Terraform

.tf .hcl

Nix

.nix

CMake

CMakeLists.txt .cmake

Solidity

.sol

CUDA

.cu .cuh

R

.r .R

Julia

.jl

Gleam

.gleam

Cairo

.cairo

Adding a language: drop a .claude-graph/languages.toml into your repo. See claude_graph/default_languages.toml for the schema (extensions, grammar name, node types for functions/classes/imports/calls).


Install options

pip install claude-graph

# With file-watching support
pip install "claude-graph[watch]"

Docker

docker pull ghcr.io/mohansagark/claude-graph:latest
docker run --rm -v "$PWD:/repo" ghcr.io/mohansagark/claude-graph build
docker run --rm -v "$PWD:/repo" ghcr.io/mohansagark/claude-graph viz --symbol MyClass

From source

git clone https://github.com/mohansagark/claude-graph.git
cd claude-graph
pip install -e .

From a release asset (no PyPI)

Each GitHub Release ships a wheel as a downloadable asset:

pip install https://github.com/mohansagark/claude-graph/releases/download/v0.2.3/claude_graph-0.2.3-py3-none-any.whl

Requirements

  • Python 3.11+

  • git

  • macOS, Linux, or Windows


How call resolution works

  • A calls edge's source is always a function-kind node — only functions/methods make calls.

  • A calls edge's target prefers a function match; if none exists, falls back to a class match (instantiation, e.g. Foo()).

  • One edge per call site — if bar() is called twice, you get two edges. Call frequency is preserved.

  • Cross-file resolution is name-based: a call to save() matches every function named save in the graph. This is a deliberate precision/recall trade-off — better to surface too many candidates for Claude to disambiguate than to miss a real caller.


Known limitations

  • Name-based call resolution — cross-file calls match by name only, not by scope. Highly common names (save, get, run) produce over-broad results on large repos.

  • tests_for linking — naming convention + imports only (test_foo.pyfoo.py, foo.spec.tsfoo.ts). Tests that don't follow a convention aren't linked.

  • Import resolution — best-effort path matching, not real module resolution. Won't follow tsconfig.json path aliases or Python namespace packages.

  • Incremental edge re-linkingclaude-graph update only re-links edges for changed files. Moving a symbol to another file keeps stale cross-file edges until the next full claude-graph build.


Contributing

git clone https://github.com/mohansagark/claude-graph.git
cd claude-graph
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

Releasing (maintainers)

Bump version in pyproject.toml, then cut a GitHub Release. Publishing the release triggers .github/workflows/publish.yml which uploads to PyPI via OIDC trusted publishing and pushes the Docker image to GHCR — no API tokens stored in this repo.


License

MIT © Mohansagar Killamsetty

A
license - permissive license
-
quality - not tested
A
maintenance

Maintenance

Maintainers
Response time
2dRelease cycle
6Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    A
    maintenance
    Code dependency graph and AI context engine. 10 MCP tools that give Claude, Cursor, and any MCP client full codebase context — impact analysis, dependency tracing, architecture summaries, and interactive arc diagram visualization. Supports TypeScript, JavaScript, Python, and Go.
    Last updated
    24
    1,207
    59
    Business Source 1.1
  • A
    license
    B
    quality
    A
    maintenance
    Knowledge graph for token-efficient code reviews. Builds a structural map of your codebase with Tree-sitter, tracks changes incrementally, and gives AI agents precise context via MCP tools. Features fixed multi-word search, qualified call resolution, dual-mode embedding (ONNX local + LiteLLM cloud), and output pagination.
    Last updated
    7
    65
    MIT
  • A
    license
    -
    quality
    F
    maintenance
    Living typed knowledge graph for software projects, exposed over MCP so coding assistants can capture and query modules, capabilities, flows, events, rules and decisions across sessions. SQLite-backed, schema-validated, ships as a Claude Code plugin.
    Last updated
    MIT

View all related MCP servers

Related MCP Connectors

  • AI Agent with Architectural Memory. Impact analysis (free), tests and code from the graph (pro).

  • Cross-agent artifact workspace with provenance across Claude Code, Codex, Cursor, LangGraph.

  • Give your AI agent a persistent map of your project's structure, dependencies, and bugs.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mohansagark/claude-graph'

If you have feedback or need assistance with the MCP directory API, please join our Discord server