@angular-modernizer/adapter-mcp 1.0.0 → 1.2.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 (131) hide show
  1. package/README.md +81 -65
  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 +58 -36
  24. package/dist/tools/analyze-build-impact.js +36 -29
  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 +87 -14
  30. package/dist/tools/analyze-project.js +140 -122
  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 +27 -25
  40. package/dist/tools/find-angular-symbol.js +19 -16
  41. package/dist/tools/find-component-hosts.d.ts +33 -27
  42. package/dist/tools/find-component-hosts.js +27 -24
  43. package/dist/tools/find-usages.d.ts +25 -23
  44. package/dist/tools/find-usages.js +21 -18
  45. package/dist/tools/get-bootstrap-execution.d.ts +35 -27
  46. package/dist/tools/get-bootstrap-execution.js +28 -25
  47. package/dist/tools/get-call-graph.d.ts +19 -14
  48. package/dist/tools/get-call-graph.js +26 -23
  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 +123 -36
  60. package/dist/tools/helpers/project-cache.js +227 -43
  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/scan-plan.d.ts +1 -1
  66. package/dist/tools/helpers/scan-plan.js +1 -1
  67. package/dist/tools/helpers/suggestion-generator.d.ts +9 -13
  68. package/dist/tools/helpers/suggestion-generator.js +0 -12
  69. package/dist/tools/helpers/tool-cache.d.ts +11 -0
  70. package/dist/tools/helpers/tool-cache.js +15 -0
  71. package/dist/tools/helpers/tool-context.d.ts +11 -8
  72. package/dist/tools/helpers/tool-context.js +5 -8
  73. package/dist/tools/inspect-form-group.d.ts +34 -27
  74. package/dist/tools/inspect-form-group.js +27 -24
  75. package/dist/tools/inspect-i18n.d.ts +31 -25
  76. package/dist/tools/inspect-i18n.js +23 -20
  77. package/dist/tools/inspect-template.d.ts +32 -25
  78. package/dist/tools/inspect-template.js +26 -23
  79. package/dist/tools/learn-patterns.d.ts +88 -12
  80. package/dist/tools/learn-patterns.js +17 -11
  81. package/dist/tools/list-imports.d.ts +45 -28
  82. package/dist/tools/list-imports.js +26 -23
  83. package/dist/tools/orchestrate-migration.d.ts +31 -9
  84. package/dist/tools/orchestrate-migration.js +12 -7
  85. package/dist/tools/parse-stack-trace.d.ts +23 -21
  86. package/dist/tools/parse-stack-trace.js +10 -7
  87. package/dist/tools/plan-migration.d.ts +67 -27
  88. package/dist/tools/plan-migration.js +22 -21
  89. package/dist/tools/resolve-type.d.ts +20 -10
  90. package/dist/tools/resolve-type.js +21 -13
  91. package/dist/tools/review-feedback.d.ts +27 -24
  92. package/dist/tools/review-feedback.js +24 -20
  93. package/dist/tools/rollback-changes.d.ts +13 -9
  94. package/dist/tools/rollback-changes.js +10 -7
  95. package/dist/tools/run-angular-cli.d.ts +12 -10
  96. package/dist/tools/run-angular-cli.js +11 -8
  97. package/dist/tools/run-build.d.ts +13 -11
  98. package/dist/tools/run-build.js +11 -8
  99. package/dist/tools/run-schematic.d.ts +12 -10
  100. package/dist/tools/run-schematic.js +11 -8
  101. package/dist/tools/scan-all.d.ts +69 -12
  102. package/dist/tools/scan-all.js +55 -122
  103. package/dist/tools/scan-angular.d.ts +41 -9
  104. package/dist/tools/scan-angular.js +66 -135
  105. package/dist/tools/scan-architecture.d.ts +75 -14
  106. package/dist/tools/scan-architecture.js +180 -185
  107. package/dist/tools/scan-solid.d.ts +40 -9
  108. package/dist/tools/scan-solid.js +64 -133
  109. package/dist/tools/search-codebase.d.ts +32 -26
  110. package/dist/tools/search-codebase.js +15 -12
  111. package/dist/tools/server-status.d.ts +116 -24
  112. package/dist/tools/server-status.js +85 -26
  113. package/dist/tools/suggest-improvements.d.ts +22 -19
  114. package/dist/tools/suggest-improvements.js +21 -17
  115. package/dist/tools/trace-output-flow.d.ts +34 -27
  116. package/dist/tools/trace-output-flow.js +27 -24
  117. package/dist/tools/transform-code.d.ts +71 -10
  118. package/dist/tools/transform-code.js +148 -54
  119. package/dist/tools/validate-before-transform.d.ts +24 -9
  120. package/dist/tools/validate-before-transform.js +10 -7
  121. package/dist/tools/validate-project-compatibility.d.ts +18 -13
  122. package/dist/tools/validate-project-compatibility.js +17 -11
  123. package/dist/tools/validate-transformation.d.ts +28 -11
  124. package/dist/tools/validate-transformation.js +14 -8
  125. package/dist/tools/verify-citations.d.ts +37 -16
  126. package/dist/tools/verify-citations.js +19 -16
  127. package/dist/types.d.ts +40 -10
  128. package/dist/types.js +0 -5
  129. package/package.json +12 -18
  130. package/dist/tools/shared/scan-types.d.ts +0 -200
  131. package/dist/tools/shared/scan-types.js +0 -7
@@ -1,6 +1,13 @@
1
+ import { AngularSymbolFinder, } from '@angular-modernizer/api';
2
+ import { existsSync } from 'node:fs';
3
+ import { findTsConfig } from './helpers/find-ts-config.js';
4
+ import { ProjectCache, acquireProject } from './helpers/project-cache.js';
5
+ import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
6
+ import { configuredComponentDecorators } from './helpers/project-decorators.js';
7
+ import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
8
+ /** Symbols named in the summaryOnly text. */
9
+ const SUMMARY_NAMES = 10;
1
10
  /**
2
- * @angular-modernizer/adapter-mcp - Find Angular Symbol Tool
3
- *
4
11
  * MCP tool for locating Angular symbols (components, directives, pipes,
5
12
  * services, guards, interceptors, resolvers, modules, tokens) in a project.
6
13
  * Accepts selectors, pipe names, class names, or partial selector substrings.
@@ -18,18 +25,6 @@
18
25
  * // args: { query: 'UserService', type: 'service', projectRoot: '/project' }
19
26
  * ```
20
27
  */
21
- import { AngularSymbolFinder, } from '@angular-modernizer/api';
22
- import { existsSync } from 'node:fs';
23
- import { findTsConfig } from './helpers/find-ts-config.js';
24
- import { ProjectCache } from './helpers/project-cache.js';
25
- import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
26
- import { configuredComponentDecorators } from './helpers/project-decorators.js';
27
- import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
28
- /** Symbols named in the summaryOnly text. */
29
- const SUMMARY_NAMES = 10;
30
- /**
31
- * MCP tool that finds Angular symbols by selector, pipe name, or class name.
32
- */
33
28
  export class FindAngularSymbolTool {
34
29
  projects;
35
30
  name = 'find-angular-symbol';
@@ -54,6 +49,10 @@ export class FindAngularSymbolTool {
54
49
  'pipe name or one selector of the list), not by substring. *.spec.ts files are skipped. ' +
55
50
  'Use during bug investigation to locate which class owns a given selector or pipe. ' +
56
51
  'Selector and pipe queries match substrings; use summaryOnly or maxResults for short queries.';
52
+ /**
53
+ * JSON Schema of the tool arguments.
54
+ * @hidden
55
+ */
57
56
  inputSchema = {
58
57
  type: 'object',
59
58
  additionalProperties: false,
@@ -87,6 +86,10 @@ export class FindAngularSymbolTool {
87
86
  },
88
87
  required: ['query', 'projectRoot'],
89
88
  };
89
+ /**
90
+ * JSON Schema of the tool result (`structuredContent`).
91
+ * @hidden
92
+ */
90
93
  outputSchema = {
91
94
  type: 'object',
92
95
  properties: {
@@ -120,7 +123,7 @@ export class FindAngularSymbolTool {
120
123
  },
121
124
  required: ['totalCount', 'truncated', 'countsByType', 'summary'],
122
125
  };
123
- async execute(args) {
126
+ async execute(args, ctx = {}) {
124
127
  const params = args;
125
128
  if (!params.query) {
126
129
  throw new Error('query is required');
@@ -136,7 +139,7 @@ export class FindAngularSymbolTool {
136
139
  if (!tsConfigPath) {
137
140
  throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
138
141
  }
139
- const project = this.projects.get(tsConfigPath);
142
+ const project = await acquireProject(this.projects, tsConfigPath, ctx);
140
143
  const finder = new AngularSymbolFinder(project, {
141
144
  componentDecorators: configuredComponentDecorators(params.projectRoot),
142
145
  });
@@ -1,37 +1,19 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Find Component Hosts Tool
3
- *
4
- * MCP tool that lists every template using a component or directive and,
5
- * per host, which inputs and outputs are bound, unbound or missing, plus
6
- * the places creating a component in code (dialogs, `createComponent`,
7
- * wrappers) as `dynamicHosts`.
8
- *
9
- * @remarks
10
- * Logic lives in `ComponentHostFinder` (`@angular-modernizer/api`); this tool
11
- * resolves the project, validates arguments and applies the compact output
12
- * contract (`maxResults` caps the host list and the dynamic host list each).
13
- *
14
- * @example
15
- * ```typescript
16
- * // Via MCP:
17
- * // tool: find-component-hosts
18
- * // args: { className: 'ItemComponent', projectRoot: '/project' }
19
- * ```
20
- */
21
- import { type MCPTool, type ToolAnnotations } from '../types.js';
1
+ import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
22
2
  import { type BindingCoverage, type ComponentHost, type ComponentHostResult, type DynamicHost } from '@angular-modernizer/api';
23
3
  import { ProjectCache } from './helpers/project-cache.js';
24
4
  /** Coverage entry with the host name lists dropped (summaryOnly) or capped (maxResults). */
25
- type CoverageOutput = Pick<BindingCoverage, 'bound' | 'unbound'> & Partial<Pick<BindingCoverage, 'boundIn' | 'unboundIn'>>;
5
+ export type CoverageOutput = Pick<BindingCoverage, 'bound' | 'unbound'> & Partial<Pick<BindingCoverage, 'boundIn' | 'unboundIn'>>;
26
6
  /** A host with occurrences optionally dropped. */
27
- type HostOutput = Omit<ComponentHost, 'occurrences'> & Partial<Pick<ComponentHost, 'occurrences'>>;
7
+ export type HostOutput = Omit<ComponentHost, 'occurrences'> & Partial<Pick<ComponentHost, 'occurrences'>>;
28
8
  /**
29
9
  * Output of the find-component-hosts tool.
30
10
  */
31
- interface FindComponentHostsOutput extends Omit<ComponentHostResult, 'hosts' | 'coverage' | 'dynamicHosts' | 'candidateHosts'> {
11
+ export interface FindComponentHostsOutput extends Omit<ComponentHostResult, 'hosts' | 'coverage' | 'dynamicHosts' | 'candidateHosts'> {
32
12
  /** Per input/output: host counts, and host names unless summaryOnly (capped by maxResults). */
33
13
  coverage: {
14
+ /** Coverage per input name. */
34
15
  inputs: Record<string, CoverageOutput>;
16
+ /** Coverage per output name. */
35
17
  outputs: Record<string, CoverageOutput>;
36
18
  };
37
19
  /** Hosts, cut to `maxResults`; omitted with `summaryOnly`. */
@@ -46,13 +28,30 @@ interface FindComponentHostsOutput extends Omit<ComponentHostResult, 'hosts' | '
46
28
  candidateHosts?: DynamicHost[];
47
29
  /** `true` when `maxResults` cut the candidate list. */
48
30
  candidateTruncated: boolean;
31
+ /** Short text summary of the hosts and the binding coverage. */
49
32
  summary: string;
33
+ /** The tsconfig whose program was searched. */
50
34
  tsConfigPath: string;
51
35
  /** Conditions that can make the result incomplete (unresolved library imports). */
52
36
  warnings?: string[];
53
37
  }
54
38
  /**
55
- * MCP tool that finds the template hosts of a component or directive.
39
+ * MCP tool that lists every template using a component or directive and,
40
+ * per host, which inputs and outputs are bound, unbound or missing, plus
41
+ * the places creating a component in code (dialogs, `createComponent`,
42
+ * wrappers) as `dynamicHosts`.
43
+ *
44
+ * @remarks
45
+ * Logic lives in `ComponentHostFinder` (`@angular-modernizer/api`); this tool
46
+ * resolves the project, validates arguments and applies the compact output
47
+ * contract (`maxResults` caps the host list and the dynamic host list each).
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * // Via MCP:
52
+ * // tool: find-component-hosts
53
+ * // args: { className: 'ItemComponent', projectRoot: '/project' }
54
+ * ```
56
55
  */
57
56
  export declare class FindComponentHostsTool implements MCPTool {
58
57
  private readonly projects;
@@ -61,6 +60,10 @@ export declare class FindComponentHostsTool implements MCPTool {
61
60
  readonly annotations: ToolAnnotations;
62
61
  constructor(projects?: ProjectCache);
63
62
  readonly description: string;
63
+ /**
64
+ * JSON Schema of the tool arguments.
65
+ * @hidden
66
+ */
64
67
  readonly inputSchema: {
65
68
  type: string;
66
69
  additionalProperties: boolean;
@@ -108,6 +111,10 @@ export declare class FindComponentHostsTool implements MCPTool {
108
111
  };
109
112
  required: string[];
110
113
  };
114
+ /**
115
+ * JSON Schema of the tool result (`structuredContent`).
116
+ * @hidden
117
+ */
111
118
  readonly outputSchema: {
112
119
  type: string;
113
120
  properties: {
@@ -673,12 +680,11 @@ export declare class FindComponentHostsTool implements MCPTool {
673
680
  };
674
681
  required: string[];
675
682
  };
676
- execute(args: Record<string, unknown>): Promise<FindComponentHostsOutput>;
683
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<FindComponentHostsOutput>;
677
684
  private buildSummary;
678
685
  private shapeCoverage;
679
686
  /** `AppDialog.open 24, new AppDialogRef 2` */
680
687
  private sinkList;
681
688
  private nameList;
682
689
  }
683
- export {};
684
690
  //# sourceMappingURL=find-component-hosts.d.ts.map
@@ -1,28 +1,8 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Find Component Hosts Tool
3
- *
4
- * MCP tool that lists every template using a component or directive and,
5
- * per host, which inputs and outputs are bound, unbound or missing, plus
6
- * the places creating a component in code (dialogs, `createComponent`,
7
- * wrappers) as `dynamicHosts`.
8
- *
9
- * @remarks
10
- * Logic lives in `ComponentHostFinder` (`@angular-modernizer/api`); this tool
11
- * resolves the project, validates arguments and applies the compact output
12
- * contract (`maxResults` caps the host list and the dynamic host list each).
13
- *
14
- * @example
15
- * ```typescript
16
- * // Via MCP:
17
- * // tool: find-component-hosts
18
- * // args: { className: 'ItemComponent', projectRoot: '/project' }
19
- * ```
20
- */
21
1
  import { ComponentHostFinder, } from '@angular-modernizer/api';
22
2
  import { existsSync } from 'node:fs';
23
3
  import { isAbsolute, resolve } from 'node:path';
24
4
  import { findTsConfig } from './helpers/find-ts-config.js';
25
- import { ProjectCache } from './helpers/project-cache.js';
5
+ import { ProjectCache, acquireProject } from './helpers/project-cache.js';
26
6
  import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
27
7
  import { configuredComponentDecorators } from './helpers/project-decorators.js';
28
8
  import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
@@ -156,7 +136,22 @@ const DYNAMIC_HOST_SCHEMA = {
156
136
  ],
157
137
  };
158
138
  /**
159
- * MCP tool that finds the template hosts of a component or directive.
139
+ * MCP tool that lists every template using a component or directive and,
140
+ * per host, which inputs and outputs are bound, unbound or missing, plus
141
+ * the places creating a component in code (dialogs, `createComponent`,
142
+ * wrappers) as `dynamicHosts`.
143
+ *
144
+ * @remarks
145
+ * Logic lives in `ComponentHostFinder` (`@angular-modernizer/api`); this tool
146
+ * resolves the project, validates arguments and applies the compact output
147
+ * contract (`maxResults` caps the host list and the dynamic host list each).
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * // Via MCP:
152
+ * // tool: find-component-hosts
153
+ * // args: { className: 'ItemComponent', projectRoot: '/project' }
154
+ * ```
160
155
  */
161
156
  export class FindComponentHostsTool {
162
157
  projects;
@@ -193,6 +188,10 @@ export class FindComponentHostsTool {
193
188
  'summaryOnly (counts per input/output only). summaryOnly drops the host list, ' +
194
189
  'maxResults caps it and the host names in coverage; counts (incl. coverage bound/unbound) always ' +
195
190
  'cover all hosts.';
191
+ /**
192
+ * JSON Schema of the tool arguments.
193
+ * @hidden
194
+ */
196
195
  inputSchema = {
197
196
  type: 'object',
198
197
  additionalProperties: false,
@@ -232,6 +231,10 @@ export class FindComponentHostsTool {
232
231
  },
233
232
  required: ['projectRoot'],
234
233
  };
234
+ /**
235
+ * JSON Schema of the tool result (`structuredContent`).
236
+ * @hidden
237
+ */
235
238
  outputSchema = {
236
239
  type: 'object',
237
240
  properties: {
@@ -293,7 +296,7 @@ export class FindComponentHostsTool {
293
296
  'tsConfigPath',
294
297
  ],
295
298
  };
296
- async execute(args) {
299
+ async execute(args, ctx = {}) {
297
300
  const params = args;
298
301
  if (!params.className && !params.selector) {
299
302
  throw new Error('className or selector is required');
@@ -312,7 +315,7 @@ export class FindComponentHostsTool {
312
315
  const file = params.file === undefined || isAbsolute(params.file)
313
316
  ? params.file
314
317
  : resolve(params.projectRoot, params.file);
315
- const finder = new ComponentHostFinder(this.projects.get(tsConfigPath), {
318
+ const finder = new ComponentHostFinder((await acquireProject(this.projects, tsConfigPath, ctx)), {
316
319
  componentDecorators: configuredComponentDecorators(params.projectRoot),
317
320
  includeTestHosts: params.includeTestHosts === true,
318
321
  includeDynamic: params.includeDynamic !== false,
@@ -1,28 +1,10 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Find Usages Tool
3
- *
4
- * MCP tool for finding all references to a symbol (class, method, function,
5
- * variable, constant) across a TypeScript project.
6
- *
7
- * @remarks
8
- * Uses ts-morph `findReferences()` via `UsageFinder` from `@angular-modernizer/api`.
9
- * Ideal as a second step in bug investigation after `parse-stack-trace` has
10
- * identified the affected files and symbols.
11
- *
12
- * @example
13
- * ```typescript
14
- * // Via MCP:
15
- * // tool: find-usages
16
- * // args: { symbol: 'UserService', projectRoot: '/my/project', file: '/my/project/src/app/user.component.ts' }
17
- * ```
18
- */
19
- import { type MCPTool, type ToolAnnotations } from '../types.js';
1
+ import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
20
2
  import { type SymbolUsage, type UsageType } from '@angular-modernizer/api';
21
3
  import { ProjectCache } from './helpers/project-cache.js';
22
4
  /**
23
5
  * Output of the find-usages tool.
24
6
  */
25
- interface FindUsagesOutput {
7
+ export interface FindUsagesOutput {
26
8
  /** Matching usages, cut to `maxResults`; omitted with `summaryOnly`. */
27
9
  usages?: SymbolUsage[];
28
10
  /** Total number of usages found (before `maxResults`). */
@@ -41,7 +23,20 @@ interface FindUsagesOutput {
41
23
  warnings?: string[];
42
24
  }
43
25
  /**
44
- * MCP tool that finds all references to a named symbol across a TypeScript project.
26
+ * MCP tool for finding all references to a symbol (class, method, function,
27
+ * variable, constant) across a TypeScript project.
28
+ *
29
+ * @remarks
30
+ * Uses ts-morph `findReferences()` via `UsageFinder` from `@angular-modernizer/api`.
31
+ * Ideal as a second step in bug investigation after `parse-stack-trace` has
32
+ * identified the affected files and symbols.
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * // Via MCP:
37
+ * // tool: find-usages
38
+ * // args: { symbol: 'UserService', projectRoot: '/my/project', file: '/my/project/src/app/user.component.ts' }
39
+ * ```
45
40
  */
46
41
  export declare class FindUsagesTool implements MCPTool {
47
42
  private readonly projects;
@@ -50,6 +45,10 @@ export declare class FindUsagesTool implements MCPTool {
50
45
  readonly annotations: ToolAnnotations;
51
46
  constructor(projects?: ProjectCache);
52
47
  readonly description: string;
48
+ /**
49
+ * JSON Schema of the tool arguments.
50
+ * @hidden
51
+ */
53
52
  readonly inputSchema: {
54
53
  type: string;
55
54
  additionalProperties: boolean;
@@ -91,6 +90,10 @@ export declare class FindUsagesTool implements MCPTool {
91
90
  };
92
91
  required: string[];
93
92
  };
93
+ /**
94
+ * JSON Schema of the tool result (`structuredContent`).
95
+ * @hidden
96
+ */
94
97
  readonly outputSchema: {
95
98
  type: string;
96
99
  properties: {
@@ -164,9 +167,8 @@ export declare class FindUsagesTool implements MCPTool {
164
167
  };
165
168
  required: string[];
166
169
  };
167
- execute(args: Record<string, unknown>): Promise<FindUsagesOutput>;
170
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<FindUsagesOutput>;
168
171
  private buildCompactSummary;
169
172
  private buildSummary;
170
173
  }
171
- export {};
172
174
  //# sourceMappingURL=find-usages.d.ts.map
@@ -1,6 +1,15 @@
1
+ import { UsageFinder, } from '@angular-modernizer/api';
2
+ import { existsSync } from 'node:fs';
3
+ import { findTsConfig } from './helpers/find-ts-config.js';
4
+ import { ProjectCache, acquireProject } from './helpers/project-cache.js';
5
+ import { COMPACT_OUTPUT_SCHEMA, countByDirectory, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
6
+ import { configuredComponentDecorators } from './helpers/project-decorators.js';
7
+ import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
8
+ /** Directory depth (relative to projectRoot) used for `countsByDirectory`. */
9
+ const DIRECTORY_DEPTH = 3;
10
+ /** Directories listed in the summaryOnly text. */
11
+ const SUMMARY_TOP_DIRECTORIES = 10;
1
12
  /**
2
- * @angular-modernizer/adapter-mcp - Find Usages Tool
3
- *
4
13
  * MCP tool for finding all references to a symbol (class, method, function,
5
14
  * variable, constant) across a TypeScript project.
6
15
  *
@@ -16,20 +25,6 @@
16
25
  * // args: { symbol: 'UserService', projectRoot: '/my/project', file: '/my/project/src/app/user.component.ts' }
17
26
  * ```
18
27
  */
19
- import { UsageFinder, } from '@angular-modernizer/api';
20
- import { existsSync } from 'node:fs';
21
- import { findTsConfig } from './helpers/find-ts-config.js';
22
- import { ProjectCache } from './helpers/project-cache.js';
23
- import { COMPACT_OUTPUT_SCHEMA, countByDirectory, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
24
- import { configuredComponentDecorators } from './helpers/project-decorators.js';
25
- import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
26
- /** Directory depth (relative to projectRoot) used for `countsByDirectory`. */
27
- const DIRECTORY_DEPTH = 3;
28
- /** Directories listed in the summaryOnly text. */
29
- const SUMMARY_TOP_DIRECTORIES = 10;
30
- /**
31
- * MCP tool that finds all references to a named symbol across a TypeScript project.
32
- */
33
28
  export class FindUsagesTool {
34
29
  projects;
35
30
  name = 'find-usages';
@@ -56,6 +51,10 @@ export class FindUsagesTool {
56
51
  'Use after parse-stack-trace to trace call paths and determine blast radius before ' +
57
52
  'proposing a bug fix. countsByType and countsByDirectory always cover all usages; ' +
58
53
  'use summaryOnly for a quick overview of widely used symbols, maxResults to cap the list.';
54
+ /**
55
+ * JSON Schema of the tool arguments.
56
+ * @hidden
57
+ */
59
58
  inputSchema = {
60
59
  type: 'object',
61
60
  additionalProperties: false,
@@ -100,6 +99,10 @@ export class FindUsagesTool {
100
99
  },
101
100
  required: ['symbol', 'projectRoot'],
102
101
  };
102
+ /**
103
+ * JSON Schema of the tool result (`structuredContent`).
104
+ * @hidden
105
+ */
103
106
  outputSchema = {
104
107
  type: 'object',
105
108
  properties: {
@@ -144,7 +147,7 @@ export class FindUsagesTool {
144
147
  'tsConfigPath',
145
148
  ],
146
149
  };
147
- async execute(args) {
150
+ async execute(args, ctx = {}) {
148
151
  const params = args;
149
152
  if (!params.symbol) {
150
153
  throw new Error('symbol is required');
@@ -162,7 +165,7 @@ export class FindUsagesTool {
162
165
  }
163
166
  // The shared ProjectCache: a fresh Project cost 4 to 6 s per call on a
164
167
  // large workspace and sat next to the cached one while the search ran.
165
- const project = this.projects.get(tsConfigPath);
168
+ const project = await acquireProject(this.projects, tsConfigPath, ctx);
166
169
  const finder = new UsageFinder(project, {
167
170
  componentDecorators: configuredComponentDecorators(params.projectRoot),
168
171
  });
@@ -1,47 +1,48 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Get Bootstrap Execution Tool
3
- *
4
- * MCP tool that lists what an Angular app runs at startup (initializers,
5
- * bootstrap component/module), on the first HTTP request (interceptors) and
6
- * on first injection (provider factories), including everything reached
7
- * through calls and dependency injection, and where a watched expression
8
- * such as `AppConfig.settings` is read or written on the way.
9
- *
10
- * @remarks
11
- * Logic lives in `BootstrapExecutionAnalyzer` (`@angular-modernizer/api`);
12
- * this tool resolves the project, validates arguments and applies the
13
- * compact output contract.
14
- *
15
- * @example
16
- * ```typescript
17
- * // Via MCP:
18
- * // tool: get-bootstrap-execution
19
- * // args: { projectRoot: '/project', watch: ['AppConfig.settings'], summaryOnly: true }
20
- * ```
21
- */
22
- import { type MCPTool, type ToolAnnotations } from '../types.js';
1
+ import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
23
2
  import { type BootstrapExecutionResult, type BootstrapRoot, type BootstrapTiming, type BootstrapWatchHit } from '@angular-modernizer/api';
24
3
  import { ProjectCache } from './helpers/project-cache.js';
25
4
  /** A root with its reached list optionally dropped or capped. */
26
- type RootOutput = Omit<BootstrapRoot, 'reached'> & Partial<Pick<BootstrapRoot, 'reached'>> & {
5
+ export type RootOutput = Omit<BootstrapRoot, 'reached'> & Partial<Pick<BootstrapRoot, 'reached'>> & {
6
+ /** Number of nodes reached from the root, also when the list is dropped or capped. */
27
7
  reachedCount: number;
28
8
  };
29
9
  /**
30
10
  * Output of the get-bootstrap-execution tool.
31
11
  */
32
- interface GetBootstrapExecutionOutput {
12
+ export interface GetBootstrapExecutionOutput {
13
+ /** Startup roots with what they reach; omitted with `summaryOnly`. */
33
14
  roots?: RootOutput[];
15
+ /** Reads and writes of the watched expressions, capped by `maxResults`; omitted with `summaryOnly`. */
34
16
  watchHits?: BootstrapWatchHit[];
17
+ /** Counts over the full result. */
35
18
  counts: BootstrapExecutionResult['counts'];
36
19
  /** `true` when `maxResults` cut a reached list or the watch hits. */
37
20
  truncated: boolean;
21
+ /** Short text: roots, counts and watch hits. */
38
22
  summary: string;
23
+ /** The tsconfig whose program was analyzed. */
39
24
  tsConfigPath: string;
40
25
  /** Conditions that can make the result incomplete (unresolved library imports). */
41
26
  warnings?: string[];
42
27
  }
43
28
  /**
44
- * MCP tool that reports what runs at application startup.
29
+ * MCP tool that lists what an Angular app runs at startup (initializers,
30
+ * bootstrap component/module), on the first HTTP request (interceptors) and
31
+ * on first injection (provider factories), including everything reached
32
+ * through calls and dependency injection, and where a watched expression
33
+ * such as `AppConfig.settings` is read or written on the way.
34
+ *
35
+ * @remarks
36
+ * Logic lives in `BootstrapExecutionAnalyzer` (`@angular-modernizer/api`);
37
+ * this tool resolves the project, validates arguments and applies the
38
+ * compact output contract.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * // Via MCP:
43
+ * // tool: get-bootstrap-execution
44
+ * // args: { projectRoot: '/project', watch: ['AppConfig.settings'], summaryOnly: true }
45
+ * ```
45
46
  */
46
47
  export declare class GetBootstrapExecutionTool implements MCPTool {
47
48
  private readonly projects;
@@ -50,6 +51,10 @@ export declare class GetBootstrapExecutionTool implements MCPTool {
50
51
  readonly annotations: ToolAnnotations;
51
52
  constructor(projects?: ProjectCache);
52
53
  readonly description: string;
54
+ /**
55
+ * JSON Schema of the tool arguments.
56
+ * @hidden
57
+ */
53
58
  readonly inputSchema: {
54
59
  type: string;
55
60
  additionalProperties: boolean;
@@ -106,6 +111,10 @@ export declare class GetBootstrapExecutionTool implements MCPTool {
106
111
  };
107
112
  required: string[];
108
113
  };
114
+ /**
115
+ * JSON Schema of the tool result (`structuredContent`).
116
+ * @hidden
117
+ */
109
118
  readonly outputSchema: {
110
119
  type: string;
111
120
  properties: {
@@ -251,8 +260,7 @@ export declare class GetBootstrapExecutionTool implements MCPTool {
251
260
  };
252
261
  required: string[];
253
262
  };
254
- execute(args: Record<string, unknown>): Promise<GetBootstrapExecutionOutput>;
263
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<GetBootstrapExecutionOutput>;
255
264
  private buildSummary;
256
265
  }
257
- export {};
258
266
  //# sourceMappingURL=get-bootstrap-execution.d.ts.map
@@ -1,29 +1,8 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Get Bootstrap Execution Tool
3
- *
4
- * MCP tool that lists what an Angular app runs at startup (initializers,
5
- * bootstrap component/module), on the first HTTP request (interceptors) and
6
- * on first injection (provider factories), including everything reached
7
- * through calls and dependency injection, and where a watched expression
8
- * such as `AppConfig.settings` is read or written on the way.
9
- *
10
- * @remarks
11
- * Logic lives in `BootstrapExecutionAnalyzer` (`@angular-modernizer/api`);
12
- * this tool resolves the project, validates arguments and applies the
13
- * compact output contract.
14
- *
15
- * @example
16
- * ```typescript
17
- * // Via MCP:
18
- * // tool: get-bootstrap-execution
19
- * // args: { projectRoot: '/project', watch: ['AppConfig.settings'], summaryOnly: true }
20
- * ```
21
- */
22
1
  import { BootstrapExecutionAnalyzer, normalizeWatchExpression, } from '@angular-modernizer/api';
23
2
  import { existsSync } from 'node:fs';
24
3
  import { isAbsolute, relative, resolve } from 'node:path';
25
4
  import { findTsConfig } from './helpers/find-ts-config.js';
26
- import { ProjectCache } from './helpers/project-cache.js';
5
+ import { ProjectCache, acquireProject } from './helpers/project-cache.js';
27
6
  import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, } from './helpers/compact-output.js';
28
7
  import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
29
8
  import { COUNT_OBJECT, STRING_ARRAY } from './helpers/investigation-schemas.js';
@@ -70,7 +49,23 @@ function stringList(value, name) {
70
49
  return value;
71
50
  }
72
51
  /**
73
- * MCP tool that reports what runs at application startup.
52
+ * MCP tool that lists what an Angular app runs at startup (initializers,
53
+ * bootstrap component/module), on the first HTTP request (interceptors) and
54
+ * on first injection (provider factories), including everything reached
55
+ * through calls and dependency injection, and where a watched expression
56
+ * such as `AppConfig.settings` is read or written on the way.
57
+ *
58
+ * @remarks
59
+ * Logic lives in `BootstrapExecutionAnalyzer` (`@angular-modernizer/api`);
60
+ * this tool resolves the project, validates arguments and applies the
61
+ * compact output contract.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Via MCP:
66
+ * // tool: get-bootstrap-execution
67
+ * // args: { projectRoot: '/project', watch: ['AppConfig.settings'], summaryOnly: true }
68
+ * ```
74
69
  */
75
70
  export class GetBootstrapExecutionTool {
76
71
  projects;
@@ -97,6 +92,10 @@ export class GetBootstrapExecutionTool {
97
92
  'from one callable instead (e.g. "AuthInterceptor.constructor"). Roots are found by scanning source files, ' +
98
93
  'not by evaluating which providers are registered; spec files are skipped. Start with summaryOnly; ' +
99
94
  'maxResults caps the reached list per root and the watch hits.';
95
+ /**
96
+ * JSON Schema of the tool arguments.
97
+ * @hidden
98
+ */
100
99
  inputSchema = {
101
100
  type: 'object',
102
101
  additionalProperties: false,
@@ -140,6 +139,10 @@ export class GetBootstrapExecutionTool {
140
139
  },
141
140
  required: ['projectRoot'],
142
141
  };
142
+ /**
143
+ * JSON Schema of the tool result (`structuredContent`).
144
+ * @hidden
145
+ */
143
146
  outputSchema = {
144
147
  type: 'object',
145
148
  properties: {
@@ -210,7 +213,7 @@ export class GetBootstrapExecutionTool {
210
213
  },
211
214
  required: ['counts', 'truncated', 'summary', 'tsConfigPath'],
212
215
  };
213
- async execute(args) {
216
+ async execute(args, ctx = {}) {
214
217
  const params = args;
215
218
  if (!params.projectRoot) {
216
219
  throw new Error('projectRoot is required');
@@ -237,7 +240,7 @@ export class GetBootstrapExecutionTool {
237
240
  const file = params.file === undefined || isAbsolute(params.file)
238
241
  ? params.file
239
242
  : resolve(params.projectRoot, params.file);
240
- const result = new BootstrapExecutionAnalyzer(this.projects.get(tsConfigPath)).analyze({
243
+ const result = new BootstrapExecutionAnalyzer((await acquireProject(this.projects, tsConfigPath, ctx))).analyze({
241
244
  ...(watch === undefined ? {} : { watch }),
242
245
  ...(timings === undefined ? {} : { timings: timings }),
243
246
  ...(file === undefined ? {} : { file }),