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

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 jsonusage 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.
Install & use
npm install -g @mohammednagy/graphify-ts
cd your-project
graphify-ts generate .
graphify-ts claude installAlso 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
👀 See Also

Grape Root Tool Reduces Claude Code Token Usage by Caching Repository Context
A free experimental tool called Grape Root addresses redundant token consumption in Claude Code by maintaining lightweight state about previously explored repository files, preventing unnecessary re-reads of unchanged files during follow-up prompts.

Claude Compact Guard Plugin Uses New PostCompact Hook to Preserve Context
A developer has released claude-compact-guard, a plugin that automatically saves critical context before Claude's /compact command destroys it, then reinjects everything after. It uses Anthropic's new PostCompact hook released 4 days ago.

HolyClaude: Docker Container for Claude Code with Browser UI and Headless Chromium
HolyClaude is an open-source Docker container that packages Claude Code CLI with a browser UI, headless Chromium, and additional AI coding tools. Setup requires only docker compose up and provides access at localhost:3001.

agent-data: Structured Web Data for OpenClaw Agents, 70% Cheaper Than Browser Automation
agent-data provides pure Python API endpoints for X, Reddit, flights, and job listings, designed for AI agents like OpenClaw—no browser automation needed. Benchmark shows significant cost savings and reliability improvements.