blueprint-extractor-mcp 7.0.6 → 7.0.8

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.
@@ -0,0 +1,28 @@
1
+ import type { ExecutionAdapter } from '../execution-adapter.js';
2
+ import { type CommandletAdapterOptions } from './commandlet-adapter.js';
3
+ type ResolvedCommandletInputs = {
4
+ engineRoot?: string;
5
+ projectPath?: string;
6
+ };
7
+ type CommandletAdapterFactory = (options: CommandletAdapterOptions) => ExecutionAdapter;
8
+ export type LazyCommandletAdapterOptions = {
9
+ resolveInputs: () => Promise<ResolvedCommandletInputs>;
10
+ createAdapter?: CommandletAdapterFactory;
11
+ platform?: NodeJS.Platform;
12
+ };
13
+ export declare class LazyCommandletAdapter implements ExecutionAdapter {
14
+ private adapter;
15
+ private adapterPromise;
16
+ private readonly resolveInputs;
17
+ private readonly createAdapter;
18
+ private readonly platform;
19
+ constructor(options: LazyCommandletAdapterOptions);
20
+ execute(subsystem: string, method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
21
+ isAvailable(): Promise<boolean>;
22
+ getMode(): 'commandlet';
23
+ getCapabilities(): ReadonlySet<import("../execution-adapter.js").ToolCapability>;
24
+ shutdown(): Promise<void>;
25
+ private getOrCreateAdapter;
26
+ private createAndInitializeAdapter;
27
+ }
28
+ export {};
@@ -0,0 +1,71 @@
1
+ import { COMMANDLET_CAPABILITIES } from '../execution-adapter.js';
2
+ import { CommandletAdapter } from './commandlet-adapter.js';
3
+ export class LazyCommandletAdapter {
4
+ adapter = null;
5
+ adapterPromise = null;
6
+ resolveInputs;
7
+ createAdapter;
8
+ platform;
9
+ constructor(options) {
10
+ this.resolveInputs = options.resolveInputs;
11
+ this.createAdapter = options.createAdapter ?? ((adapterOptions) => new CommandletAdapter(adapterOptions));
12
+ this.platform = options.platform;
13
+ }
14
+ async execute(subsystem, method, params) {
15
+ const adapter = await this.getOrCreateAdapter();
16
+ return adapter.execute(subsystem, method, params);
17
+ }
18
+ async isAvailable() {
19
+ try {
20
+ const adapter = await this.getOrCreateAdapter();
21
+ return await adapter.isAvailable();
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ }
27
+ getMode() {
28
+ return 'commandlet';
29
+ }
30
+ getCapabilities() {
31
+ return COMMANDLET_CAPABILITIES;
32
+ }
33
+ async shutdown() {
34
+ if (this.adapter && typeof this.adapter.shutdown === 'function') {
35
+ await this.adapter.shutdown();
36
+ }
37
+ this.adapter = null;
38
+ this.adapterPromise = null;
39
+ }
40
+ async getOrCreateAdapter() {
41
+ if (this.adapter) {
42
+ return this.adapter;
43
+ }
44
+ if (!this.adapterPromise) {
45
+ this.adapterPromise = this.createAndInitializeAdapter();
46
+ }
47
+ try {
48
+ const adapter = await this.adapterPromise;
49
+ this.adapter = adapter;
50
+ return adapter;
51
+ }
52
+ finally {
53
+ this.adapterPromise = null;
54
+ }
55
+ }
56
+ async createAndInitializeAdapter() {
57
+ const resolved = await this.resolveInputs();
58
+ if (!resolved.engineRoot || !resolved.projectPath) {
59
+ throw new Error('Commandlet fallback requires both engineRoot and projectPath to be resolved.');
60
+ }
61
+ const adapter = this.createAdapter({
62
+ engineRoot: resolved.engineRoot,
63
+ projectPath: resolved.projectPath,
64
+ ...(this.platform ? { platform: this.platform } : {}),
65
+ });
66
+ if (typeof adapter.initialize === 'function') {
67
+ await adapter.initialize();
68
+ }
69
+ return adapter;
70
+ }
71
+ }
@@ -1,15 +1,44 @@
1
+ import { z } from 'zod';
1
2
  import { extractExtraContent, extractToolPayload, isPlainObject } from './formatting.js';
2
3
  import { rawHandlerRegistry } from './alias-registration.js';
4
+ const normalizedToolResultEnvelopeSchema = z.object({
5
+ success: z.boolean(),
6
+ operation: z.string(),
7
+ code: z.string().optional(),
8
+ message: z.string().optional(),
9
+ recoverable: z.boolean().optional(),
10
+ next_steps: z.array(z.string()).optional(),
11
+ _hints: z.array(z.string()).optional(),
12
+ diagnostics: z.array(z.object({
13
+ severity: z.string().optional(),
14
+ code: z.string().optional(),
15
+ message: z.string().optional(),
16
+ path: z.string().optional(),
17
+ })).optional(),
18
+ execution: z.object({
19
+ mode: z.enum(['immediate', 'task_aware']),
20
+ task_support: z.enum(['optional', 'required', 'forbidden']),
21
+ status: z.string().optional(),
22
+ progress_message: z.string().optional(),
23
+ }).optional(),
24
+ }).passthrough();
25
+ function wrapOutputSchemaWithNormalizedErrors(outputSchema) {
26
+ if (outputSchema instanceof z.ZodObject) {
27
+ return normalizedToolResultEnvelopeSchema.extend(outputSchema.partial().shape).passthrough();
28
+ }
29
+ return normalizedToolResultEnvelopeSchema;
30
+ }
3
31
  export function installNormalizedToolRegistration({ server, toolHelpRegistry, registeredToolMap, defaultOutputSchema, normalizeToolError, normalizeToolSuccess, executor, }) {
4
32
  const rawRegisterTool = server.registerTool.bind(server);
5
33
  server.registerTool = ((name, config, cb) => {
6
- const outputSchema = (config.outputSchema ?? defaultOutputSchema);
34
+ const declaredOutputSchema = (config.outputSchema ?? defaultOutputSchema);
35
+ const outputSchema = wrapOutputSchemaWithNormalizedErrors(declaredOutputSchema);
7
36
  rawHandlerRegistry.set(name, cb);
8
37
  toolHelpRegistry.set(name, {
9
38
  title: config.title ?? name,
10
39
  description: config.description ?? '',
11
40
  inputSchema: (config.inputSchema ?? {}),
12
- outputSchema,
41
+ outputSchema: declaredOutputSchema,
13
42
  annotations: config.annotations,
14
43
  });
15
44
  const registered = rawRegisterTool(name, {
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { pathToFileURL } from 'node:url';
2
+ import { realpathSync } from 'node:fs';
3
+ import { fileURLToPath } from 'node:url';
3
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
5
  import { createBlueprintExtractorServer } from './server-factory.js';
5
6
  export { createBlueprintExtractorServer } from './server-factory.js';
@@ -10,7 +11,20 @@ async function main() {
10
11
  const transport = new StdioServerTransport();
11
12
  await server.connect(transport);
12
13
  }
13
- if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
14
+ function isCliEntrypoint() {
15
+ const entryPath = process.argv[1];
16
+ if (!entryPath) {
17
+ return false;
18
+ }
19
+ try {
20
+ // npm/npx launch the package via a symlink in node_modules/.bin.
21
+ return realpathSync(entryPath) === realpathSync(fileURLToPath(import.meta.url));
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ }
27
+ if (isCliEntrypoint()) {
14
28
  main().catch((error) => {
15
29
  console.error('Fatal:', error);
16
30
  process.exit(1);
@@ -1243,12 +1243,12 @@ export declare const ImportJobSchema: z.ZodObject<{
1243
1243
  status: z.ZodOptional<z.ZodString>;
1244
1244
  progress_message: z.ZodOptional<z.ZodString>;
1245
1245
  }, "strip", z.ZodTypeAny, {
1246
- mode: "task_aware" | "immediate";
1246
+ mode: "immediate" | "task_aware";
1247
1247
  task_support: "optional" | "required" | "forbidden";
1248
1248
  status?: string | undefined;
1249
1249
  progress_message?: string | undefined;
1250
1250
  }, {
1251
- mode: "task_aware" | "immediate";
1251
+ mode: "immediate" | "task_aware";
1252
1252
  task_support: "optional" | "required" | "forbidden";
1253
1253
  status?: string | undefined;
1254
1254
  progress_message?: string | undefined;
@@ -1383,16 +1383,16 @@ export declare const ImportJobSchema: z.ZodObject<{
1383
1383
  code?: string | undefined;
1384
1384
  message?: string | undefined;
1385
1385
  recoverable?: boolean | undefined;
1386
+ next_steps?: string[] | undefined;
1387
+ _hints?: string[] | undefined;
1386
1388
  execution?: {
1387
- mode: "task_aware" | "immediate";
1389
+ mode: "immediate" | "task_aware";
1388
1390
  task_support: "optional" | "required" | "forbidden";
1389
1391
  status?: string | undefined;
1390
1392
  progress_message?: string | undefined;
1391
1393
  } | undefined;
1392
1394
  completedAt?: string | undefined;
1393
1395
  startedAt?: string | undefined;
1394
- next_steps?: string[] | undefined;
1395
- _hints?: string[] | undefined;
1396
1396
  jobId?: string | undefined;
1397
1397
  }, {
1398
1398
  status: string;
@@ -1433,16 +1433,16 @@ export declare const ImportJobSchema: z.ZodObject<{
1433
1433
  code?: string | undefined;
1434
1434
  message?: string | undefined;
1435
1435
  recoverable?: boolean | undefined;
1436
+ next_steps?: string[] | undefined;
1437
+ _hints?: string[] | undefined;
1436
1438
  execution?: {
1437
- mode: "task_aware" | "immediate";
1439
+ mode: "immediate" | "task_aware";
1438
1440
  task_support: "optional" | "required" | "forbidden";
1439
1441
  status?: string | undefined;
1440
1442
  progress_message?: string | undefined;
1441
1443
  } | undefined;
1442
1444
  completedAt?: string | undefined;
1443
1445
  startedAt?: string | undefined;
1444
- next_steps?: string[] | undefined;
1445
- _hints?: string[] | undefined;
1446
1446
  jobId?: string | undefined;
1447
1447
  }>;
1448
1448
  export declare const ImportJobListSchema: z.ZodObject<{
@@ -1475,12 +1475,12 @@ export declare const ImportJobListSchema: z.ZodObject<{
1475
1475
  status: z.ZodOptional<z.ZodString>;
1476
1476
  progress_message: z.ZodOptional<z.ZodString>;
1477
1477
  }, "strip", z.ZodTypeAny, {
1478
- mode: "task_aware" | "immediate";
1478
+ mode: "immediate" | "task_aware";
1479
1479
  task_support: "optional" | "required" | "forbidden";
1480
1480
  status?: string | undefined;
1481
1481
  progress_message?: string | undefined;
1482
1482
  }, {
1483
- mode: "task_aware" | "immediate";
1483
+ mode: "immediate" | "task_aware";
1484
1484
  task_support: "optional" | "required" | "forbidden";
1485
1485
  status?: string | undefined;
1486
1486
  progress_message?: string | undefined;
@@ -1502,12 +1502,12 @@ export declare const ImportJobListSchema: z.ZodObject<{
1502
1502
  status: z.ZodOptional<z.ZodString>;
1503
1503
  progress_message: z.ZodOptional<z.ZodString>;
1504
1504
  }, "strip", z.ZodTypeAny, {
1505
- mode: "task_aware" | "immediate";
1505
+ mode: "immediate" | "task_aware";
1506
1506
  task_support: "optional" | "required" | "forbidden";
1507
1507
  status?: string | undefined;
1508
1508
  progress_message?: string | undefined;
1509
1509
  }, {
1510
- mode: "task_aware" | "immediate";
1510
+ mode: "immediate" | "task_aware";
1511
1511
  task_support: "optional" | "required" | "forbidden";
1512
1512
  status?: string | undefined;
1513
1513
  progress_message?: string | undefined;
@@ -1642,16 +1642,16 @@ export declare const ImportJobListSchema: z.ZodObject<{
1642
1642
  code?: string | undefined;
1643
1643
  message?: string | undefined;
1644
1644
  recoverable?: boolean | undefined;
1645
+ next_steps?: string[] | undefined;
1646
+ _hints?: string[] | undefined;
1645
1647
  execution?: {
1646
- mode: "task_aware" | "immediate";
1648
+ mode: "immediate" | "task_aware";
1647
1649
  task_support: "optional" | "required" | "forbidden";
1648
1650
  status?: string | undefined;
1649
1651
  progress_message?: string | undefined;
1650
1652
  } | undefined;
1651
1653
  completedAt?: string | undefined;
1652
1654
  startedAt?: string | undefined;
1653
- next_steps?: string[] | undefined;
1654
- _hints?: string[] | undefined;
1655
1655
  jobId?: string | undefined;
1656
1656
  }, {
1657
1657
  status: string;
@@ -1692,16 +1692,16 @@ export declare const ImportJobListSchema: z.ZodObject<{
1692
1692
  code?: string | undefined;
1693
1693
  message?: string | undefined;
1694
1694
  recoverable?: boolean | undefined;
1695
+ next_steps?: string[] | undefined;
1696
+ _hints?: string[] | undefined;
1695
1697
  execution?: {
1696
- mode: "task_aware" | "immediate";
1698
+ mode: "immediate" | "task_aware";
1697
1699
  task_support: "optional" | "required" | "forbidden";
1698
1700
  status?: string | undefined;
1699
1701
  progress_message?: string | undefined;
1700
1702
  } | undefined;
1701
1703
  completedAt?: string | undefined;
1702
1704
  startedAt?: string | undefined;
1703
- next_steps?: string[] | undefined;
1704
- _hints?: string[] | undefined;
1705
1705
  jobId?: string | undefined;
1706
1706
  }>, "many">;
1707
1707
  }, "strip", z.ZodTypeAny, {
@@ -1748,16 +1748,16 @@ export declare const ImportJobListSchema: z.ZodObject<{
1748
1748
  code?: string | undefined;
1749
1749
  message?: string | undefined;
1750
1750
  recoverable?: boolean | undefined;
1751
+ next_steps?: string[] | undefined;
1752
+ _hints?: string[] | undefined;
1751
1753
  execution?: {
1752
- mode: "task_aware" | "immediate";
1754
+ mode: "immediate" | "task_aware";
1753
1755
  task_support: "optional" | "required" | "forbidden";
1754
1756
  status?: string | undefined;
1755
1757
  progress_message?: string | undefined;
1756
1758
  } | undefined;
1757
1759
  completedAt?: string | undefined;
1758
1760
  startedAt?: string | undefined;
1759
- next_steps?: string[] | undefined;
1760
- _hints?: string[] | undefined;
1761
1761
  jobId?: string | undefined;
1762
1762
  }[];
1763
1763
  code?: string | undefined;
@@ -1769,14 +1769,14 @@ export declare const ImportJobListSchema: z.ZodObject<{
1769
1769
  severity?: string | undefined;
1770
1770
  }[] | undefined;
1771
1771
  recoverable?: boolean | undefined;
1772
+ next_steps?: string[] | undefined;
1773
+ _hints?: string[] | undefined;
1772
1774
  execution?: {
1773
- mode: "task_aware" | "immediate";
1775
+ mode: "immediate" | "task_aware";
1774
1776
  task_support: "optional" | "required" | "forbidden";
1775
1777
  status?: string | undefined;
1776
1778
  progress_message?: string | undefined;
1777
1779
  } | undefined;
1778
- next_steps?: string[] | undefined;
1779
- _hints?: string[] | undefined;
1780
1780
  }, {
1781
1781
  success: boolean;
1782
1782
  operation: string;
@@ -1821,16 +1821,16 @@ export declare const ImportJobListSchema: z.ZodObject<{
1821
1821
  code?: string | undefined;
1822
1822
  message?: string | undefined;
1823
1823
  recoverable?: boolean | undefined;
1824
+ next_steps?: string[] | undefined;
1825
+ _hints?: string[] | undefined;
1824
1826
  execution?: {
1825
- mode: "task_aware" | "immediate";
1827
+ mode: "immediate" | "task_aware";
1826
1828
  task_support: "optional" | "required" | "forbidden";
1827
1829
  status?: string | undefined;
1828
1830
  progress_message?: string | undefined;
1829
1831
  } | undefined;
1830
1832
  completedAt?: string | undefined;
1831
1833
  startedAt?: string | undefined;
1832
- next_steps?: string[] | undefined;
1833
- _hints?: string[] | undefined;
1834
1834
  jobId?: string | undefined;
1835
1835
  }[];
1836
1836
  code?: string | undefined;
@@ -1842,14 +1842,14 @@ export declare const ImportJobListSchema: z.ZodObject<{
1842
1842
  severity?: string | undefined;
1843
1843
  }[] | undefined;
1844
1844
  recoverable?: boolean | undefined;
1845
+ next_steps?: string[] | undefined;
1846
+ _hints?: string[] | undefined;
1845
1847
  execution?: {
1846
- mode: "task_aware" | "immediate";
1848
+ mode: "immediate" | "task_aware";
1847
1849
  task_support: "optional" | "required" | "forbidden";
1848
1850
  status?: string | undefined;
1849
1851
  progress_message?: string | undefined;
1850
1852
  } | undefined;
1851
- next_steps?: string[] | undefined;
1852
- _hints?: string[] | undefined;
1853
1853
  }>;
1854
1854
  export declare const UserDefinedStructMutationOperationSchema: z.ZodEnum<["replace_fields", "patch_field", "rename_field", "remove_field", "reorder_fields"]>;
1855
1855
  export declare const UserDefinedEnumMutationOperationSchema: z.ZodEnum<["replace_entries", "rename_entry", "remove_entry", "reorder_entries"]>;