ts-code-awareness
A static-analysis knowledge base for TypeScript/NestJS codebases, served to AI agents over MCP for understanding code without hallucination and excessive token usage.
README
ts-code-awareness
A static-analysis knowledge base for TypeScript / NestJS codebases, served to AI agents (like Claude Code) over MCP — so they can understand code without hallucinating and without spending many tokens.
It reads the source under a project root (it never boots the target app's runtime), builds a queryable map, and exposes framework-aware tools an LSP can't give you: DI graphs, route tables, the Nest guard/pipe/interceptor pipeline, the Prisma schema, and the entity↔code bridge — plus structural discovery, semantic search, and optional read-only live-data tools.
Why
TypeScript already ships a type checker and a language server, so "types,
go-to-def, find-references" are table stakes. The differentiation here is the
framework-aware, pre-digested views no LSP gives you, returned as compact,
chainable projections instead of raw source. An agent asks "what actually runs
when POST /users is hit, and where does it touch the DB?" and gets an answer
built from the route pipeline, the call graph, and the ORM access map — not a
pile of files to re-read.
Every answer is honest about its own completeness: reverse queries carry a
coverage envelope, call edges are tagged exact | contract | unresolved, and DB
access is tagged typed | heuristic. The engine never claims certainty it can't
prove.
What it does
- Structural map — symbols, signatures, decorators, and a resolved edge graph (imports, calls, extends/implements/overrides, references, instantiations) across a whole pnpm/npm/yarn + nx/turbo monorepo, with cross-package resolution and a two-tier build (cheap skeleton for everything, full call graph on demand).
- NestJS adapter — the route table, DI/provider graph, module graph, and
nest_pipeline_for(the effective guard → interceptor → pipe → filter chain for a handler, composed across all five registration levels in execution order). GraphQL resolvers and microservice/queue handlers when those packages are used. - Prisma adapter —
schema.prisma→ models / relations / enums, the model↔code access bridge ("where isUserwritten, with which fields"), and static migration/drift reports. The generated client is never read. - Semantic search — NL discovery (
search,search_similar) over a local, on-machine embedding index. Nothing leaves the machine. - Live data (optional, opt-in) — read-only
data_*tools against a configured DB connection, behind a SELECT-only guard that provably never mutates.
The full tool catalog is in docs/tools.md (~35 tools across
five categories; framework/DB/live tools light up only on detection).
Architecture
A single shared, multi-tenant HTTP daemon — started by a Claude Code
SessionStart hook — holds warm maps under an LRU and routes each session to its
project by an X-Project-Root header. A per-session stdio MCP shim forwards
tool calls to it. The daemon walks the program once with ts-morph; adapters
(Nest, Prisma) read that one parsed program and contribute namespaced fragments,
so nothing framework-specific runs unless its framework is detected.
Claude Code session
│ spawns (stdio, cwd = project)
▼
mcp-server ── HTTP /rpc, header X-Project-Root: <cwd> ──► daemon (shared, long-lived)
(per-session shim) │ ts-morph walk → SQLite map
▼
core + nest/prisma adapters → tools
Layout
packages/
core/ ts-morph walk → base map + tiers + fingerprint/incremental,
adapter registry, semantic index; SQLite store (node:sqlite)
adapter-nest/ routes, DI/module graph, guard/pipe/interceptor/filter pipeline,
GraphQL + messaging
adapter-prisma/ schema → models/relations, model↔code access bridge, migrations
live-data/ optional read-only DB tools behind a SELECT-only guard
daemon/ shared multi-tenant HTTP daemon + LRU + X-Project-Root routing
mcp-server/ stdio MCP shim (per session; forwards to the daemon)
plugin/ Claude Code SessionStart hook + MCP wiring
fixtures/ golden nx/pnpm monorepo (Nest + Prisma) test bed
docs/tools.md the MCP tool reference
Use it with Claude Code
The engine is wired as a Claude Code plugin via plugin/ — see
plugin/README.md. In short: a SessionStart hook starts
the shared daemon, .mcp.json registers the stdio shim as the ts-code-awareness
MCP server, and Claude Code asks you to approve it on first use. Opening this repo
in Claude Code (and approving ts-code-awareness) gives you the tools over this
repo's own TypeScript.
Develop
pnpm install
# typecheck the whole workspace
pnpm typecheck
# the test suites (run against the golden fixture)
pnpm test:tiers # structural map + incremental build
pnpm test:nest # routes / DI / pipeline
pnpm test:prisma # schema + model↔code bridge
pnpm test:semantic # semantic search
pnpm test:live # live-data guard + drivers (spins up throwaway DBs)
# run the daemon, then curl it
pnpm --filter @codehead-pl/tsca-daemon start
curl -s localhost:47600/health
# drive the MCP shim the way Claude Code does
pnpm exec tsx packages/mcp-server/test/client.ts "$PWD/fixtures/nest-monorepo"
# compile to dist/
pnpm build
Requirements: Node ≥ 22.5 (uses built-in node:sqlite — no native modules).
Dev runs TypeScript directly via tsx; pnpm build compiles with tsup.
Roadmap
Where it's headed — more framework and database adapters, cross-cutting bridges,
and a community adapter SDK — is in ROADMAP.md.
License
MIT © Michał Tomczuk
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.