ts-review-graph

ts-review-graph

Enables Claude Code to query a TypeScript dependency graph and retrieve the minimal set of files needed for code review, implementation, or debugging.

Category
访问服务器

README

ts-review-graph

CI npm License: MIT Node.js

Build a TypeScript dependency graph in SQLite and tell Claude Code (via MCP) the minimal file set to read before any code review, implementation, or debugging session.

日本語: TypeScript プロジェクトの依存グラフを SQLite に構築し、コードレビュー・実装・デバッグ前に「読むべき最小ファイルセット」を Claude Code (MCP) に伝えるツール。

Why?

Claude Code reads too many files. It grabs large files one after another and stuffs unrelated code into its context.

ts-review-graph pre-builds the project's dependency graph and instantly computes the blast radius (impact surface) of changed files — so Claude only reads what matters.

Real-world benchmark (manako project)

From BENCHMARK.md:

Metric Baseline ts-review-graph Reduction
Read tool calls 14 3 −79%
File content bytes 219,139 58,583 −73%
Estimated tokens ~54,784 ~14,645 −73%

Graph size: 1,191 nodes / 1,400+ edges (Cloudflare Workers monorepo)

Requirements

  • Node.js 20+

Installation

Single tsconfig

npx @elchika-inc/ts-review-graph@latest install --tsconfig tsconfig.json

Config is saved to .ts-review-graph/config.json, MCP server is registered in .mcp.json, and usage instructions are appended to CLAUDE.md. Restart Claude Code and the MCP server connects automatically.

Monorepo (multiple tsconfigs)

npx @elchika-inc/ts-review-graph@latest install \
  --tsconfig apps/api/tsconfig.json \
  --tsconfig apps/web/tsconfig.app.json \
  --tsconfig apps/worker/tsconfig.json

Multiple tsconfigs are merged into a single unified graph (tested with 1,191+ nodes across layers).

Usage

In Claude Code (automatic)

Claude calls get_minimal_context automatically before reading source files:

get_minimal_context(["src/routes/monitors.ts"], "implement")

Example output (implement mode, apps/web + apps/api):

Changed: src/routes/monitors.ts

── Files affected (REVERSE depth=3) ──
  1. src/routes/services.ts   [IMPORTS_FROM]

── Files to change together (FORWARD depth=1) ──
  1. src/env.ts               [direct import]
  2. src/lib/schemas.ts       [direct import]
  3. src/lib/format.ts        [direct import]
  4. packages/db/src/index.ts [direct import]

SKIP: 1170 other files — not in blast radius

CLI commands

Command Description
npx @elchika-inc/ts-review-graph@latest install --tsconfig <path> Setup + initial build + register MCP + append CLAUDE.md
npx @elchika-inc/ts-review-graph build [--tsconfig <path>]... [--db <path>] Rebuild the graph
npx @elchika-inc/ts-review-graph update <file> [--db <path>] Incremental update for a single file
npx @elchika-inc/ts-review-graph status [--db <path>] Show graph statistics
npx @elchika-inc/ts-review-graph uninstall Remove MCP registration

MCP tools

Tool Key args Description
get_minimal_context changed_files[], mode (default: "review") Minimal file set (REVERSE/FORWARD BFS)
get_impact changed_file Files affected by a change, with depth
get_type_usages type_name Nodes that reference a type
get_test_coverage file Corresponding test files
query_graph from, edge_kind, direction, depth General-purpose graph traversal
build_graph tsconfigs[] (optional) Rebuild the graph
graph_status Graph statistics

BFS depth by mode

Mode REVERSE FORWARD Use case
review depth=2 Pre-review impact analysis (downstream)
implement depth=3 depth=1 (direct imports only) Pre-implementation change surface (bidirectional)
debug depth=5 Wide exploration for bug investigation

Configuration

.ts-review-graph/config.json (auto-generated by install, commit to repo):

{
  "tsconfigs": [
    "apps/api/tsconfig.json",
    "apps/web/tsconfig.app.json",
    "apps/monitor-worker/tsconfig.json"
  ]
}

graph.db is a build artifact — added to .gitignore automatically. Share config.json with your team.

How it works

Build phase

  1. Load each tsconfig.json
  2. Walk the AST using the TypeScript Compiler API
  3. Extract import/export/type relationships
  4. Store nodes and edges in SQLite (graph.db)

Query phase

  1. Specify changed files (["src/routes/monitors.ts"])
  2. Run BFS in the selected mode:
    • REVERSE: who imports this file (downstream impact)
    • FORWARD: what this file imports (upstream co-change candidates)
  3. Return only files within the blast radius

Tech stack

  • Language: TypeScript 5.4+
  • Database: SQLite 3 (better-sqlite3)
  • Graph traversal: SQL recursive CTE (WITH RECURSIVE)
  • MCP: Model Context Protocol SDK v1.0.0
  • CLI: Commander.js 12.0.0

License

MIT


Packages

Package Description Version
@elchika-inc/ts-review-graph CLI tool 0.3.0
@elchika-inc/ts-review-graph-mcp-server MCP server 0.3.0
@elchika-inc/ts-review-graph-core Graph build & query engine 0.3.0

Links

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选