@angular-modernizer/adapter-mcp 1.0.0 → 1.1.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.
Files changed (129) hide show
  1. package/README.md +78 -64
  2. package/dist/cli.js +8 -0
  3. package/dist/core/project-analyzer.d.ts +3 -12
  4. package/dist/core/project-analyzer.js +3 -12
  5. package/dist/index.d.ts +118 -3
  6. package/dist/index.js +46 -3
  7. package/dist/mcp-watcher.d.ts +28 -8
  8. package/dist/mcp-watcher.js +7 -7
  9. package/dist/scan-host/scan-host.d.ts +119 -0
  10. package/dist/scan-host/scan-host.js +376 -0
  11. package/dist/scan-host/scan-protocol.d.ts +35 -0
  12. package/dist/scan-host/scan-protocol.js +6 -0
  13. package/dist/scan-host/scan-worker.d.ts +14 -0
  14. package/dist/scan-host/scan-worker.js +48 -0
  15. package/dist/server/limited-stdio-transport.d.ts +7 -0
  16. package/dist/server/mcp-server.d.ts +11 -7
  17. package/dist/server/mcp-server.js +4 -7
  18. package/dist/server/sdk-server.d.ts +1 -0
  19. package/dist/server/tool-registry.d.ts +3 -7
  20. package/dist/server/tool-registry.js +1 -7
  21. package/dist/streaming/progress-store.d.ts +22 -5
  22. package/dist/streaming/progress-store.js +9 -5
  23. package/dist/tools/analyze-build-impact.d.ts +56 -34
  24. package/dist/tools/analyze-build-impact.js +30 -25
  25. package/dist/tools/analyze-core-to-shared.d.ts +42 -12
  26. package/dist/tools/analyze-core-to-shared.js +11 -10
  27. package/dist/tools/analyze-parser-performance.d.ts +23 -22
  28. package/dist/tools/analyze-parser-performance.js +20 -18
  29. package/dist/tools/analyze-project.d.ts +82 -12
  30. package/dist/tools/analyze-project.js +98 -101
  31. package/dist/tools/check-incremental-compatibility.d.ts +13 -11
  32. package/dist/tools/check-incremental-compatibility.js +11 -8
  33. package/dist/tools/collect-feedback.d.ts +41 -26
  34. package/dist/tools/collect-feedback.js +32 -23
  35. package/dist/tools/compare-health.d.ts +76 -19
  36. package/dist/tools/compare-health.js +26 -19
  37. package/dist/tools/extract-libraries.d.ts +44 -20
  38. package/dist/tools/extract-libraries.js +16 -17
  39. package/dist/tools/find-angular-symbol.d.ts +25 -23
  40. package/dist/tools/find-angular-symbol.js +17 -14
  41. package/dist/tools/find-component-hosts.d.ts +31 -25
  42. package/dist/tools/find-component-hosts.js +24 -21
  43. package/dist/tools/find-usages.d.ts +23 -21
  44. package/dist/tools/find-usages.js +19 -16
  45. package/dist/tools/get-bootstrap-execution.d.ts +33 -25
  46. package/dist/tools/get-bootstrap-execution.js +25 -22
  47. package/dist/tools/get-call-graph.d.ts +18 -13
  48. package/dist/tools/get-call-graph.js +24 -21
  49. package/dist/tools/get-operation-progress-tool.d.ts +12 -6
  50. package/dist/tools/get-operation-progress-tool.js +11 -6
  51. package/dist/tools/get-operation-progress.d.ts +26 -0
  52. package/dist/tools/helpers/analysis-output.d.ts +5 -0
  53. package/dist/tools/helpers/batch-kernel.d.ts +14 -0
  54. package/dist/tools/helpers/batch-kernel.js +12 -0
  55. package/dist/tools/helpers/compact-output.d.ts +2 -1
  56. package/dist/tools/helpers/compact-output.js +2 -1
  57. package/dist/tools/helpers/health-delta.d.ts +27 -14
  58. package/dist/tools/helpers/health-delta.js +11 -14
  59. package/dist/tools/helpers/project-cache.d.ts +50 -34
  60. package/dist/tools/helpers/project-cache.js +33 -34
  61. package/dist/tools/helpers/rule-runner.d.ts +23 -16
  62. package/dist/tools/helpers/rule-runner.js +24 -17
  63. package/dist/tools/helpers/scan-engine.d.ts +107 -0
  64. package/dist/tools/helpers/scan-engine.js +197 -0
  65. package/dist/tools/helpers/suggestion-generator.d.ts +9 -13
  66. package/dist/tools/helpers/suggestion-generator.js +0 -12
  67. package/dist/tools/helpers/tool-cache.d.ts +11 -0
  68. package/dist/tools/helpers/tool-cache.js +15 -0
  69. package/dist/tools/helpers/tool-context.d.ts +11 -8
  70. package/dist/tools/helpers/tool-context.js +5 -8
  71. package/dist/tools/inspect-form-group.d.ts +32 -25
  72. package/dist/tools/inspect-form-group.js +24 -21
  73. package/dist/tools/inspect-i18n.d.ts +28 -22
  74. package/dist/tools/inspect-i18n.js +20 -17
  75. package/dist/tools/inspect-template.d.ts +31 -24
  76. package/dist/tools/inspect-template.js +23 -20
  77. package/dist/tools/learn-patterns.d.ts +88 -12
  78. package/dist/tools/learn-patterns.js +17 -11
  79. package/dist/tools/list-imports.d.ts +42 -25
  80. package/dist/tools/list-imports.js +23 -20
  81. package/dist/tools/orchestrate-migration.d.ts +31 -9
  82. package/dist/tools/orchestrate-migration.js +12 -7
  83. package/dist/tools/parse-stack-trace.d.ts +23 -21
  84. package/dist/tools/parse-stack-trace.js +10 -7
  85. package/dist/tools/plan-migration.d.ts +65 -25
  86. package/dist/tools/plan-migration.js +19 -19
  87. package/dist/tools/resolve-type.d.ts +19 -9
  88. package/dist/tools/resolve-type.js +19 -11
  89. package/dist/tools/review-feedback.d.ts +27 -24
  90. package/dist/tools/review-feedback.js +24 -20
  91. package/dist/tools/rollback-changes.d.ts +13 -9
  92. package/dist/tools/rollback-changes.js +10 -7
  93. package/dist/tools/run-angular-cli.d.ts +12 -10
  94. package/dist/tools/run-angular-cli.js +11 -8
  95. package/dist/tools/run-build.d.ts +13 -11
  96. package/dist/tools/run-build.js +11 -8
  97. package/dist/tools/run-schematic.d.ts +12 -10
  98. package/dist/tools/run-schematic.js +11 -8
  99. package/dist/tools/scan-all.d.ts +69 -12
  100. package/dist/tools/scan-all.js +55 -122
  101. package/dist/tools/scan-angular.d.ts +41 -9
  102. package/dist/tools/scan-angular.js +66 -135
  103. package/dist/tools/scan-architecture.d.ts +75 -14
  104. package/dist/tools/scan-architecture.js +180 -185
  105. package/dist/tools/scan-solid.d.ts +40 -9
  106. package/dist/tools/scan-solid.js +64 -133
  107. package/dist/tools/search-codebase.d.ts +30 -24
  108. package/dist/tools/search-codebase.js +13 -10
  109. package/dist/tools/server-status.d.ts +116 -24
  110. package/dist/tools/server-status.js +85 -26
  111. package/dist/tools/suggest-improvements.d.ts +22 -19
  112. package/dist/tools/suggest-improvements.js +21 -17
  113. package/dist/tools/trace-output-flow.d.ts +32 -25
  114. package/dist/tools/trace-output-flow.js +24 -21
  115. package/dist/tools/transform-code.d.ts +71 -10
  116. package/dist/tools/transform-code.js +60 -42
  117. package/dist/tools/validate-before-transform.d.ts +24 -9
  118. package/dist/tools/validate-before-transform.js +10 -7
  119. package/dist/tools/validate-project-compatibility.d.ts +18 -13
  120. package/dist/tools/validate-project-compatibility.js +17 -11
  121. package/dist/tools/validate-transformation.d.ts +28 -11
  122. package/dist/tools/validate-transformation.js +14 -8
  123. package/dist/tools/verify-citations.d.ts +37 -16
  124. package/dist/tools/verify-citations.js +19 -16
  125. package/dist/types.d.ts +40 -10
  126. package/dist/types.js +0 -5
  127. package/package.json +12 -18
  128. package/dist/tools/shared/scan-types.d.ts +0 -200
  129. package/dist/tools/shared/scan-types.js +0 -7
package/README.md CHANGED
@@ -17,33 +17,41 @@ Tools are designed for LLM consumption with structured I/O, pre-validation, auto
17
17
  ```
18
18
  AI Assistant (Claude/Copilot)
19
19
  |
20
- | JSON-RPC 2.0 (stdio)
20
+ | MCP over stdio (JSON-RPC 2.0, MCP TypeScript SDK)
21
+ | protocol eras 2025-06-18 / 2025-11-25 (initialize), 2026-07-28 (server/discover)
21
22
  v
22
23
  MCP Server (adapter-mcp)
23
24
  - 41 Tools (analysis, planning, transformation,
24
- build and validation, feedback, bug investigation)
25
- - Shared ts-morph ProjectCache
26
- - Real-time Progress Monitoring
27
- - Parameter Validation
28
- - Result Serialization
29
- |
30
- | TypeScript API
31
- v
32
- Core Platform (Kernel + Plugins)
33
- - Analysis Rules (52 rules total)
34
- - Architecture: 17 rules
35
- - Angular: 28 rules
36
- - SOLID: 7 rules
25
+ build and validation, rollback, feedback, bug investigation)
26
+ - Input validation against closed JSON schemas
27
+ - structuredContent validated against each outputSchema, plus a summary text
28
+ - Native MCP progress and cancellation
29
+ - Shared ts-morph ProjectCache (investigation tools, build impact, plan-migration)
30
+ | |
31
+ | Kernel per call | direct calls
32
+ | (scans, transform-code, ...) | (14 investigation tools)
33
+ v |
34
+ Core Platform (Kernel + Plugins) |
35
+ - Analysis rules (52) |
36
+ - Architecture: 17 |
37
+ - Angular: 28 |
38
+ - SOLID: 7 |
37
39
  - Transformations (26 types via transform-code)
38
- - Caching
39
- - Orchestration
40
+ - Safety envelope: backup, type check, rollback
41
+ - Caching, worker parallelism, workflow engine
42
+ | |
43
+ | context.api |
44
+ v v
45
+ Public API (@angular-modernizer/api)
46
+ - Analysis and transformation building blocks
47
+ - Investigation: usages, call graph, types, templates, forms, i18n
40
48
  |
41
- | ts-morph AST
49
+ | ts-morph AST, TypeScript type checker, @angular/compiler (templates)
42
50
  v
43
- TypeScript Project
44
- - Source Files
45
- - Type Checking
46
- - Semantic Analysis
51
+ TypeScript / Angular Project
52
+ - Source files and templates
53
+ - Type checking
54
+ - Semantic analysis
47
55
  ```
48
56
 
49
57
  ### Protocol
@@ -82,12 +90,10 @@ Create `.angular-modernizer.json` in your project root. Only `build` is required
82
90
  },
83
91
  "tools": {
84
92
  "analyze-project": {
85
- "excludePatterns": ["**/node_modules/**", "**/dist/**"],
86
- "orchestration": { "parallel": true, "autoSelectMode": true }
93
+ "excludePatterns": ["**/node_modules/**", "**/dist/**"]
87
94
  },
88
95
  "scan-architecture": {
89
- "maxFiles": 500,
90
- "orchestration": { "parallel": true, "enableProgress": true }
96
+ "maxFiles": 500
91
97
  }
92
98
  }
93
99
  }
@@ -119,7 +125,8 @@ Or point a client at a local build, e.g. `.mcp.json` / `claude_desktop_config.js
119
125
  ```
120
126
 
121
127
  `--expose-gc` lets the ProjectCache collect garbage after evicting a project. `cli.js` also takes
122
- `--max-projects N` and `--max-heap-mb N` (defaults 3 and 2048). A running client keeps the old code in memory
128
+ `--max-projects N` and `--max-heap-mb N` (defaults 3 and 2048; the heap limit also applies to the scan worker) and
129
+ `--scan-worker 0` (scans on the main thread instead of a worker thread). A running client keeps the old code in memory
123
130
  after a rebuild; reconnect, or check `server-status` (`build.rebuiltSinceStart`).
124
131
 
125
132
  ---
@@ -139,7 +146,7 @@ after a rebuild; reconnect, or check `server-status` (`build.rebuiltSinceStart`)
139
146
  | analyze-core-to-shared | Dependency violation analysis | - | yes | 3-10s |
140
147
  | analyze-parser-performance | Parser metrics from feedback sessions | - | no | varies |
141
148
  | extract-libraries | Library extraction candidates (shared folders, secondary entry points) | - | no | varies |
142
- | learn-patterns | ML-based pattern discovery | - | yes | 10-60s |
149
+ | learn-patterns | Pattern discovery with AST heuristics, stored in a knowledge base | - | yes | 10-60s |
143
150
 
144
151
  The scans, analyze-project, analyze-core-to-shared and extract-libraries keep their numbers in `counts` (for the scans `totalViolations`, `analyzedFiles`, `bySeverity`, `byCategory`, `byRule`, always over all violations); `summary` is a short text with the totals, the largest rules and categories, the first five entries and the returned page. `violations` holds only the page set by `maxResults` and `resultOffset`, `pagination` says what was cut.
145
152
 
@@ -227,6 +234,14 @@ Key features:
227
234
  - Generates custom analysis rules from patterns
228
235
  - Tracks pattern evolution across scans
229
236
 
237
+ ### Feedback Tools
238
+
239
+ | Tool | Purpose | Cache | Time |
240
+ |-|-|-|-|
241
+ | collect-feedback | Store the outcome of a transformation or a corrected analysis result | no | <1s |
242
+ | review-feedback | Patterns, quality trends and warnings from stored feedback | no | varies |
243
+ | suggest-improvements | Rule adjustment suggestions from feedback patterns | no | varies |
244
+
230
245
  #### collect-feedback
231
246
 
232
247
  Manually collect transformation feedback for AI learning with privacy-first design.
@@ -325,6 +340,7 @@ Returns:
325
340
  - `insights`: array of detected patterns with confidence scores
326
341
  - `qualityWarnings`: warnings about low-quality feedback
327
342
  - `sourcesRead`: locations where feedback was read from
343
+ - `analysisRecords`, `analysisInsights`: number of analysis records and the insights drawn from them
328
344
 
329
345
  #### suggest-improvements
330
346
 
@@ -354,19 +370,22 @@ Usage:
354
370
 
355
371
  Returns:
356
372
  - `ruleId`: rule these suggestions apply to
373
+ - `currentPerformance`: `successRate`, `avgDuration`, `qualityImprovement` of the rule
357
374
  - `suggestions`: array of suggestions sorted by confidence (descending)
358
- - `totalFeedback`: number of feedback records analyzed
359
- - `successRate`: current rule success rate
375
+ - `feedbackCount`: number of feedback records analyzed
376
+ - `analysisFeedbackCount`: number of analysis records for this tool
377
+ - `sourcesRead`: locations where feedback was read from
360
378
 
361
379
  Example suggestion:
362
380
 
363
381
  ```json
364
382
  {
365
383
  "type": "parameter-adjustment",
366
- "confidence": 0.85,
367
- "suggestion": "Lower confidence threshold from 0.95 to 0.85",
368
- "reasoning": "3 high-confidence failures detected, threshold too aggressive",
369
- "expectedImprovement": "Reduce false positives by 40%",
384
+ "description": "Lower confidence threshold for this rule",
385
+ "reasoning": "3 failures occurred with high confidence (>0.8), suggesting overconfidence in predictions",
386
+ "confidence": 0.8,
387
+ "expectedImprovement": "Reduce false positives by 21%",
388
+ "implementation": "Adjust rule confidence threshold from 0.8 to 0.9. Review decision-making logic to improve accuracy.",
370
389
  "requiresApproval": true
371
390
  }
372
391
  ```
@@ -547,6 +566,8 @@ Cache statistics example (second run, nothing changed):
547
566
 
548
567
  ### Intelligent Mode Selection
549
568
 
569
+ > **Deprecated in 1.1:** `parallel` and `incremental` of analyze-project and scan-architecture select the old WorkerPool path, which will be removed in 2.0. On a large app (371 files) it was no faster than the default path (10.8-12.1 vs 10.3-13.1 s), blocked the server for up to 10.7 s and took about four times the memory; before 1.1 the automatic mode selection could fail with `Not implemented yet`. The default path runs the analysis in a scan worker. Leave these options unset; the text below describes the old path.
570
+
550
571
  The orchestration system automatically selects between Promise-based and worker thread parallelism based on project complexity score:
551
572
 
552
573
  ```
@@ -601,46 +622,38 @@ Example evolution output:
601
622
 
602
623
  ### Tool-Specific Configuration
603
624
 
604
- Create `.angular-modernizer.json`:
625
+ Per-tool defaults go under `tools` in `.angular-modernizer.json`; arguments of a call override them. The schema lists
626
+ the configurable tools (scan-architecture, scan-all, scan-angular, scan-solid, analyze-project, transform-code,
627
+ transform-code-batch, run-build, validate-transformation, collect-feedback, review-feedback, suggest-improvements) and
628
+ their keys; `orchestration` takes a different set of keys per tool. Other tools, such as learn-patterns, take their
629
+ options per call only.
605
630
 
606
631
  ```json
607
632
  {
608
- "analyze-project": {
609
- "rootPath": ".",
610
- "excludePatterns": ["**/node_modules/**", "**/dist/**"],
611
- "maxResults": 1000,
612
- "orchestration": {
613
- "parallel": true,
614
- "autoSelectMode": true,
615
- "enableProgress": true
616
- }
633
+ "build": {
634
+ "command": "ng build",
635
+ "mode": "incremental"
617
636
  },
618
- "scan-architecture": {
619
- "rootPath": ".",
620
- "maxFiles": 500,
621
- "includeAutoFixes": true,
622
- "orchestration": {
623
- "parallel": true,
624
- "incremental": false,
625
- "autoSelectMode": true,
626
- "enableProgress": true,
627
- "timeout": 120000
637
+ "tools": {
638
+ "analyze-project": {
639
+ "excludePatterns": ["**/node_modules/**", "**/dist/**"],
640
+ "maxResults": 1000
641
+ },
642
+ "scan-architecture": {
643
+ "maxFiles": 500,
644
+ "includeAutoFixes": true
645
+ },
646
+ "review-feedback": {
647
+ "source": "both",
648
+ "minConfidence": 0.7
628
649
  }
629
- },
630
- "learn-patterns": {
631
- "targetPath": ".",
632
- "categories": ["all"],
633
- "minOccurrences": 3,
634
- "enableLearning": true,
635
- "generateStyleProfile": true,
636
- "respectCodebaseStyle": true
637
650
  }
638
651
  }
639
652
  ```
640
653
 
641
654
  ### Cache Configuration
642
655
 
643
- Caching is enabled by default for analysis tools:
656
+ The scan tools cache per file with these built-in settings (not configurable):
644
657
 
645
658
  ```typescript
646
659
  cacheConfig: {
@@ -670,14 +683,15 @@ rm -rf .angular-modernizer-cache
670
683
 
671
684
  ### Orchestration Tuning
672
685
 
673
- For large projects (500+ files):
686
+ > **Deprecated in 1.1:** `parallel` and `incremental` of analyze-project and scan-architecture select the old WorkerPool path, which will be removed in 2.0. On a large app (371 files) it was no faster than the default path (10.8-12.1 vs 10.3-13.1 s), blocked the server for up to 10.7 s and took about four times the memory; before 1.1 the automatic mode selection could fail with `Not implemented yet`. The default path runs the analysis in a scan worker. Leave these options unset; the text below describes the old path.
687
+
688
+ For large projects (500+ files), in `tools.scan-architecture` (or per call as the `orchestration` argument):
674
689
 
675
690
  ```json
676
691
  {
677
692
  "orchestration": {
678
693
  "parallel": true,
679
694
  "autoSelectMode": true,
680
- "maxWorkers": 6,
681
695
  "enableProgress": true,
682
696
  "enableMonitoring": true,
683
697
  "resourceLimits": {
package/dist/cli.js CHANGED
@@ -10,6 +10,7 @@ import { fileURLToPath } from 'node:url';
10
10
  import { MCPServer } from './server/mcp-server.js';
11
11
  import { isDebugEnabled } from './mcp-watcher.js';
12
12
  import { routeConsoleToStderr } from './server/stdio-guard.js';
13
+ import { configureScanHost, parseScanWorkerSetting } from './scan-host/scan-host.js';
13
14
  import { AnalyzeProjectTool } from './tools/analyze-project.js';
14
15
  import { ScanArchitectureTool } from './tools/scan-architecture.js';
15
16
  import { ScanSolidTool } from './tools/scan-solid.js';
@@ -117,6 +118,13 @@ function main() {
117
118
  cacheLimits.warnings.forEach((w) => console.error(`Project cache: ${w}`));
118
119
  const projects = new ProjectCache(cacheLimits.options);
119
120
  debugLog(`CLI Project cache limits: ${JSON.stringify(projects.limits)}`);
121
+ // Scans analyze in a worker thread (default; --scan-worker 0 or
122
+ // ANGULAR_MODERNIZER_SCAN_WORKER=0 runs them on the main thread), its
123
+ // heap limited to the same --max-heap-mb as the project cache
124
+ const scanWorker = parseScanWorkerSetting(process.argv.slice(2), process.env);
125
+ scanWorker.warnings.forEach((w) => console.error(`Scan worker: ${w}`));
126
+ configureScanHost({ enabled: scanWorker.enabled, maxHeapMb: projects.limits.maxHeapMb });
127
+ debugLog(`CLI Scan worker: ${scanWorker.enabled ? 'on' : 'off'}`);
120
128
  server.registerTool(new AnalyzeProjectTool());
121
129
  server.registerTool(new ScanArchitectureTool());
122
130
  server.registerTool(new ScanSolidTool());
@@ -1,15 +1,3 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Project Analyzer
3
- *
4
- * Core orchestration logic for analyzing Angular projects.
5
- * This module coordinates the Kernel, plugins, and analysis rules
6
- * to perform comprehensive project analysis.
7
- *
8
- * Design Philosophy: "Orchestrate, Don't Implement"
9
- * - This module doesn't contain analysis logic
10
- * - It coordinates existing components (Kernel, plugins, rules)
11
- * - All actual analysis happens in plugin rules
12
- */
13
1
  import { type AnalysisResult } from '@angular-modernizer/plugin-system';
14
2
  /**
15
3
  * Options for project analysis.
@@ -51,6 +39,9 @@ export interface AnalyzeProjectOptions {
51
39
  * 4. Executes all rules in parallel
52
40
  * 5. Collects and returns all analysis results
53
41
  *
42
+ * The function holds no analysis logic of its own; all findings come from
43
+ * the plugin rules.
44
+ *
54
45
  * @param options - Configuration for the analysis
55
46
  * @returns Promise resolving to array of all analysis results
56
47
  * @throws Error if project path is invalid or analysis fails
@@ -1,15 +1,3 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Project Analyzer
3
- *
4
- * Core orchestration logic for analyzing Angular projects.
5
- * This module coordinates the Kernel, plugins, and analysis rules
6
- * to perform comprehensive project analysis.
7
- *
8
- * Design Philosophy: "Orchestrate, Don't Implement"
9
- * - This module doesn't contain analysis logic
10
- * - It coordinates existing components (Kernel, plugins, rules)
11
- * - All actual analysis happens in plugin rules
12
- */
13
1
  import { Kernel } from '@angular-modernizer/core';
14
2
  import { AnalyzerPlugin } from '@angular-modernizer/plugin-analyzer';
15
3
  import { createPublicApi } from '@angular-modernizer/api';
@@ -24,6 +12,9 @@ import { ContextFactory, } from '@angular-modernizer/plugin-system';
24
12
  * 4. Executes all rules in parallel
25
13
  * 5. Collects and returns all analysis results
26
14
  *
15
+ * The function holds no analysis logic of its own; all findings come from
16
+ * the plugin rules.
17
+ *
27
18
  * @param options - Configuration for the analysis
28
19
  * @returns Promise resolving to array of all analysis results
29
20
  * @throws Error if project path is invalid or analysis fails
package/dist/index.d.ts CHANGED
@@ -1,8 +1,51 @@
1
1
  /**
2
- * @angular-modernizer/adapter-mcp - MCP Server Entry Point
2
+ * MCP server of the Angular Modernizer: 41 tools for analysis, migration
3
+ * planning, transformation, build validation, rollback, feedback and bug
4
+ * investigation of Angular projects, served over stdio with the MCP
5
+ * TypeScript SDK.
3
6
  *
4
- * This module provides the Model Context Protocol (MCP) server
5
- * that exposes Angular Modernizer analysis capabilities to AI assistants.
7
+ * @remarks
8
+ * The server speaks both protocol eras on one stdio connection: clients that
9
+ * open with `initialize` get the revision they ask for (2025-06-18,
10
+ * 2025-11-25), clients that open with `server/discover` get 2026-07-28.
11
+ * Arguments are validated against each tool's input schema; every tool
12
+ * answers with `structuredContent` validated against its output schema and a
13
+ * text block with the result's `summary`.
14
+ *
15
+ * Run the server through the `angular-modernizer-mcp` bin (`dist/cli.js`):
16
+ *
17
+ * ```bash
18
+ * npx @angular-modernizer/adapter-mcp
19
+ * claude mcp add angular-modernizer npx @angular-modernizer/adapter-mcp
20
+ * ```
21
+ *
22
+ * `cli.js` takes `--max-projects N` and `--max-heap-mb N` for the shared
23
+ * ts-morph project cache (defaults 3 and 2048 MB, 0 = no heap limit).
24
+ *
25
+ * The package entry exports the building blocks for embedding the server or
26
+ * calling tools directly:
27
+ *
28
+ * - {@link MCPServer}: stdio server lifecycle; register tools, then `start()`.
29
+ * - {@link ToolRegistry}: tool registration and execution.
30
+ * - {@link MCPTool}: the tool contract every tool class implements, with
31
+ * {@link ToolContext} for cancellation and progress.
32
+ * - The tool classes, one per MCP tool, e.g. {@link ScanAllTool},
33
+ * {@link TransformCodeTool}, {@link FindUsagesTool}, {@link ServerStatusTool}.
34
+ * - {@link ProgressStore}: operation store of the deprecated streaming path.
35
+ * - {@link startMCPWatcher}: debug log and health check, enabled with
36
+ * `ANGULAR_MODERNIZER_DEBUG`.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * import { MCPServer, ScanAllTool, FindUsagesTool } from '@angular-modernizer/adapter-mcp';
41
+ *
42
+ * const server = new MCPServer();
43
+ * server.registerTool(new ScanAllTool());
44
+ * server.registerTool(new FindUsagesTool());
45
+ * server.start();
46
+ * ```
47
+ *
48
+ * @packageDocumentation
6
49
  */
7
50
  export { MCPServer } from './server/mcp-server.js';
8
51
  export { ToolRegistry } from './server/tool-registry.js';
@@ -52,4 +95,76 @@ export { VerifyCitationsTool } from './tools/verify-citations.js';
52
95
  export { ProgressStore, type OperationMetadata, type OperationState, } from './streaming/progress-store.js';
53
96
  export type { MCPTool, ToolAnnotations, MCPServerConfig, JsonRpcRequest, JsonRpcResponse, JsonRpcNotification, ToolExecutionContext, ToolContext, ProgressFn, } from './types.js';
54
97
  export { analyzeProject } from './core/project-analyzer.js';
98
+ export type { AnalyzeProjectOptions } from './core/project-analyzer.js';
99
+ export type { JsonRpcError } from './types.js';
100
+ export type { MemorySnapshot } from './mcp-watcher.js';
101
+ export type { ServerRuntimeStats } from './server/mcp-server.js';
102
+ export type { ProjectCache } from './tools/helpers/project-cache.js';
103
+ export type { HealthScan, CompareHealthOutput } from './tools/compare-health.js';
104
+ export type { DistDirectory, ServerStatusOutput } from './tools/server-status.js';
105
+ export type { AnalyzeBuildImpactOutput } from './tools/analyze-build-impact.js';
106
+ export type { AnalyzeCoreToSharedResult } from './tools/analyze-core-to-shared.js';
107
+ export type { AnalyzeParserPerformanceOutput } from './tools/analyze-parser-performance.js';
108
+ export type { AnalyzeProjectResult } from './tools/analyze-project.js';
109
+ export type { CompatibilityCheckOutput } from './tools/check-incremental-compatibility.js';
110
+ export type { CollectFeedbackOutput, CollectAnalysisFeedbackOutput, } from './tools/collect-feedback.js';
111
+ export type { ExtractLibrariesResult } from './tools/extract-libraries.js';
112
+ export type { FindAngularSymbolOutput } from './tools/find-angular-symbol.js';
113
+ export type { FindComponentHostsOutput } from './tools/find-component-hosts.js';
114
+ export type { FindUsagesOutput } from './tools/find-usages.js';
115
+ export type { GetBootstrapExecutionOutput } from './tools/get-bootstrap-execution.js';
116
+ export type { GetCallGraphOutput } from './tools/get-call-graph.js';
117
+ export type { InspectFormGroupOutput } from './tools/inspect-form-group.js';
118
+ export type { InspectI18nOutput } from './tools/inspect-i18n.js';
119
+ export type { InspectTemplateOutput } from './tools/inspect-template.js';
120
+ export type { LearnPatternsResult } from './tools/learn-patterns.js';
121
+ export type { ListImportsOutput } from './tools/list-imports.js';
122
+ export type { OrchestrateMigrationResult } from './tools/orchestrate-migration.js';
123
+ export type { ParseStackTraceOutput } from './tools/parse-stack-trace.js';
124
+ export type { PlanMigrationResult } from './tools/plan-migration.js';
125
+ export type { ReviewFeedbackOutput } from './tools/review-feedback.js';
126
+ export type { RollbackResult } from './tools/rollback-changes.js';
127
+ export type { AngularCliResult } from './tools/run-angular-cli.js';
128
+ export type { BuildResult } from './tools/run-build.js';
129
+ export type { SchematicResult } from './tools/run-schematic.js';
130
+ export type { ScanAllResult } from './tools/scan-all.js';
131
+ export type { ScanAngularResult } from './tools/scan-angular.js';
132
+ export type { ScanArchitectureResult } from './tools/scan-architecture.js';
133
+ export type { ScanSolidResult } from './tools/scan-solid.js';
134
+ export type { SearchCodebaseOutput } from './tools/search-codebase.js';
135
+ export type { SuggestImprovementsOutput } from './tools/suggest-improvements.js';
136
+ export type { TraceOutputFlowOutput } from './tools/trace-output-flow.js';
137
+ export type { TransformationResult } from './tools/transform-code.js';
138
+ export type { ValidationResult as ValidateBeforeTransformResult } from './tools/validate-before-transform.js';
139
+ export type { ValidationResult as ValidateTransformationResult } from './tools/validate-transformation.js';
140
+ export type { ValidateProjectCompatibilityOutput } from './tools/validate-project-compatibility.js';
141
+ export type { VerifyCitationsOutput } from './tools/verify-citations.js';
142
+ export type { BuildImpactCounts, BuildScopeStrategy, DependencyInfo, EstimatedBuildScope, MappedFile, TemplateHost, UnresolvedFile, } from './tools/analyze-build-impact.js';
143
+ export type { AggregatedParserMetrics, SessionMetricsDetail, } from './tools/analyze-parser-performance.js';
144
+ export type { RecommendationType } from './tools/check-incremental-compatibility.js';
145
+ export type { CompareHealthStatus, HealthRunInfo, HealthScanResult, } from './tools/compare-health.js';
146
+ export type { ExtractionOpportunity } from './tools/extract-libraries.js';
147
+ export type { CoverageOutput, HostOutput } from './tools/find-component-hosts.js';
148
+ export type { RootOutput } from './tools/get-bootstrap-execution.js';
149
+ export type { ControlOutput, FormOutput } from './tools/inspect-form-group.js';
150
+ export type { DetailField, ListField as InspectI18nListField, SourceOutput, } from './tools/inspect-i18n.js';
151
+ export type { ListField as InspectTemplateListField, TemplateReportOutput, } from './tools/inspect-template.js';
152
+ export type { ImportCounts, ImportEntry, NamedImportEntry, } from './tools/list-imports.js';
153
+ export type { MigrationStep, MigrationStrategy, ScanPlanOutput, StyleAwareRiskAssessment, } from './tools/plan-migration.js';
154
+ export type { FeedbackInsight, QualityWarning } from './tools/review-feedback.js';
155
+ export type { IncrementalMetadata as RunBuildIncrementalMetadata } from './tools/run-build.js';
156
+ export type { ResolvedScope, ScanExecution } from './tools/scan-architecture.js';
157
+ export type { DistPackageState } from './tools/server-status.js';
158
+ export type { DynamicFlowOutput, OutputFlowOutput } from './tools/trace-output-flow.js';
159
+ export type { IncrementalMetadata as ValidateTransformationIncrementalMetadata } from './tools/validate-transformation.js';
160
+ export type { VerifiedCitation } from './tools/verify-citations.js';
161
+ export type { ScanCounts } from './tools/helpers/analysis-output.js';
162
+ export type { FileDelta, HealthViolation, RuleDelta, } from './tools/helpers/health-delta.js';
163
+ export type { CachedProjectInfo, EvictionReason, EvictionStats, ProjectCacheLimits, ProjectEviction, } from './tools/helpers/project-cache.js';
164
+ export type { RuleTiming } from './tools/helpers/rule-runner.js';
165
+ export type { Performance, Suggestion } from './tools/helpers/suggestion-generator.js';
166
+ export type { CancelledExecution } from './tools/helpers/tool-context.js';
167
+ export type { ResponseRecord, ResponseStats } from './server/limited-stdio-transport.js';
168
+ export type { ScanHostStatus, ScanWorkerInfo } from './scan-host/scan-host.js';
169
+ export type { ProtocolEra, ProtocolInfo } from './server/sdk-server.js';
55
170
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,8 +1,51 @@
1
1
  /**
2
- * @angular-modernizer/adapter-mcp - MCP Server Entry Point
2
+ * MCP server of the Angular Modernizer: 41 tools for analysis, migration
3
+ * planning, transformation, build validation, rollback, feedback and bug
4
+ * investigation of Angular projects, served over stdio with the MCP
5
+ * TypeScript SDK.
3
6
  *
4
- * This module provides the Model Context Protocol (MCP) server
5
- * that exposes Angular Modernizer analysis capabilities to AI assistants.
7
+ * @remarks
8
+ * The server speaks both protocol eras on one stdio connection: clients that
9
+ * open with `initialize` get the revision they ask for (2025-06-18,
10
+ * 2025-11-25), clients that open with `server/discover` get 2026-07-28.
11
+ * Arguments are validated against each tool's input schema; every tool
12
+ * answers with `structuredContent` validated against its output schema and a
13
+ * text block with the result's `summary`.
14
+ *
15
+ * Run the server through the `angular-modernizer-mcp` bin (`dist/cli.js`):
16
+ *
17
+ * ```bash
18
+ * npx @angular-modernizer/adapter-mcp
19
+ * claude mcp add angular-modernizer npx @angular-modernizer/adapter-mcp
20
+ * ```
21
+ *
22
+ * `cli.js` takes `--max-projects N` and `--max-heap-mb N` for the shared
23
+ * ts-morph project cache (defaults 3 and 2048 MB, 0 = no heap limit).
24
+ *
25
+ * The package entry exports the building blocks for embedding the server or
26
+ * calling tools directly:
27
+ *
28
+ * - {@link MCPServer}: stdio server lifecycle; register tools, then `start()`.
29
+ * - {@link ToolRegistry}: tool registration and execution.
30
+ * - {@link MCPTool}: the tool contract every tool class implements, with
31
+ * {@link ToolContext} for cancellation and progress.
32
+ * - The tool classes, one per MCP tool, e.g. {@link ScanAllTool},
33
+ * {@link TransformCodeTool}, {@link FindUsagesTool}, {@link ServerStatusTool}.
34
+ * - {@link ProgressStore}: operation store of the deprecated streaming path.
35
+ * - {@link startMCPWatcher}: debug log and health check, enabled with
36
+ * `ANGULAR_MODERNIZER_DEBUG`.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * import { MCPServer, ScanAllTool, FindUsagesTool } from '@angular-modernizer/adapter-mcp';
41
+ *
42
+ * const server = new MCPServer();
43
+ * server.registerTool(new ScanAllTool());
44
+ * server.registerTool(new FindUsagesTool());
45
+ * server.start();
46
+ * ```
47
+ *
48
+ * @packageDocumentation
6
49
  */
7
50
  // Export server infrastructure
8
51
  export { MCPServer } from './server/mcp-server.js';
@@ -1,33 +1,53 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - MCP Watcher
3
- *
4
- * Writes periodic status updates to mcp-server.log to help debug
5
- * hanging operations like analyze-project. The server starts it only when
6
- * `ANGULAR_MODERNIZER_DEBUG` is set.
7
- */
1
+ /** Internal state of the {@link MCPWatcher}. */
8
2
  export interface WatcherState {
3
+ /** When the watcher started. */
9
4
  startTime: Date;
5
+ /** Time of the last heartbeat. */
10
6
  lastHeartbeat: Date;
7
+ /** Number of heartbeats since the start. */
11
8
  heartbeatCount: number;
9
+ /** Running operations by operation id. */
12
10
  activeOperations: Map<string, OperationInfo>;
11
+ /** Memory readings of the last 20 heartbeats, oldest first. */
13
12
  memorySnapshots: MemorySnapshot[];
13
+ /** Port of the health check HTTP server; unset when disabled. */
14
14
  healthCheckPort?: number;
15
15
  }
16
+ /** An operation tracked by the {@link MCPWatcher}. */
16
17
  export interface OperationInfo {
18
+ /** Operation id. */
17
19
  operationId: string;
20
+ /** Name of the tool running the operation. */
18
21
  toolName: string;
22
+ /** When the operation started. */
19
23
  startTime: Date;
24
+ /** Time of the last phase update. */
20
25
  lastUpdate: Date;
26
+ /** Current phase, `'starting'` at the start. */
21
27
  phase: string;
28
+ /** Details of the current phase. */
22
29
  details?: string;
23
30
  }
24
- interface MemorySnapshot {
31
+ /** Memory reading of one heartbeat, in bytes (`process.memoryUsage()`). */
32
+ export interface MemorySnapshot {
33
+ /** Time of the reading. */
25
34
  timestamp: Date;
35
+ /** V8 heap in use. */
26
36
  heapUsed: number;
37
+ /** V8 heap allocated. */
27
38
  heapTotal: number;
39
+ /** Memory of C++ objects bound to JavaScript objects. */
28
40
  external: number;
41
+ /** Resident set size of the process. */
29
42
  rss: number;
30
43
  }
44
+ /**
45
+ * Debug watcher: writes periodic status updates (heartbeat, memory, running
46
+ * operations) to `mcp-server.log` to help debug hanging operations, and
47
+ * optionally serves a health check over HTTP. The server starts it only when
48
+ * `ANGULAR_MODERNIZER_DEBUG` is set; its timer is `unref()`ed and never keeps
49
+ * the process alive.
50
+ */
31
51
  declare class MCPWatcher {
32
52
  private readonly state;
33
53
  private readonly logPath;
@@ -1,13 +1,13 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - MCP Watcher
3
- *
4
- * Writes periodic status updates to mcp-server.log to help debug
5
- * hanging operations like analyze-project. The server starts it only when
6
- * `ANGULAR_MODERNIZER_DEBUG` is set.
7
- */
8
1
  import { appendFileSync, writeFileSync } from 'node:fs';
9
2
  import { resolve } from 'node:path';
10
3
  import * as http from 'node:http';
4
+ /**
5
+ * Debug watcher: writes periodic status updates (heartbeat, memory, running
6
+ * operations) to `mcp-server.log` to help debug hanging operations, and
7
+ * optionally serves a health check over HTTP. The server starts it only when
8
+ * `ANGULAR_MODERNIZER_DEBUG` is set; its timer is `unref()`ed and never keeps
9
+ * the process alive.
10
+ */
11
11
  class MCPWatcher {
12
12
  state;
13
13
  logPath;