Skip to Content
๐Ÿ“– Guide DocumentsCompiler Knowledge GraphOverview

Compiler Knowledge Graph

Your coding agent answers from the compiler instead of reading files.

A file-by-file source crawl collapsing into a compiler-built graph index

Ask an agent how something works and it opens a file, follows an import, opens the next, and repeats. That crawl is most of the token bill, and the relationships it infers are guesses from whatever text it happened to read.

One MCP tool, inspect_typescript_graph, answers instead. Its replies carry names, signatures, relationships, and source spans, never file bodies, so neither the question nor the answer grows with the repository.

  • How is this project laid out? Entry points, layers, and the symbols the most code leans on: overview.
  • Give me a code tour. Central flow, nearby paths, tests, and answer anchors: tour.
  • Where should I start? Ranked code handles for a natural question: entrypoints or lookup.
  • What does this reach, and what reaches it? Forward to callees, reverse to callers, and an impact projection onto the public API and tests: trace.
  • What is this, exactly? The declaration shape, its range, its dependencies, and its dependents: details.
  • Which code implements this specification? The declarations whose documentation cites a document section, an API operation, or a data model: lookup, with the target as the query.

For package users who need every caller or the full impact set, a trace request accepts complete: true. This exhausts the finite graph selected by direction, focus, and includeExternal, including dispatch through bodyless declarations. Cycles terminate without expanding a node twice, and impact results retain exported and test roles. With to, it searches for one shortest dependency path.

Exploratory traces default to a depth of three, twelve reached nodes and twenty-four traversed edges; path searches default to twelve hops. Explicit maxDepth and maxNodes have no upper ceiling, but bounded open traces still withhold dispatch fanouts of twelve or more implementations and limit hops to twice the node budget. truncated identifies omitted flow or an unsuccessful bounded path search. complete: true overrides every traversal budget and includes a summary of every hop, so a complete response may grow with the entire graph. Traversal is synchronous without per-request cancellation; resource or transport refusal fails the request instead of returning partial success.

Graph requests admitted before one native freshness check starts share that check of current disk inputs. A later request receives another check, without a time-based freshness window or cooldown. Canceling one waiting request releases only that caller; shared work continues for its remaining callers. The last cancellation aborts that work, and an outstanding native request retires its peer.

Initial artifact discovery and later publisher builds also belong to the session lifetime. They run asynchronously so a cold build leaves the transport responsive. Canceling a caller rejects that caller promptly; the last cancellation also withdraws shared work. The underlying preparation retires its owned native processes before releasing build locks and temporary inputs. Queued recovery and session closure wait for that preparation to finish. A canceled discovery cannot supply a later graph requestโ€™s artifacts.

Every node and edge is the compilerโ€™s own answer, which is what a text search cannot give you.

  • pnpm workspaces. A workspace:* dependency is followed into the sibling packageโ€™s real source, so a cross-package call lands on the true declaration rather than the barrel it passed through.
  • Path aliases. A @app/* import from tsconfig resolves to the real file.
  • Barrel re-exports. An index.ts that only re-exports is unwrapped to the file that declares the symbol.
  • Your code, not the world. Anything in node_modules or a .d.ts is an outside boundary rather than a place to walk into, and generated sources your .gitignore covers are de-ranked.
  • Object members. Statically named object-literal methods, function properties and nested properties have their own nodes. Ordinary names use api.create; empty keys and keys containing dots or brackets use JSON brackets such as api["quoted.key"] and api[""], keeping literal text distinct from nested ownership. Dynamic keys and object literals without a stable binding receive no guessed member identity or edge.
  • Documentation links. A {@link Symbol} the checker resolves is an edge like any other, and a tag the type system does not recognize is carried as written, so lookup answers which declarations cite docs/pricing.md#sale.

Benchmark

Loading graph benchmark results...

The median token cost on one shared onboarding question, against no MCP and the three comparators. Lower is better.

The line stays flat because neither side of the exchange grows with the repository: the agent stops fanning out across files, and the graph answers in names and edges rather than bodies. The comparators swing with repository size because their cost still follows how much source has to be read.

Indexing is the other half of the trade. The graph is a byproduct of the type-check the compiler already runs, so the three-million-line VS Code fixture is ready in 29 seconds, where a separate index spends minutes before it can answer anything.

Setup

npm install -D ttsc @ttsc/graph typescript
{ "mcpServers": { "ttsc-graph": { "command": "npx", "args": ["-y", "@ttsc/graph"] } } }

Start the agent from your project root so the server finds your tsconfig.json, or name the project with --cwd and --tsconfig. The native binary comes from the platform package installed with @ttsc/graph, not from the project being graphed.

The server never writes into your CLAUDE.md, AGENTS.md, or any other agent config, so installing it changes nothing in your repository.

Closing stdin withdraws pending graph work and joins its owned preparation. If shutdown fails, the MCP server exits with status 1 and reports the nested cleanup causes on stderr.

Comparison

How it differs from codegraph, codebase-memory-mcp, and serena: the resolution backend, the language scope, the index each one builds, and what that costs in tokens and in time.

3D Viewer

The same checker-resolved graph, rendered as a navigable ontology. Pick a benchmark repository or load your own project.

[Code graph]

Browse a code graph in 3D

Pick a benchmark example, or load a graph from your own project. Drag to orbit, scroll to zoom, click a node to focus it; the explorer spotlights files and finds symbols by name.

Loadingโ€ฆ
value-call (runtime use)type-refdoc-ref (documentation link)heritage (extends / implements / overrides)exports (module surface)node size = connection count ยท color = declaration kind
Last updated on