graphify-ts: Local MCP server cuts Claude Code PR review tokens from 63K to 8.7K

✍️ OpenClawRadar📅 Published: May 5, 2026🔗 Source
graphify-ts: Local MCP server cuts Claude Code PR review tokens from 63K to 8.7K
Ad

If you've used Claude Code on a real codebase, you've seen the problem: every question triggers 8-10 sequential tool calls (glob, grep, read, read, read) to build context from scratch. Input tokens pile up, latency drags, and the agent rediscovers the same structure each time. graphify-ts is a free, open-source MCP server that pre-indexes your code into a local knowledge graph, so Claude makes a single retrieve call instead.

How it works

At index time, graphify-ts parses your code with tree-sitter AST, extracts structural relationships (files, functions, classes, calls, imports), runs Louvain community detection to group related modules, indexes with BM25, and optionally re-ranks with a local ONNX model. The resulting graph is served via MCP stdio — fully local, no data leaves your laptop. The default core profile exposes 6 tools to keep session overhead low (about 5K tokens); you can opt into the full 21-tool surface with GRAPHIFY_TOOL_PROFILE=full.

Benchmarks you can verify

The repo includes a verify.sh script that re-derives all numbers from committed evidence. Results measured on a real production NestJS + Next.js codebase (1,268 files) with Claude Opus 4.7:

  • Single code query: 9 tool calls → 3, 615,190 input tokens → 233,508 (2.6× fewer), latency 96 sec → 35 sec (2.8× faster). Both from Claude's --output-format json usage field.
  • 36-file PR review: Prompt tokens dropped from 63,024 to 8,690 (7.25× smaller). Same reviewer, same diff, same review depth — both runs flagged the same hotspots.
  • Multi-repo question across 3 repos: Estimated naive prompt ~1.5M tokens (wouldn't fit any window) vs. 2,800 tokens with graphify-ts. The author notes this is a structural estimate, not a sent prompt.
Ad

Install & use

npm install -g @mohammednagy/graphify-ts
cd your-project
graphify-ts generate .
graphify-ts claude install

Also works with Cursor, Copilot, Gemini CLI, Aider, OpenCode via <agent> install.

Trade-offs to know

  • Cold-start cost: First session costs about 13% more than no-graph baseline due to tool-schema overhead (~5K tokens). Multi-question sessions amortize this.
  • Language support: Deep extraction is best on JS/TS with framework-aware passes (Express, NestJS, Next.js, Redux Toolkit, React Router). Python/Ruby/Go/Java/Rust use plain tree-sitter AST. C/Kotlin/C#/Scala/PHP/Swift/Zig use a generic structural extractor.
  • Limits: This is a structural map for an agent, not a full program-analysis database. Heavily meta-programmed routes fall back to the base AST.

The author is actively seeking counterexamples — repos where structural slicing breaks. MIT licensed, requires Node 20+.

📖 Read the full source: r/ClaudeAI

Ad

👀 See Also