raph-indexer** — a code-intelligence engine that turns any TypeScript / React / Next.js repo into a queryable **code graph** and serves it five ways: a **CLI**, an **MCP server** for AI agents, an **HTTP + WebSocket API**, a **3D web explorer with a built-in chatbot**, and **local semantic search**.
mcp-code-indexer
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
The source monorepo for **code-graph-indexer** — a code-intelligence engine that turns any TypeScript / React / Next.js repo into a queryable **code graph** and serves it five ways: a **CLI**, an **MCP server** for AI agents, an **HTTP + WebSocket API**, a **3D web explorer with a built-in chatbot**, and **local semantic search**.
> **Just want to use it?** You don't need this repo. npx code-graph-indexer ui --root . gets you the whole thing — see the package README. This repo is for working on the engine itself.
Everything is built on ts-morph, so edges are **resolved by the compiler, not grepped** — and conservative: an edge is drawn only when it resolves to a real indexed node. The indexer is **generic**; it discovers the workspace shape itself and handles monorepos (pnpm / turbo / lerna) and standalone single-package repos alike. Nothing about the target is hardcoded.
---
Why it exists
An agent asked *"what breaks if I change this?"* normally reads a pile of files
into context and guesses. One graph query answers it exactly, for roughly 1% of
the tokens — because edges come from the TypeScript resolver, not from grep.
The numbers behind that claim, and the query-by-query breakdown, are in the
package README. This file
is about **working on the engine**; that one is about using it.
---
The graph model
| Node types | Edge types |
| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| repo · app · package · folder · file · component · function · external | contains · imports · calls · renders · references · depends-on |
Each node carries metrics (loc, exportsCount), a status block (type/lint/build health), and git metadata — enough to build codebase dashboards, impact analysis, and AI-agent navigation on top of.
---
Quickstart (working on the engine)
> Requires Node ≥ 20.19 and pnpm 10 (pinned via packageManager; corepack enable selects it). pnpm build is required before running the CLI or server from source.
Run the full explorer against this repo (or any path):
pnpm serve serves the pre-built web bundle; pnpm ui is the hot-reloading dev server for working on the UI itself.
---
The five surfaces
All resolve the **same engine** against a target repo root.
1. 3D explorer + chatbot
The apps/web/code-graph front-end — a react-force-graph-3d viewer with folder drill-down, type/health coloring, hover tracing, blast-radius highlighting, a 2D fallback, and a chat panel grounded in the graph. It's a pure consumer of the HTTP/WS API: it loads GET /api/graph, then applies live GraphPatches over WS /ws as you edit files. The published package bundles the built version so npx code-graph-indexer ui just works.
2. MCP server — 14 tools
Registers over stdio so Claude Code / Cursor can call it directly:
Tools: index_repo, get_graph, get_node, who_renders, who_calls, find_references, blast_radius, find_cycles, find_orphans, search_nodes, get_context_pack, build_embeddings, semantic_search, and open_explorer (starts the 3D UI and returns its URL). Full descriptions are in the package README.