project-graph-mcp 2.4.1 → 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 +42 -306
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,281 +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
- Includes a built-in [Web Dashboard](#web-dashboard) (`npx project-graph-mcp serve`) to visualize token metrics and compact ⇄ raw code in real-time.
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:
212
-
213
- ```markdown
214
- ## Tests
215
- - [ ] POST /api/users with valid data → 201 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
- Every project-graph-mcp instance includes a built-in web UI at `http://localhost:{port}/`:
244
-
245
- - **Multi-project dashboard** — overview of all registered projects with token metrics
246
- - **File tree** — navigate project structure
247
- - **Code viewer** — compact/raw toggle with syntax highlighting and per-file compression stats
248
- - **Dependency graph** — visual dependency exploration
249
- - **Health panel** — analysis results
250
- - **Live monitor** — real-time agent activity via WebSocket
251
-
252
-
253
-
254
- With the optional gateway, all projects are accessible under `http://project-graph.local/{project-name}/`.
16
+ ## Features
255
17
 
256
- ### Compression Metrics
257
-
258
- Token-level metrics are available project-wide and per-file:
259
-
260
- ```javascript
261
- // Project-wide: how many tokens for the entire codebase
262
- // GET /api/compression-stats
263
- // { files: 45, codeTok: 47000, ctxTok: 9500, totalTok: 56500 }
264
-
265
- // Per-file: shown in code viewer header
266
- // 2054 + 527 ctx = 2581 3340 tok (23% savings)
267
- ```
268
-
269
- ### Performance
270
-
271
- - **Batch concurrency** — `generate_context_docs` processes 5 files in parallel
272
- - **Quick health check** — `get_analysis_summary` runs only cached per-file metrics (skips expensive cross-file analysis)
273
- - **Streaming analysis** — `getFullAnalysisStreaming` yields results incrementally as each sub-analysis completes
274
-
275
- ### Custom Rules & Framework References
276
-
277
- 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`.
278
-
279
- Custom project conventions can be added in the `rules/` directory or configured by the agent via `set_custom_rule`.
280
-
281
- ### Response Hints
282
-
283
- 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.
284
-
285
- ### Security
286
-
287
- **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
288
29
 
289
30
  ## Quick Start
290
31
 
@@ -296,19 +37,6 @@ npx -y project-graph-mcp config
296
37
 
297
38
  Copy the output JSON into your IDE's MCP config file, then restart.
298
39
 
299
- #### Grouped Tools (v2.0)
300
-
301
- v2.0 uses 18 domain-grouped tools instead of 49 individual endpoints. Grouped tools use an `action` parameter:
302
-
303
- ```javascript
304
- navigate({ action: "expand", symbol: "MyClass" })
305
- analyze({ action: "complexity", path: "src/" })
306
- docs({ action: "generate", path: ".", scope: "focus" })
307
- compact({ action: "compact_file", path: "src/parser.js" })
308
- ```
309
-
310
- 10 standalone tools (`get_skeleton`, `get_ai_context`, `invalidate_cache`, etc.) remain unchanged.
311
-
312
40
  <details>
313
41
  <summary>Where is my MCP config file?</summary>
314
42
 
@@ -320,7 +48,7 @@ compact({ action: "compact_file", path: "src/parser.js" })
320
48
  | Windsurf | `.windsurf/mcp.json` |
321
49
  | Claude Code | Run: `claude mcp add project-graph npx -y project-graph-mcp` |
322
50
 
323
- 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.
324
52
 
325
53
  </details>
326
54
 
@@ -331,17 +59,13 @@ See **[CONFIGURATION.md](CONFIGURATION.md)** for all supported IDEs (Antigravity
331
59
  git clone --recursive https://github.com/rnd-pro/project-graph-mcp
332
60
  cd project-graph-mcp
333
61
  npm install
334
- # Use "node /path/to/project-graph-mcp/src/network/server.js" as the command in MCP config
335
62
  ```
336
63
 
337
- > **Note:** The `--recursive` flag is required to fetch the `vendor/symbiote-node` submodule. If you already cloned without it, run:
338
- > ```bash
339
- > git submodule update --init --recursive
340
- > ```
64
+ > **Note:** The `--recursive` flag is required to fetch the `vendor/symbiote-node` submodule.
341
65
 
342
66
  </details>
343
67
 
344
- ## CLI
68
+ ### CLI
345
69
 
346
70
  ```bash
347
71
  npx project-graph-mcp skeleton src/ # Project skeleton
@@ -349,33 +73,45 @@ npx project-graph-mcp expand SN # Expand minified symbol
349
73
  npx project-graph-mcp deps SNG # Get dependencies
350
74
  npx project-graph-mcp deadcode src/ # Find unused code
351
75
  npx project-graph-mcp complexity src/ # Cyclomatic complexity
352
- npx project-graph-mcp similar src/ # Find duplicates
353
- npx project-graph-mcp pending src/ # List pending tests
76
+ npx project-graph-mcp analyze src/ # Full health analysis
354
77
  npx project-graph-mcp compress src/f.js # Compress file for AI
355
78
  npx project-graph-mcp docs src/ # Project docs (doc-dialect)
356
79
  npx project-graph-mcp generate-ctx src/ # Generate .context/ docs
357
- npx project-graph-mcp validate-ctx . # Validate .ctx ↔ source
358
- npx project-graph-mcp mode . # Show current editing mode
359
- npx project-graph-mcp compact-migrate . # Migrate formatted -> compact (git must be clean)
360
- npx project-graph-mcp set-mode . 1 # Set mode (1=compact*, 2=full)
361
- 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
362
82
  npx project-graph-mcp help # All commands
363
83
  ```
364
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
+
365
90
  ## MCP Ecosystem
366
91
 
367
- Best used together with [**agent-pool-mcp**](https://www.npmjs.com/package/agent-pool-mcp) — multi-agent task delegation via [Gemini CLI](https://github.com/google-gemini/gemini-cli):
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:
368
93
 
369
- | Layer | project-graph-mcp | agent-pool-mcp |
370
- |-------|-------------------|----------------|
371
- | **Primary IDE agent** | Navigates codebase, runs analysis | Delegates tasks, consults peer |
372
- | **Gemini CLI workers** | Available as MCP tool inside workers | Executes delegated tasks |
94
+ ```json
95
+ {
96
+ "mcpServers": {
97
+ "agent-portal": {
98
+ "command": "npx",
99
+ "args": ["-y", "mcp-agent-portal"]
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ > [!TIP]
106
+ > One entry replaces separate configs for project-graph-mcp, agent-pool-mcp, and any other child servers.
107
+
108
+ Also works standalone or alongside [**agent-pool-mcp**](https://www.npmjs.com/package/agent-pool-mcp) — multi-agent task delegation:
373
109
 
374
110
  ```bash
375
111
  # Generate configs with correct paths for both servers:
376
112
  npx -y project-graph-mcp config
377
113
  npx -y agent-pool-mcp config
378
- # Merge both outputs into your IDE's MCP config file.
114
+ # Or use mcp-agent-portal which bundles both.
379
115
  ```
380
116
 
381
117
  > [!IMPORTANT]
@@ -384,13 +120,13 @@ npx -y agent-pool-mcp config
384
120
  ## Documentation
385
121
 
386
122
  - [CONFIGURATION.md](CONFIGURATION.md) — Setup for all supported IDEs
123
+ - [GUIDE.md](GUIDE.md) — Comprehensive usage guide with all tools
387
124
  - [ARCHITECTURE.md](ARCHITECTURE.md) — Source code structure
388
125
  - [AGENT_ROLE.md](docs/examples/AGENT_ROLE.md) — Full system prompt for agents
389
- - [AGENT_ROLE_MINIMAL.md](docs/examples/AGENT_ROLE_MINIMAL.md) — Minimal variant (agent self-discovers)
390
- - [GUIDE.md](GUIDE.md) — Comprehensive usage guide with all tools
391
126
  - [ROADMAP.md](docs/ROADMAP.md) — Feature roadmap and backlog
392
127
 
393
128
  ## Related Projects
129
+ - [mcp-agent-portal](https://github.com/rnd-pro/mcp-agent-portal) — Unified MCP aggregator + web dashboard + AI agent runtime
394
130
  - [agent-pool-mcp](https://github.com/rnd-pro/agent-pool-mcp) — Multi-agent orchestration via Gemini CLI
395
131
  - [Symbiote.js](https://github.com/symbiotejs/symbiote.js) — Isomorphic Reactive Web Components framework
396
132
  - [JSDA-Kit](https://github.com/rnd-pro/jsda-kit) — SSG/SSR toolkit for modern web applications
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-graph-mcp",
3
- "version": "2.4.1",
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",