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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。