mcp-code-indexer-react-ts
This server indexes any TypeScript/React repo into a queryable code graph and exposes 14 MCP tools for analysis, search, and visualization.
Index & retrieve the graph —
index_repobuilds/persists the graph;get_graphreads it (with filtering/summary options);get_nodefetches a single node by id.Reverse lookups —
who_renders,who_calls, andfind_referencesfind what depends on a given component/function/symbol.Impact analysis —
blast_radiusshows everything transitively affected by a node change;find_cyclesdetects dependency cycles;find_orphansfinds dead-code candidates.Search —
search_nodesfuzzy-matches by name/path;semantic_searchfinds code by meaning (embeddings, with lexical fallback).Context for AI agents —
get_context_packbundles source, dependencies, dependents, and blast radius for safe edits.Embeddings —
build_embeddingscomputes local vectors (idempotent, incremental, optional).Visualization —
open_explorerstarts the 3D web explorer + chatbot and returns its URL.All tools accept a
rootto target any repo (defaults to cwd).
mcp-code-indexer
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.
┌──────────────┐ ts-morph AST ┌───────────────┐ serve ┌───────────────────────────────────────┐
│ any TS/React │ ───────────────▶ │ code graph │ ─────────▶ │ CLI · MCP · HTTP/WS · 3D UI · semantic │
│ repo │ walk + resolve │ nodes + edges │ │ (consume from anywhere) │
└──────────────┘ └───────────────┘ └───────────────────────────────────────┘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.
Related MCP server: codegraph
The graph model
Node types | Edge types |
|
|
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)
pnpm install
pnpm build # turbo builds core → _shared → engine → server → web (topo order)
pnpm test # unit tests across the engine + schema packages
pnpm typecheck
pnpm lintRequires Node ≥ 20.19 and pnpm 10 (pinned via
packageManager;corepack enableselects it).pnpm buildis required before running the CLI or server from source.
Run the full explorer against this repo (or any path):
pnpm serve --root . # HTTP/WS server on :3002 (serves the built UI too)
pnpm ui # OR: Vite dev server on :5182 with HMR, proxying /api + /ws → :3002pnpm 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:
claude mcp add code-graph -- node "$(pwd)/tools/code-indexer/build/code-indexer/src/index.js"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.
3. CLI
node tools/code-indexer/build/code-indexer/src/cli.js index --root /path/to/repo
node tools/code-indexer/build/code-indexer/src/cli.js query blast-radius --id "fn:src/util.ts#format" --root /path/to/repo4. HTTP + WebSocket API
pnpm serve --root /path/to/repo
curl localhost:3002/api/graph | jq '.meta'
# { "root": "/…", "nodeCount": 908, "edgeCount": 2138, "indexerVersion": "…" }Reads, reverse queries, POST /api/reindex, POST /api/chat, and WS /ws for live patches. Bound to 127.0.0.1 only — endpoints are unauthenticated and mutating, so never expose it off-host.
5. Semantic search
Local all-MiniLM-L6-v2 embeddings (384-dim) via @huggingface/transformers — no API key, nothing leaves the machine. It is an optional dependency: if it isn't installed, semantic_search degrades to lexical search instead of failing.
Architecture
Deeper rationale — the graph model, why ts-morph, the macro/micro split, and the honest trade-offs — is in docs/DESIGN.md.
A Turborepo of a few focused packages (plus shared config):
mcp-code-indexer/
├── packages/
│ ├── code-graph-core/ @repo/code-graph-core — Zod schemas: nodes, edges, snapshot, status
│ └── code-indexer-dist/ code-graph-indexer — the published npm bundle (tsup) + bundled web UI
├── tools/
│ ├── _shared/ @tools/shared — MCP server base (McpServerBase, ToolRegistry), utils
│ └── code-indexer/ code-indexer-mcp — the engine: ts-morph analysis, CLI, MCP server
└── apps/
├── indexer-server/ indexer-server — Express + ws runtime, file-watcher, REST/WS + chat
└── web/code-graph/ code-graph — the React + three.js 3D explorerDependency flow (leaves first):
code-graph-core ─┬─▶ code-indexer ─▶ indexer-server ─┐
_shared ──────┘ ├─▶ code-indexer-dist (the npm package)
web/code-graph ─────────────────────────────────┘code-graph-core— the contract. Zod schemas validate every node, edge, and snapshot, so the graph shape is guaranteed end-to-end. Pure and fully unit-tested.code-indexer— the analysis engine.ts-morphparsing plus workspace discovery (monorepo vs standalone), incremental snapshots to.code-graph/. Doubles as the MCP server.indexer-server— wraps the engine in Express +ws, indexes on boot, enriches node status in the background, watches files for live updates, and serves the chat endpoint (localclaudeCLI → API key → heuristic).web/code-graph— the 3D explorer, a pure API consumer.code-indexer-dist— bundles all of the above into the singlecode-graph-indexernpm package, web UI included.
Scripts
Command | What it does |
| Build every package (topo order via turbo) |
|
|
| Unit tests (schemas + engine) |
| ESLint across all packages (shared flat config) |
| Run the server (with UI) against any repo on |
| Vite dev server for the explorer on |
Tech
TypeScript (strict) · Turborepo · pnpm workspaces · ts-morph · Zod · Express · ws · @parcel/watcher · React · three.js · Model Context Protocol SDK · Transformers.js · Vitest · tsup.
Status
pnpm build ✓ · pnpm typecheck ✓ · pnpm lint ✓ · pnpm test ✓. CI runs the same gate on every push and PR (.github/workflows/ci.yml):
install → audit (fails on high) → build → typecheck → lint → testThe audit step is explicit because npm audit silently reports nothing on a
pnpm workspace — there's no package-lock.json for it to read.
Available Tools
14 toolsblast_radiusA
Everything that transitively depends on a node — the impact if it changes or breaks
Inputs: id (required), root.
build_embeddingsA
Compute local vector embeddings for the indexed nodes (enables semantic_search). Idempotent + incremental — only changed nodes are re-embedded. No-op if the local model is unavailable.
Inputs: root.
find_cyclesB
Find dependency cycles in the graph (import/render/call cycles)
Inputs: root.
find_orphansA
Dead-code candidates: exported files/components/functions that nothing imports, renders, or calls. Excludes entry points (index/main/App/config) unless includeEntryPoints is set. Heuristic — review, do not auto-delete.
Inputs: root, includeEntryPoints.
find_referencesB
All references into a node (incoming edges), optionally filtered by edge type
Inputs: id (required), root, types.
get_context_packA
One dense bundle for safely editing a node: its source + what it depends on + what depends on it + blast-radius size. Use instead of get_node + source + who_calls + blast_radius.
Inputs: id (required), root, maxRefs.
get_graphA
Read the code graph. Defaults to a compact summary on large repos (pass full:true for everything). Narrow with type/depth/lean/fields to keep output small.
Inputs: full, lean, root, type, +3 more.
get_nodeB
Read a single node from the persisted code graph by id
Inputs: id (required), root.
index_repoA
Index a TS/React repo (monorepo or standalone) into a code graph and persist it to .code-graph/graph.json
Inputs: root.
open_explorerA
Start the local 3D web explorer + chatbot for a repo and return its URL. Use when the user asks to SEE/visualize the code graph, open the UI, or explore visually. Starts a background HTTP server on 127.0.0.1 (default port 3002) and indexes the repo; returns the URL to open in a browser.
Inputs: port, root.
search_nodesA
Fuzzy-find nodes by name or path (e.g. "useAuth", "Header") — resolve a rough name to canonical node ids without grepping or guessing ids
Inputs: query (required), root, type, limit.
semantic_searchA
Find code by MEANING, not just name (e.g. "logic that decides trustee access"). Ranks nodes by embedding similarity; falls back to lexical search (with a hint) if embeddings aren't built.
Inputs: query (required), root, type, limit.
who_callsA
Reverse lookup: which symbols call the given function/component id (incoming calls edges)
Inputs: id (required), root.
who_rendersC
Reverse lookup: which components render the given component id (incoming renders edges)
Inputs: id (required), root.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Most tools have distinct purposes, but there is minor overlap between 'find_references', 'who_calls', and 'who_renders' since all deal with incoming edges. However, descriptions clearly differentiate them by edge type.
Naming is mostly verb_noun (e.g., index_repo, search_nodes, find_cycles), but 'blast_radius' breaks the pattern with a noun phrase. The 'who_' prefix for call/renders is consistent but unconventional.
14 tools is a well-scoped set for a code indexing server, covering indexing, searching, dependency analysis, and visualization without excessive overlap.
Covers core CRUD (index, read, search) and dependency analysis thoroughly. Missing explicit delete or update tools for the graph, but the server's read-heavy purpose makes this acceptable.
Maintenance
Related MCP Connectors
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Coding agents in multi-service codebases routinely rebuild existing helpers, trust stale type definitions, and modify API contracts without knowing who consumes them. Carrick solves this by indexing your entire TypeScript ecosystem across service and repository boundaries. By integrating deeply with the TypeScript compiler, Carrick traces every route, type, and cross-service call while recording function behaviour so agents search by intent rather than name. Delivered via MCP for AI agents and LSP for IDEs, Carrick ensures models see existing endpoints and utilities before generating new code. The scanner is source-available and runs from your CLI or CI pipeline.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceSemantic code indexer with GraphRAG knowledge graph. Index your codebase, search in natural language, and expose everything via MCP so AI agents understand architecture — not just files.524Apache 2.0
- AlicenseBqualityBmaintenanceIndexes a Python/JS/TS repository into a local SQLite knowledge graph so agents can trace callers, callees, imports, subclasses and covering tests, measure impact radius, rank diff risk, and summarize architecture without grepping files. Exposes these queries as MCP tools alongside an equivalent CLI, with no daemon, embeddings, or network access.10MIT
- AlicenseAqualityBmaintenanceLocal code search for AI agents over a tree-sitter index of your repo: exact symbol lookup, scope-aware usages, call graph and impact analysis, AST pattern search, indexed grep and semantic search. 28 MCP tools, 19 languages, runs fully offline.2812MIT
- AlicenseNot gradedqualityCmaintenanceEnables coding agents to query a deterministic AST knowledge graph of a codebase over MCP—finding symbols, callers/callees, dependencies, impact, and relevant tests via compact path:line JSON—so they can navigate code without grepping, embeddings, or an LLM.MIT