project-graph-mcp 2.4.2 → 2.4.3

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.
Files changed (2) hide show
  1. package/README.md +24 -295
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,276 +10,22 @@
10
10
 
11
11
  ![Compact mode — same file, 14 lines total, ↓40% tokens. Agents read and edit this directly.](https://raw.githubusercontent.com/rnd-pro/project-graph-mcp/main/docs/img/explorer-compact.jpg)
12
12
 
13
- The web dashboard has moved to [**mcp-agent-portal**](https://github.com/rnd-pro/mcp-agent-portal) — a unified MCP aggregator that includes project-graph-mcp as a child server with full visual UI.
14
-
15
13
  > [!TIP]
16
14
  > **18 MCP tools, zero config.** Add one line to your MCP config and the server downloads itself on the next IDE restart.
17
15
 
18
- ### Project Skeleton (10-50x compression)
19
-
20
- The server builds an AST-based graph of your project and outputs a minified JSON representation. The agent reads this to understand the architecture. When it needs deeper details, it calls `expand` or `deps`:
21
-
22
- ```json
23
- {
24
- "L": { "SN": "SymNode", "SNG": "SymNodeGraph" },
25
- "s": { "files": 23, "classes": 10, "functions": 65 },
26
- "n": { "SN": { "m": 11, "$": 7 }, "SNG": { "m": 16, "$": 5 } },
27
- "e": 35, "o": 7, "d": 5, "F": 63
28
- }
29
- ```
30
-
31
- `L` = legend (actual symbol names), `s` = stats, `n` = nodes with methods/properties, `e` = edges, `o` = orphans, `d` = duplicates, `F` = functions.
32
-
33
- ### Multi-Language Parsers
34
-
35
- JavaScript is parsed via AST (Acorn). TypeScript, Python, and Go use lightweight regex-based parsers — no heavy external binaries, just enough to extract classes, functions, imports, and calls. All parsers return a unified `ParseResult` structure.
36
-
37
- ```javascript
38
- // Python — triple quotes, hash comments
39
- stripStringsAndComments(code, { tripleQuote: true, hashComment: true })
40
-
41
- // Go — backtick strings without interpolation
42
- stripStringsAndComments(code, { backtick: true, templateInterpolation: false })
43
- ```
44
-
45
- ### Code Quality Analysis
46
-
47
- - **Dead code detection** — unused functions, classes, exports, variables, and imports
48
- - **Cyclomatic complexity** — flags functions over threshold, identifies refactoring targets
49
- - **Duplicate detection** — finds functionally similar functions by signature + structure similarity
50
- - **Large file analysis** — candidates for splitting by lines, functions, and exports count
51
- - **Legacy pattern finder** — outdated code patterns and redundant npm deps (built into Node.js 18+)
52
- - **JSDoc consistency** — validates `@param` count/names and `@returns` against AST signatures
53
- - **Type checking** — optional `tsc --checkJs` wrapper with graceful fallback
54
- - **Health Score (0-100)** — aggregated result from all checks in one call (`get_full_analysis` or quick `get_analysis_summary`)
55
- - **Incremental cache** — per-file analysis results cached in `.context/.cache/` with content hashing
56
-
57
- ### AI Context Layer
58
-
59
- One call loads everything an agent needs to understand a project:
60
-
61
- ```javascript
62
- get_ai_context({ path: "src/" })
63
- // → { skeleton, docs, totalTokens: 3150, savings: "93%" }
64
- ```
65
-
66
- - **Code compression** — Terser-minified source with export legend headers (20-55% per file)
67
- - **Compact Code Mode** — project-wide `compact`/`beautify` (preserves all names, strips comments/whitespace)
68
- - **Doc Dialect** — compact `.context/` documentation format, auto-generated from AST with `{DESCRIBE}` markers. Descriptions use a **simplified English dialect** — max 80 characters, pipe-separated, with standard abbreviations (`fn/ret/cfg/init/auth/db/msg`):
69
-
70
- ```
71
- generateJSDoc(t)→e.push,e.join|build /** */ JSDoc block from .ctx signature
72
- export expandFile(e,n)→beautify,inject|beautify compact JS + inject JSDoc from .ctx
73
- PATTERNS: Terser beautify|AST walk for injection points|reverse-order insertion
74
- ```
75
- - **Two-tier `.ctx`** — `.ctx` (machine-generated, AST signatures) + `.ctx.md` (agent notes, TODO, decisions)
76
- - **Self-enriching** — `@enrich` instructions embedded in `.ctx` files guide any AI agent to fill descriptions
77
- - **Staleness detection** — `@sig` hashes track structural changes; `check_stale_docs` identifies outdated docs
78
- - **Merge strategy** — regenerating `.ctx` files preserves existing descriptions
79
- - **Boot aggregator** — `get_ai_context` combines skeleton + docs + compressed files in one response
80
-
81
- ```bash
82
- # Generate .context/ documentation templates
83
- npx project-graph-mcp generate-ctx src/
84
-
85
- # View project docs in compact format
86
- npx project-graph-mcp docs src/
87
-
88
- # Compress a single file for AI
89
- npx project-graph-mcp compress src/core/parser.js
90
- ```
91
-
92
- ### Two-Tier Context: Overview → Focus
93
-
94
- Agents don't need full context for every file. The server provides a **progressive loading model**:
95
-
96
- | Mode | What agent reads | Token cost | Use case |
97
- |------|-----------------|------------|----------|
98
- | **Overview** | `get_skeleton()` + compact code | codeTok only | Understand project structure |
99
- | **Focus** | compact code + `.ctx` for specific files | codeTok + ctxTok (per file) | Deep work on area of interest |
100
- | **Traditional** | All raw source files | expanded | Reading source directly |
101
-
102
- ```javascript
103
- // 1. Overview: read entire project structure (cheap, no .ctx)
104
- get_skeleton({ path: "src/" })
105
- // → Legend, stats, all classes/functions/exports — ~2-5K tokens
106
-
107
- // 2. Focus: get enriched context ONLY for area of interest
108
- get_focus_zone({ recentFiles: ["src/core/parser.js", "src/mcp/tools.js"] })
109
- // → Compact code + .ctx documentation for just those 2 files
110
-
111
- // 3. Or auto-detect from git diff
112
- get_focus_zone({ path: ".", useGitDiff: true })
113
- // → Context for recently changed files only
114
- ```
115
-
116
- **Real-world token budget** (this project's own benchmark, 45 files):
117
-
118
- ```
119
- Skeleton + docs only: 3.2K tok — 93% savings, full project overview
120
- Compact source (agent reads): 46.9K tok — 20-55% savings per file
121
- ```
122
-
123
- **Per-file metrics breakdown:**
124
-
125
- | Layer | What | Tokens |
126
- |-------|------|--------|
127
- | Code (compact .js) | Minified source, all names preserved | codeTok |
128
- | Context (.ctx) | AST signatures, types, descriptions | ctxTok |
129
- | Total (focus mode) | What agent reads when focusing | codeTok + ctxTok |
130
-
131
- ### Compact Code Architecture
132
-
133
- Two modes for AI-native codebase editing — configure per project via `.context/config.json`:
134
-
135
- | Mode | Storage | Agent reads/writes | Human reviews |
136
- |------|---------|-------------------|---------------|
137
- | **1 — Compact** ⭐ | Minified JS | `src/` directly | `.expanded/` cache |
138
- | **2 — Full** | Formatted JS | compressed view | `src/` directly |
139
-
140
- **Mode 1 — Compact** (recommended for AI-first projects):
141
-
142
- Source of truth is compact code. Agents read and write it directly — saving tokens in **both directions** (input and output). Since output tokens cost 3-5x more than input, compact output is the biggest cost saving. Humans review via auto-generated `.expanded/` cache with restored names and injected JSDoc.
143
-
144
- ```javascript
145
- // Agent reads and edits compact source directly (20-55% fewer tokens both ways)
146
- // After edits, validate and generate human-readable cache:
147
- compact({ action: "validate_pipeline", path: ".", strict: true })
148
- compact({ action: "expand_project", path: "." })
149
- ```
150
-
151
- **Mode 2 — Full** (for existing projects, no refactoring needed):
152
-
153
- ```javascript
154
- // 1. Read compressed view (saves input tokens only)
155
- get_compressed_file({ path: "src/parser.js" })
156
-
157
- // 2. Edit by symbol name — server finds it via AST
158
- edit_compressed({
159
- path: "src/parser.js",
160
- symbol: "parseFile",
161
- code: "export async function parseFile(code, filename) { /* new body */ }"
162
- })
163
-
164
- // 3. Validate .ctx contracts after editing
165
- validate_ctx_contracts({ path: "." })
166
- ```
167
-
168
- **Migrating from Full to Compact:**
169
-
170
- ```bash
171
- # Ensure git is clean, then run automated migration
172
- npx project-graph-mcp compact-migrate .
173
- # → compacts all JS, generates @names in .ctx, sets mode 1, validates
174
- ```
175
-
176
- **`.ctx` typed signatures** — JSDoc types extracted into compact format:
177
-
178
- ```
179
- parseFile(code:string,filename:string)→Promise<ParseResult>→parse,walk|parse JS file into AST
180
- ```
181
-
182
- ```bash
183
- # Check current mode
184
- npx project-graph-mcp mode .
185
-
186
- # Set project mode
187
- npx project-graph-mcp set-mode . 1
188
-
189
- # Validate .ctx documentation matches source
190
- npx project-graph-mcp validate-ctx . --strict
191
- ```
192
-
193
- ### Expand & Validate Pipeline
194
-
195
- The compact→expand pipeline is **fully reversible**. Verify round-trip integrity:
196
-
197
- ```javascript
198
- // Expand a compact file back to full formatted + JSDoc
199
- compact({ action: "expand_file", path: "src/parser.js" })
200
-
201
- // Expand entire project
202
- compact({ action: "expand_project", path: ".", dryRun: true })
203
-
204
- // Validate compact ↔ expand round-trip
205
- compact({ action: "validate_pipeline", path: ".", strict: true })
206
- // → Reports any functions in source missing from .ctx
207
- ```
208
-
209
- ### Test Checklists
210
-
211
- Test checklists live in `.ctx.md` files (alongside documentation), not in source code:
16
+ ## Features
212
17
 
213
- ```markdown
214
- ## Tests
215
- - [ ] POST /api/users with valid data201 Created
216
- - [ ] GET /api/users/:id returns user object
217
- - [x] DELETE /api/users/:id 204 No Content
218
- ```
219
-
220
- The agent calls `get_pending_tests`, runs the test, then `mark_test_passed` (which writes `[x]` directly to the `.ctx.md` file). Test state is persistent and survives session restarts.
221
-
222
- ### Monorepo Support
223
-
224
- `discover_sub_projects` scans standard monorepo directories (`packages/`, `apps/`, `services/`, `modules/`, `libs/`, `plugins/`) for sub-projects with `package.json`. Combined with `parseProject({ recursive: true })`, agents can analyze entire monorepos.
225
-
226
- ### Database Analysis
227
-
228
- Scan SQL migrations and code for database schema insights:
229
-
230
- ```javascript
231
- // Extract schema from SQL/migration files
232
- db({ action: "schema", path: "src/" })
233
-
234
- // Find where each table is referenced in code
235
- db({ action: "table_usage", path: "src/", table: "users" })
236
-
237
- // Detect tables defined but never queried
238
- db({ action: "dead_tables", path: "src/" })
239
- ```
240
-
241
- ### Web Dashboard
242
-
243
- > [!NOTE]
244
- > The web dashboard has moved to [**mcp-agent-portal**](https://github.com/rnd-pro/mcp-agent-portal). Install it with `npx mcp-agent-portal` to get the full visual UI: file tree, code viewer, dependency graph, live monitoring, and marketplace.
245
-
246
- ```bash
247
- # Legacy serve command auto-redirects to mcp-agent-portal:
248
- npx project-graph-mcp serve .
249
- ```
250
-
251
- ### Compression Metrics
252
-
253
- Token-level metrics are available project-wide and per-file:
254
-
255
- ```javascript
256
- // Project-wide: how many tokens for the entire codebase
257
- // GET /api/compression-stats
258
- // → { files: 45, codeTok: 47000, ctxTok: 9500, totalTok: 56500 }
259
-
260
- // Per-file: shown in code viewer header
261
- // 2054 + 527 ctx = 2581 → 3340 tok (23% savings)
262
- ```
263
-
264
- ### Performance
265
-
266
- - **Batch concurrency** — `generate_context_docs` processes 5 files in parallel
267
- - **Quick health check** — `get_analysis_summary` runs only cached per-file metrics (skips expensive cross-file analysis)
268
- - **Streaming analysis** — `getFullAnalysisStreaming` yields results incrementally as each sub-analysis completes
269
-
270
- ### Custom Rules & Framework References
271
-
272
- 11 pre-built rulesets (86 rules) for React 18/19, Vue 3, Next.js 15, Express 5, Fastify 5, NestJS 10, TypeScript 5, Node.js 22, and [Symbiote.js](https://github.com/symbiotejs/symbiote.js). The server auto-detects your project type and returns adapted documentation via `get_framework_reference`.
273
-
274
- Custom project conventions can be added in the `rules/` directory or configured by the agent via `set_custom_rule`.
275
-
276
- ### Response Hints
277
-
278
- Every tool response includes contextual coaching — if the agent finds a massive function, the server suggests checking its complexity. After expanding a class, it hints to explore dependencies.
279
-
280
- ### Security
281
-
282
- **Path Traversal Protection** — all incoming paths are validated using `resolve` and `startsWith`. The agent cannot escape the working directory. An attempt to read `../../etc/passwd` returns a direct error.
18
+ - **Project Skeleton** — AST-based graph with 10-50x compression, minified JSON representation of your entire codebase
19
+ - **Compact Code Mode** — project-wide `compact`/`beautify`, agents read and edit minified source directly (↓40% tokens both ways)
20
+ - **AI Context Layer** one call loads skeleton + docs + compressed files; progressive loading (Overview Focus)
21
+ - **Code Quality Analysis** dead code, complexity, duplicates, large files, legacy patterns, JSDoc consistency, Health Score (0-100)
22
+ - **Multi-Language Parsers** — JavaScript (AST/Acorn), TypeScript, Python, Go (regex-based)
23
+ - **Doc Dialect** — auto-generated `.ctx` documentation with AST signatures, staleness detection, self-enriching `@enrich` markers
24
+ - **Database Analysis** — schema extraction from SQL migrations, table usage, dead tables
25
+ - **Test Checklists** persistent test state in `.ctx.md` files, agent-driven `mark_test_passed`
26
+ - **Monorepo Support** — auto-discovery of sub-projects in `packages/`, `apps/`, `services/`
27
+ - **Framework Rules** — 11 rulesets (86 rules) for React, Vue, Next.js, Express, NestJS, TypeScript, Node.js, Symbiote.js
28
+ - **Security** — path traversal protection on all operations
283
29
 
284
30
  ## Quick Start
285
31
 
@@ -291,19 +37,6 @@ npx -y project-graph-mcp config
291
37
 
292
38
  Copy the output JSON into your IDE's MCP config file, then restart.
293
39
 
294
- #### Grouped Tools (v2.0)
295
-
296
- v2.0 uses 18 domain-grouped tools instead of 49 individual endpoints. Grouped tools use an `action` parameter:
297
-
298
- ```javascript
299
- navigate({ action: "expand", symbol: "MyClass" })
300
- analyze({ action: "complexity", path: "src/" })
301
- docs({ action: "generate", path: ".", scope: "focus" })
302
- compact({ action: "compact_file", path: "src/parser.js" })
303
- ```
304
-
305
- 10 standalone tools (`get_skeleton`, `get_ai_context`, `invalidate_cache`, etc.) remain unchanged.
306
-
307
40
  <details>
308
41
  <summary>Where is my MCP config file?</summary>
309
42
 
@@ -315,7 +48,7 @@ compact({ action: "compact_file", path: "src/parser.js" })
315
48
  | Windsurf | `.windsurf/mcp.json` |
316
49
  | Claude Code | Run: `claude mcp add project-graph npx -y project-graph-mcp` |
317
50
 
318
- See **[CONFIGURATION.md](CONFIGURATION.md)** for all supported IDEs (Antigravity, Gemini CLI, Cursor, VS Code, Zed, Claude Desktop, OpenCode, Jenova, Firebase Genkit, NVIDIA AIQ).
51
+ See **[CONFIGURATION.md](CONFIGURATION.md)** for all supported IDEs.
319
52
 
320
53
  </details>
321
54
 
@@ -326,17 +59,13 @@ See **[CONFIGURATION.md](CONFIGURATION.md)** for all supported IDEs (Antigravity
326
59
  git clone --recursive https://github.com/rnd-pro/project-graph-mcp
327
60
  cd project-graph-mcp
328
61
  npm install
329
- # Use "node /path/to/project-graph-mcp/src/network/server.js" as the command in MCP config
330
62
  ```
331
63
 
332
- > **Note:** The `--recursive` flag is required to fetch the `vendor/symbiote-node` submodule. If you already cloned without it, run:
333
- > ```bash
334
- > git submodule update --init --recursive
335
- > ```
64
+ > **Note:** The `--recursive` flag is required to fetch the `vendor/symbiote-node` submodule.
336
65
 
337
66
  </details>
338
67
 
339
- ## CLI
68
+ ### CLI
340
69
 
341
70
  ```bash
342
71
  npx project-graph-mcp skeleton src/ # Project skeleton
@@ -344,19 +73,20 @@ npx project-graph-mcp expand SN # Expand minified symbol
344
73
  npx project-graph-mcp deps SNG # Get dependencies
345
74
  npx project-graph-mcp deadcode src/ # Find unused code
346
75
  npx project-graph-mcp complexity src/ # Cyclomatic complexity
347
- npx project-graph-mcp similar src/ # Find duplicates
348
- npx project-graph-mcp pending src/ # List pending tests
76
+ npx project-graph-mcp analyze src/ # Full health analysis
349
77
  npx project-graph-mcp compress src/f.js # Compress file for AI
350
78
  npx project-graph-mcp docs src/ # Project docs (doc-dialect)
351
79
  npx project-graph-mcp generate-ctx src/ # Generate .context/ docs
352
- npx project-graph-mcp validate-ctx . # Validate .ctx ↔ source
353
- npx project-graph-mcp mode . # Show current editing mode
354
- npx project-graph-mcp compact-migrate . # Migrate formatted -> compact (git must be clean)
355
- npx project-graph-mcp set-mode . 1 # Set mode (1=compact*, 2=full)
356
- npx project-graph-mcp serve . # Start web dashboard
80
+ npx project-graph-mcp compact src/ --dry-run # Compact all files
81
+ npx project-graph-mcp mode . # Show current editing mode
357
82
  npx project-graph-mcp help # All commands
358
83
  ```
359
84
 
85
+ ### Web Dashboard
86
+
87
+ > [!NOTE]
88
+ > The web dashboard has moved to [**mcp-agent-portal**](https://github.com/rnd-pro/mcp-agent-portal). Install it with `npx mcp-agent-portal` to get the full visual UI: file tree, code viewer, dependency graph, live monitoring, and marketplace.
89
+
360
90
  ## MCP Ecosystem
361
91
 
362
92
  Best used as part of [**mcp-agent-portal**](https://github.com/rnd-pro/mcp-agent-portal) — a unified MCP aggregator that combines all RND-PRO servers behind a single config entry:
@@ -390,10 +120,9 @@ npx -y agent-pool-mcp config
390
120
  ## Documentation
391
121
 
392
122
  - [CONFIGURATION.md](CONFIGURATION.md) — Setup for all supported IDEs
123
+ - [GUIDE.md](GUIDE.md) — Comprehensive usage guide with all tools
393
124
  - [ARCHITECTURE.md](ARCHITECTURE.md) — Source code structure
394
125
  - [AGENT_ROLE.md](docs/examples/AGENT_ROLE.md) — Full system prompt for agents
395
- - [AGENT_ROLE_MINIMAL.md](docs/examples/AGENT_ROLE_MINIMAL.md) — Minimal variant (agent self-discovers)
396
- - [GUIDE.md](GUIDE.md) — Comprehensive usage guide with all tools
397
126
  - [ROADMAP.md](docs/ROADMAP.md) — Feature roadmap and backlog
398
127
 
399
128
  ## Related Projects
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-graph-mcp",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "type": "module",
5
5
  "description": "MCP server for AI agents — project graph, code quality analysis, visual web explorer. JS, TS, Python, Go.",
6
6
  "main": "src/network/server.js",