typegraph-mcp 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +17 -0
- package/.cursor-plugin/plugin.json +17 -0
- package/.mcp.json +10 -0
- package/LICENSE +21 -0
- package/README.md +451 -0
- package/benchmark.ts +735 -0
- package/check.ts +459 -0
- package/cli.ts +778 -0
- package/commands/check.md +23 -0
- package/commands/test.md +23 -0
- package/config.ts +50 -0
- package/gemini-extension.json +16 -0
- package/graph-queries.ts +462 -0
- package/hooks/hooks.json +15 -0
- package/module-graph.ts +507 -0
- package/package.json +39 -0
- package/scripts/ensure-deps.sh +34 -0
- package/server.ts +837 -0
- package/skills/code-exploration/SKILL.md +55 -0
- package/skills/dependency-audit/SKILL.md +50 -0
- package/skills/impact-analysis/SKILL.md +52 -0
- package/skills/refactor-safety/SKILL.md +50 -0
- package/skills/tool-selection/SKILL.md +79 -0
- package/smoke-test.ts +500 -0
- package/tsserver-client.ts +413 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "typegraph",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "Type-aware TypeScript navigation — 14 MCP tools for go-to-definition, find-references, dependency graphs, cycle detection, and impact analysis",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Owen Jones"
|
|
7
|
+
},
|
|
8
|
+
"repository": "https://github.com/guyowen/typegraph-mcp",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"typescript",
|
|
12
|
+
"navigation",
|
|
13
|
+
"mcp",
|
|
14
|
+
"tsserver",
|
|
15
|
+
"monorepo"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "typegraph",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "Type-aware TypeScript navigation — 14 MCP tools for go-to-definition, find-references, dependency graphs, cycle detection, and impact analysis",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Owen Jones"
|
|
7
|
+
},
|
|
8
|
+
"repository": "https://github.com/guyowen/typegraph-mcp",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"typescript",
|
|
12
|
+
"navigation",
|
|
13
|
+
"mcp",
|
|
14
|
+
"tsserver",
|
|
15
|
+
"monorepo"
|
|
16
|
+
]
|
|
17
|
+
}
|
package/.mcp.json
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Owen Guy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
# typegraph-mcp
|
|
2
|
+
|
|
3
|
+
Give your AI coding agent the same TypeScript understanding your IDE has.
|
|
4
|
+
|
|
5
|
+
14 semantic navigation tools — go-to-definition, find-references, type info, dependency graphs, cycle detection, impact analysis — delivered via the [Model Context Protocol](https://modelcontextprotocol.io/) so any MCP-compatible agent can use them.
|
|
6
|
+
|
|
7
|
+
## The problem
|
|
8
|
+
|
|
9
|
+
AI coding agents navigate TypeScript blind. They `grep` for a symbol name and get string matches instead of real references. They read entire files to find a type that's re-exported through three barrel files. They can't tell you what depends on what, or whether your refactor will break something two packages away.
|
|
10
|
+
|
|
11
|
+
Every wrong turn burns context tokens and degrades the agent's output.
|
|
12
|
+
|
|
13
|
+
## The difference
|
|
14
|
+
|
|
15
|
+
Measured on a real monorepo — tracing a call chain from an API handler to its implementation:
|
|
16
|
+
|
|
17
|
+
| | grep | typegraph-mcp |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| **Tokens consumed** | ~113,000 | 1,006 |
|
|
20
|
+
| **Files touched** | 47 | 3 |
|
|
21
|
+
| **False positives** | dozens of string matches | 0 |
|
|
22
|
+
|
|
23
|
+
**99% context reduction.** The agent gets precise answers in milliseconds instead of noisy guesses. See [full benchmark results](#benchmark-results) for token comparison, latency, and accuracy data across multiple scenarios.
|
|
24
|
+
|
|
25
|
+
### Before: grep-based navigation
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
Agent: I need to find where createUser is implemented.
|
|
29
|
+
→ grep "createUser" across project
|
|
30
|
+
→ 47 results: test files, comments, variable names, string literals, actual definitions
|
|
31
|
+
→ reads 6 files trying to follow the chain
|
|
32
|
+
→ burns ~113,000 tokens, still not sure it found the right implementation
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### After: typegraph-mcp
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
Agent: ts_trace_chain({ file: "src/handlers.ts", symbol: "createUser" })
|
|
39
|
+
→ 3-hop chain: handlers.ts → UserService.ts → UserRepository.ts
|
|
40
|
+
→ each hop shows the exact line with a code preview
|
|
41
|
+
→ 1,006 tokens, done
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick start
|
|
45
|
+
|
|
46
|
+
### Option A: Claude Code plugin (recommended)
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Clone and install
|
|
50
|
+
git clone https://github.com/guyowen/typegraph-mcp.git ~/typegraph-mcp
|
|
51
|
+
cd ~/typegraph-mcp && pnpm install
|
|
52
|
+
|
|
53
|
+
# Load the plugin
|
|
54
|
+
claude --plugin-dir ~/typegraph-mcp
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The plugin auto-configures everything:
|
|
58
|
+
- MCP server starts automatically with the correct environment
|
|
59
|
+
- 5 workflow skills teach Claude *when* and *how* to chain tools (impact analysis, refactor safety, dependency audit, code exploration, tool selection)
|
|
60
|
+
- `/typegraph:check` and `/typegraph:test` commands available in-session
|
|
61
|
+
- SessionStart hook verifies dependencies are installed
|
|
62
|
+
|
|
63
|
+
### Option B: CLI setup (all agents)
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Clone and install
|
|
67
|
+
git clone https://github.com/guyowen/typegraph-mcp.git ~/typegraph-mcp
|
|
68
|
+
cd ~/typegraph-mcp && pnpm install
|
|
69
|
+
|
|
70
|
+
# Run setup from your project root
|
|
71
|
+
cd /path/to/your-ts-project
|
|
72
|
+
npx tsx ~/typegraph-mcp/cli.ts setup
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The interactive `setup` command:
|
|
76
|
+
1. Auto-detects which AI agents you use (Claude Code, Cursor, Codex CLI, Gemini CLI, GitHub Copilot)
|
|
77
|
+
2. Copies the plugin into `./plugins/typegraph-mcp/` and installs dependencies
|
|
78
|
+
3. Registers the MCP server in each agent's config file (`.mcp.json`, `.cursor/mcp.json`, `.codex/config.toml`, `.vscode/mcp.json`)
|
|
79
|
+
4. Copies workflow skills to `.agents/skills/` for agents that discover them there
|
|
80
|
+
5. Appends agent instructions to `CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, or `.github/copilot-instructions.md`
|
|
81
|
+
6. Runs health checks and smoke tests to verify everything works
|
|
82
|
+
|
|
83
|
+
Use `--yes` to skip prompts and auto-select detected agents.
|
|
84
|
+
|
|
85
|
+
### Option C: Manual setup
|
|
86
|
+
|
|
87
|
+
If you prefer to configure things yourself:
|
|
88
|
+
|
|
89
|
+
1. Add to `.claude/mcp.json` in your project (or `~/.claude/mcp.json` for global):
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"mcpServers": {
|
|
94
|
+
"typegraph": {
|
|
95
|
+
"command": "npx",
|
|
96
|
+
"args": ["tsx", "/absolute/path/to/typegraph-mcp/server.ts"],
|
|
97
|
+
"env": {
|
|
98
|
+
"TYPEGRAPH_PROJECT_ROOT": ".",
|
|
99
|
+
"TYPEGRAPH_TSCONFIG": "./tsconfig.json"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
2. Verify with `npx tsx ~/typegraph-mcp/cli.ts check` and `npx tsx ~/typegraph-mcp/cli.ts test`.
|
|
107
|
+
|
|
108
|
+
`TYPEGRAPH_PROJECT_ROOT` resolves relative to the agent's working directory. Use `"."` for project-local config. The `args` path to `server.ts` must be absolute.
|
|
109
|
+
|
|
110
|
+
### Restart your agent session
|
|
111
|
+
|
|
112
|
+
First query takes ~2s (tsserver warmup). Subsequent queries: 1–60ms.
|
|
113
|
+
|
|
114
|
+
## Requirements
|
|
115
|
+
|
|
116
|
+
- **Node.js** >= 18
|
|
117
|
+
- **TypeScript** >= 5.0 in the target project (`node_modules`)
|
|
118
|
+
- **pnpm** (or npm) for installing typegraph-mcp dependencies
|
|
119
|
+
|
|
120
|
+
## CLI
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
Usage: typegraph-mcp <command> [options]
|
|
124
|
+
|
|
125
|
+
Commands:
|
|
126
|
+
setup Install typegraph-mcp plugin into the current project
|
|
127
|
+
remove Uninstall typegraph-mcp from the current project
|
|
128
|
+
check Run health checks (12 checks)
|
|
129
|
+
test Run smoke tests (all 14 tools)
|
|
130
|
+
start Start the MCP server (stdin/stdout)
|
|
131
|
+
|
|
132
|
+
Options:
|
|
133
|
+
--yes Skip confirmation prompts (accept all defaults)
|
|
134
|
+
--help Show help
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Run any command with:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npx tsx ~/typegraph-mcp/cli.ts <command>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### `setup`
|
|
144
|
+
|
|
145
|
+
Interactive project setup. Detects which AI agents you use, copies the plugin into `./plugins/typegraph-mcp/`, registers the MCP server in each agent's config, installs dependencies, and runs verification. If an existing installation is detected, offers Update/Remove/Exit.
|
|
146
|
+
|
|
147
|
+
### `remove`
|
|
148
|
+
|
|
149
|
+
Cleanly uninstalls typegraph-mcp from the project: removes the plugin directory, deregisters the MCP server from all agent configs (`.cursor/mcp.json`, `.codex/config.toml`, `.vscode/mcp.json`), strips agent instruction snippets, and cleans up `.agents/skills/`.
|
|
150
|
+
|
|
151
|
+
### `check`
|
|
152
|
+
|
|
153
|
+
Runs 12 health checks: Node.js version, TypeScript installation, tsconfig validity, MCP registration, dependency versions, etc. Every failing check shows a `Fix:` instruction.
|
|
154
|
+
|
|
155
|
+
### `test`
|
|
156
|
+
|
|
157
|
+
Exercises all 14 tools against the target project — graph build, dependency tree, cycle detection, go-to-definition, references, type info, and more. Dynamically discovers a file in the project to test against.
|
|
158
|
+
|
|
159
|
+
### `start`
|
|
160
|
+
|
|
161
|
+
Starts the MCP server on stdin/stdout. This is what the MCP client calls — you typically don't run this directly.
|
|
162
|
+
|
|
163
|
+
## Tools
|
|
164
|
+
|
|
165
|
+
### Semantic point queries (tsserver)
|
|
166
|
+
|
|
167
|
+
These tools understand your types, resolve through imports and barrel files, and return real code — not string matches.
|
|
168
|
+
|
|
169
|
+
#### `ts_find_symbol`
|
|
170
|
+
Find a symbol's location in a file by name.
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
{ file: "src/services/Auth.ts", symbol: "validateToken" }
|
|
174
|
+
→ { file, line, column, kind, preview }
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### `ts_definition`
|
|
178
|
+
Go to definition. Resolves through imports, re-exports, barrel files, interfaces, and generics.
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
{ file: "src/handlers.ts", symbol: "UserService" }
|
|
182
|
+
→ { definitions: [{ file, line, column, preview }] }
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### `ts_references`
|
|
186
|
+
Find all semantic references to a symbol (not string matches).
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
{ file: "src/services/Auth.ts", symbol: "validateToken" }
|
|
190
|
+
→ { references: [{ file, line, column, preview, isDefinition }], count }
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### `ts_type_info`
|
|
194
|
+
Get the TypeScript type and documentation — the same info you see hovering in VS Code.
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
{ file: "src/handlers.ts", symbol: "userService" }
|
|
198
|
+
→ { type: "const userService: { readonly getUser: ...", documentation: "..." }
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### `ts_navigate_to`
|
|
202
|
+
Search for a symbol across the entire project without knowing which file it's in.
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
{ symbol: "validateToken", maxResults: 10 }
|
|
206
|
+
→ { results: [{ file, line, column, kind, containerName }], count }
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### `ts_trace_chain`
|
|
210
|
+
Follow go-to-definition hops automatically, building a call chain from entry point to implementation.
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
{ file: "src/handlers.ts", symbol: "createUser", maxHops: 5 }
|
|
214
|
+
→ { chain: [{ file, line, column, preview }, ...], hops: 3 }
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### `ts_blast_radius`
|
|
218
|
+
Analyze the impact of changing a symbol — all usage sites and affected files.
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
{ file: "src/services/Auth.ts", symbol: "validateToken" }
|
|
222
|
+
→ { directCallers: 12, filesAffected: ["src/handlers.ts", ...], callers: [...] }
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### `ts_module_exports`
|
|
226
|
+
List all exports from a module with their resolved types.
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
{ file: "src/services/Auth.ts" }
|
|
230
|
+
→ { exports: [{ symbol, kind, line, type }], count }
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Structural graph queries (oxc-parser + oxc-resolver)
|
|
234
|
+
|
|
235
|
+
These tools operate on the full import graph, built in ~100ms and kept current via `fs.watch`.
|
|
236
|
+
|
|
237
|
+
#### `ts_dependency_tree`
|
|
238
|
+
Transitive dependency tree of a file — what it depends on.
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
{ file: "src/handlers.ts", depth: 3, includeTypeOnly: false }
|
|
242
|
+
→ { root, nodes: 42, files: [...] }
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### `ts_dependents`
|
|
246
|
+
All files that depend on a given file, grouped by package.
|
|
247
|
+
|
|
248
|
+
```
|
|
249
|
+
{ file: "src/schemas/ids.ts" }
|
|
250
|
+
→ { nodes: 155, directCount: 31, byPackage: { "@my/core": [...] } }
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### `ts_import_cycles`
|
|
254
|
+
Detect circular import dependencies (strongly connected components).
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
{ file: "src/services/Auth.ts" } // optional filter
|
|
258
|
+
→ { count: 1, cycles: [["src/a.ts", "src/b.ts"]] }
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
#### `ts_shortest_path`
|
|
262
|
+
Shortest import path between two files.
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
{ from: "src/handlers.ts", to: "src/schemas/ids.ts" }
|
|
266
|
+
→ { path: ["handlers.ts", "schemas/index.ts", "schemas/ids.ts"], hops: 2 }
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
#### `ts_subgraph`
|
|
270
|
+
Extract the neighborhood around seed files — imports, dependents, or both.
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
{ files: ["src/services/Auth.ts"], depth: 1, direction: "both" }
|
|
274
|
+
→ { nodes: [...], edges: [{ from, to, specifiers }], stats: { nodeCount, edgeCount } }
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
#### `ts_module_boundary`
|
|
278
|
+
Analyze coupling of a module: incoming/outgoing edges, shared dependencies, isolation score.
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
{ files: ["src/schemas/ids.ts", "src/schemas/queue.ts"] }
|
|
282
|
+
→ { internalEdges: 8, incomingEdges: [...], outgoingEdges: [...], isolationScore: 0.058 }
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Architecture
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
AI Agent ─── stdin/stdout ─── MCP Server ─┬── tsserver (child process)
|
|
289
|
+
MCP protocol │ type-aware point queries
|
|
290
|
+
└── module-graph (in-process)
|
|
291
|
+
oxc-parser + oxc-resolver
|
|
292
|
+
structural graph queries
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Plugin structure (Claude Code)
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
typegraph-mcp/
|
|
299
|
+
├── .claude-plugin/plugin.json # Plugin manifest
|
|
300
|
+
├── .mcp.json # Auto-configured MCP server
|
|
301
|
+
├── hooks/hooks.json # SessionStart dependency check
|
|
302
|
+
├── scripts/ensure-deps.sh # Installs node_modules if missing
|
|
303
|
+
├── commands/
|
|
304
|
+
│ ├── check.md # /typegraph:check
|
|
305
|
+
│ └── test.md # /typegraph:test
|
|
306
|
+
├── skills/
|
|
307
|
+
│ ├── tool-selection/ # Which of the 14 tools to use when
|
|
308
|
+
│ ├── impact-analysis/ # blast_radius + dependents + boundary
|
|
309
|
+
│ ├── refactor-safety/ # trace_chain + cycles + references
|
|
310
|
+
│ ├── dependency-audit/ # cycles + dependency_tree + boundary
|
|
311
|
+
│ └── code-exploration/ # navigate_to + trace_chain + subgraph
|
|
312
|
+
├── server.ts # MCP server entry point
|
|
313
|
+
├── cli.ts # CLI (setup, check, test, start)
|
|
314
|
+
└── ...
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Server internals
|
|
318
|
+
|
|
319
|
+
Two subsystems start concurrently:
|
|
320
|
+
|
|
321
|
+
1. **tsserver** — child process for semantic queries. Communicates via pipes using tsserver's JSON protocol. Auto-restarts on crash (up to 3 times) and re-opens tracked files.
|
|
322
|
+
|
|
323
|
+
2. **Module graph** — in-process import graph built with [oxc-parser](https://github.com/nicolo-ribaudo/oxc-parser) (fast NAPI parser, no AST walking) and [oxc-resolver](https://github.com/nicolo-ribaudo/oxc-resolver) (tsconfig-aware resolution). Incrementally updated via `fs.watch`.
|
|
324
|
+
|
|
325
|
+
### Monorepo support
|
|
326
|
+
|
|
327
|
+
Works out of the box with TypeScript project references:
|
|
328
|
+
|
|
329
|
+
- Resolves through `composite` project references and declaration maps
|
|
330
|
+
- Maps `dist/` paths back to source (handles `outDir: "dist"` / `rootDir: "src"`)
|
|
331
|
+
- `extensionAlias` for NodeNext `.js` → `.ts` import mapping
|
|
332
|
+
- Cross-package barrel re-export resolution
|
|
333
|
+
|
|
334
|
+
Point `TYPEGRAPH_TSCONFIG` at your root `tsconfig.json` that includes all project references.
|
|
335
|
+
|
|
336
|
+
### ESLint configuration
|
|
337
|
+
|
|
338
|
+
If typegraph-mcp is installed as a plugin (e.g. `plugins/typegraph-mcp/`) and the project uses `typescript-eslint`, add to your ESLint `ignores`:
|
|
339
|
+
|
|
340
|
+
```javascript
|
|
341
|
+
ignores: [
|
|
342
|
+
"plugins/**",
|
|
343
|
+
]
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Not needed when typegraph-mcp lives outside the project tree.
|
|
347
|
+
|
|
348
|
+
### Agent instructions snippet
|
|
349
|
+
|
|
350
|
+
Add this to your agent instructions file (`CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, etc.) so the agent uses TypeGraph instead of grep:
|
|
351
|
+
|
|
352
|
+
```markdown
|
|
353
|
+
## TypeScript Navigation (typegraph-mcp)
|
|
354
|
+
|
|
355
|
+
Use the `ts_*` MCP tools instead of grep/glob for navigating TypeScript code. They resolve through barrel files, re-exports, and project references — returning precise results, not string matches.
|
|
356
|
+
|
|
357
|
+
- **Point queries** (tsserver): `ts_find_symbol`, `ts_definition`, `ts_references`, `ts_type_info`, `ts_navigate_to`, `ts_trace_chain`, `ts_blast_radius`, `ts_module_exports`
|
|
358
|
+
- **Graph queries** (import graph): `ts_dependency_tree`, `ts_dependents`, `ts_import_cycles`, `ts_shortest_path`, `ts_subgraph`, `ts_module_boundary`
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## Benchmark results
|
|
362
|
+
|
|
363
|
+
Measured on a 440-file TypeScript monorepo (4 apps, 4 packages, 972 import edges). All scenarios were discovered dynamically from the module graph — no hardcoded symbols.
|
|
364
|
+
|
|
365
|
+
Run the benchmark on your own codebase:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
TYPEGRAPH_PROJECT_ROOT=/path/to/project npx tsx ~/typegraph-mcp/benchmark.ts
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Token comparison
|
|
372
|
+
|
|
373
|
+
How many context tokens the agent consumes to answer a query. grep requires reading entire matching files; typegraph returns structured JSON.
|
|
374
|
+
|
|
375
|
+
| Scenario | Symbol | grep tokens | typegraph tokens | Calls | Reduction |
|
|
376
|
+
|---|---|---|---|---|---|
|
|
377
|
+
| Barrel re-export resolution | `AwsSesConfig` | 9,880 | 6 | 2 | 99.9% |
|
|
378
|
+
| High-fanout symbol lookup | `TenantId` | 125,000 | 7 | 2 | 99.9% |
|
|
379
|
+
| Call chain tracing | `AccessMaterializationService` | 53,355 | 4 | 1 | 99.9% |
|
|
380
|
+
| Impact analysis | `ids` | 125,000 | 3,373 | 1 | 97.3% |
|
|
381
|
+
|
|
382
|
+
**Average: 99% token reduction.**
|
|
383
|
+
|
|
384
|
+
### Latency
|
|
385
|
+
|
|
386
|
+
Per-tool timing across 5 runs. Test file: `AddressServiceLive.ts` (auto-discovered).
|
|
387
|
+
|
|
388
|
+
| Tool | p50 | p95 | avg |
|
|
389
|
+
|---|---|---|---|
|
|
390
|
+
| `ts_find_symbol` | 1.8ms | 3.0ms | 2.0ms |
|
|
391
|
+
| `ts_definition` | 0.3ms | 4.5ms | 1.1ms |
|
|
392
|
+
| `ts_references` | 13.3ms | 227.3ms | 56.4ms |
|
|
393
|
+
| `ts_type_info` | 1.0ms | 4.2ms | 1.7ms |
|
|
394
|
+
| `ts_navigate_to` | 32.4ms | 61.9ms | 38.3ms |
|
|
395
|
+
| `ts_module_exports` | 1.6ms | 2.2ms | 1.7ms |
|
|
396
|
+
| `ts_dependency_tree` | 0.0ms | 0.2ms | 0.1ms |
|
|
397
|
+
| `ts_dependents` | 0.0ms | 0.0ms | 0.0ms |
|
|
398
|
+
| `ts_import_cycles` | 0.3ms | 0.6ms | 0.3ms |
|
|
399
|
+
| `ts_shortest_path` | 0.0ms | 0.1ms | 0.0ms |
|
|
400
|
+
| `ts_subgraph` | 0.1ms | 0.3ms | 0.2ms |
|
|
401
|
+
| `ts_module_boundary` | 0.2ms | 0.3ms | 0.2ms |
|
|
402
|
+
|
|
403
|
+
**tsserver queries: 16.9ms avg. Graph queries: 0.1ms avg.**
|
|
404
|
+
|
|
405
|
+
### Accuracy
|
|
406
|
+
|
|
407
|
+
| Scenario | grep | typegraph |
|
|
408
|
+
|---|---|---|
|
|
409
|
+
| **Barrel resolution** — find where `AwsSesConfig` is defined, not re-exported | 13 matches across 6 files. Agent must read each to distinguish definition from re-exports. | Resolves directly to source definition in 1 tool call. |
|
|
410
|
+
| **Same-name disambiguation** — distinguish `CoreApiClient` from `CoreApiClientRpcLive`, `CoreApiClientTest`, etc. | 278 matches, 90 of which are variant names sharing the prefix. | 2 exact matches: `CoreApiClient.ts:103` [class], `index.ts:82` [alias]. |
|
|
411
|
+
| **Type-only vs runtime imports** — classify imports in a file with both kinds | `grep "import"` shows all imports. Agent must parse each line to check for `import type`. | 1 type-only, 13 runtime — classified automatically by the module graph. |
|
|
412
|
+
| **Cross-package impact** — find everything that depends on `ids.ts` | 1,038 matches for "ids". Cannot distinguish direct vs transitive or follow re-exports. | 31 direct, 158 transitive. Broken down by package. |
|
|
413
|
+
| **Circular dependency detection** | Impossible with grep. | 1 cycle: `TodoService.ts` <-> `TodoHistoryService.ts`. |
|
|
414
|
+
|
|
415
|
+
**5/5 typegraph wins.**
|
|
416
|
+
|
|
417
|
+
### Run your own benchmark
|
|
418
|
+
|
|
419
|
+
The benchmark is fully dynamic — it discovers scenarios from the module graph, so it works on any TypeScript project:
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
# From the typegraph-mcp directory
|
|
423
|
+
TYPEGRAPH_PROJECT_ROOT=/path/to/project npx tsx benchmark.ts
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
Scenarios that can't be found in the target codebase (e.g. no barrel files) are gracefully skipped.
|
|
427
|
+
|
|
428
|
+
## Troubleshooting
|
|
429
|
+
|
|
430
|
+
Run the health check first — it catches most issues:
|
|
431
|
+
|
|
432
|
+
```bash
|
|
433
|
+
npx tsx ~/typegraph-mcp/cli.ts check
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
| Symptom | Likely cause | Fix |
|
|
437
|
+
|---|---|---|
|
|
438
|
+
| Server won't start | Dependencies missing | `cd /path/to/typegraph-mcp && pnpm install` |
|
|
439
|
+
| "TypeScript not found" | Target project missing TS | Add `typescript` to devDependencies |
|
|
440
|
+
| Tools return empty results | tsconfig misconfigured | Check `TYPEGRAPH_TSCONFIG` points to the right file |
|
|
441
|
+
| MCP registration not found | Wrong path in config | Verify the `args` path to `server.ts` is absolute |
|
|
442
|
+
|
|
443
|
+
## Known limitations
|
|
444
|
+
|
|
445
|
+
- **Object literal property keys** (e.g., RPC handler names) are not indexed by tsserver's `navto`. Use `ts_find_symbol` with a specific file, or pass the `file` hint to `ts_navigate_to`.
|
|
446
|
+
- **First query latency** — ~2s as tsserver loads the project. Subsequent queries are 1–60ms.
|
|
447
|
+
- **Memory** — tsserver holds the project in memory. For very large monorepos (1000+ files), expect ~200–500MB RSS.
|
|
448
|
+
|
|
449
|
+
## License
|
|
450
|
+
|
|
451
|
+
MIT
|