@mcpjam/cli 3.18.0 → 3.19.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.
package/dist/index.js CHANGED
@@ -2,14 +2,14 @@
2
2
  import { Command, CommanderError } from 'commander';
3
3
  import { realpathSync, mkdirSync, writeFileSync, readFileSync, existsSync, statSync, closeSync, renameSync, openSync } from 'fs';
4
4
  import { pathToFileURL } from 'url';
5
- import { probeMcpServer, redactSensitiveValue, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, classifyMcpHeader, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, SubscriptionCoordinator, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, MCPAppsConformanceSuite, MCPTasksConformanceTest, runOAuthLogin, OAuthConformanceTest, OAuthConformanceSuite, runXaaFlow, MCPConformanceTest, MCPConformanceSuite, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, DEFAULT_SUBSCRIPTION_RECONNECT_POLICY, isKnownProtocolVersion, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, normalizeRegistrationStrategy, normalizeXaaClientAuth, normalizeIdentityAssertionFormat, IDENTITY_ASSERTION_FORMATS, XAA_CONFIDENTIAL_CIMD_ORIGIN, getLocalConfidentialCimdProvider, MCP_PROTOCOL_VERSIONS, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, openUrlInBrowser, MCPClientManager, decodeMcpHeaderValue, canDeclareTasksExtension, createStrictElicitationContentValidator, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, MCP_TASKS_CHECK_CATEGORIES, MCP_TASKS_CHECK_IDS, OAuthProxyError, isLoopbackHost, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS, TaskLifecycleEngine, driveTaskToTerminal, extensionTaskToObservation, legacyTaskToObservation, isUnknownTaskError, isMCPTasksWireError, LEGACY_TASK_STATUSES } from '@mcpjam/sdk';
5
+ import { probeMcpServer, redactSensitiveValue, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, classifyMcpHeader, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, SubscriptionCoordinator, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, scoreFromAppsResult, MCPAppsConformanceSuite, MCPTasksConformanceTest, scoreFromTasksResult, runOAuthLogin, OAuthConformanceTest, scoreFromOAuthResult, OAuthConformanceSuite, runXaaFlow, MCPConformanceTest, scoreFromProtocolResult, MCPConformanceSuite, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, DEFAULT_SUBSCRIPTION_RECONNECT_POLICY, isKnownProtocolVersion, describeConformanceScore, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, normalizeRegistrationStrategy, normalizeXaaClientAuth, normalizeIdentityAssertionFormat, IDENTITY_ASSERTION_FORMATS, XAA_CONFIDENTIAL_CIMD_ORIGIN, getLocalConfidentialCimdProvider, MCP_PROTOCOL_VERSIONS, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, openUrlInBrowser, MCPClientManager, decodeMcpHeaderValue, canDeclareTasksExtension, createStrictElicitationContentValidator, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, MCP_TASKS_CHECK_CATEGORIES, MCP_TASKS_CHECK_IDS, OAuthProxyError, isLoopbackHost, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS, TaskLifecycleEngine, driveTaskToTerminal, extensionTaskToObservation, legacyTaskToObservation, isUnknownTaskError, isMCPTasksWireError, LEGACY_TASK_STATUSES } from '@mcpjam/sdk';
6
6
  import { mkdir, writeFile, readFile, chmod, rename, rm } from 'fs/promises';
7
7
  import path2, { dirname, join, basename } from 'path';
8
8
  import { randomUUID } from 'crypto';
9
9
  import { spawn } from 'child_process';
10
10
  import { createRequire } from 'module';
11
11
  import os, { homedir } from 'os';
12
- import { cancelEvalRunOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createHostOperation, updateHostOperation, createEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listProjectsOperation, listProjectServersOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation, listEnvironmentsOperation, getEnvironmentOperation, resolveEnvironmentOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation } from '@mcpjam/sdk/platform';
12
+ import { cancelEvalRunOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createHostOperation, updateHostOperation, createEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listProjectsOperation, listProjectServersOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation, listEnvironmentsOperation, getEnvironmentOperation, resolveEnvironmentOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation } from '@mcpjam/sdk/platform';
13
13
  import { buildHostProfilesFromCatalog, buildMarketHostProfiles, scanWidgetUsage, evaluateMarketHosts, fetchHostCompatCatalog } from '@mcpjam/sdk/host-compat';
14
14
  import { HOST_TEMPLATES as HOST_TEMPLATES$1, HOST_TEMPLATE_IDS, seedHostTemplate } from '@mcpjam/sdk/host-config/templates';
15
15
  import { applyVisibilityPolicyAndCountSignals, isAppOnlyTool, extractHostExecutionPolicy, hostConnectionProfile } from '@mcpjam/sdk/host-config/internal';
@@ -25,7 +25,46 @@ import { WebSocket } from 'ws';
25
25
 
26
26
  // package.json
27
27
  var package_default = {
28
- version: "3.18.0"};
28
+ version: "3.19.0"};
29
+ function conformanceExitCode(result) {
30
+ if (result.outcome === "incomplete") return 3;
31
+ if (result.outcome === "failed") return 1;
32
+ return result.passed ? 0 : 1;
33
+ }
34
+ function conformanceSuiteExitCode(results) {
35
+ const codes = results.map(conformanceExitCode);
36
+ if (codes.includes(1)) return 1;
37
+ if (codes.includes(3)) return 3;
38
+ return 0;
39
+ }
40
+ function reportScore(score, command, label) {
41
+ if (score.score === null) return;
42
+ if (command.optsWithGlobals().quiet) return;
43
+ process.stderr.write(
44
+ `Score${label ? ` [${label}]` : ""}: ${describeConformanceScore(score)}
45
+ `
46
+ );
47
+ }
48
+ function reportReadiness(result, command) {
49
+ const readiness = result.readiness ?? [];
50
+ if (readiness.length === 0) return;
51
+ if (command.optsWithGlobals().quiet) return;
52
+ process.stderr.write(`Advice (${readiness.length}):
53
+ `);
54
+ for (const advice of readiness) {
55
+ process.stderr.write(
56
+ ` [${advice.specStrength}] ${advice.title}: ${advice.message}
57
+ `
58
+ );
59
+ }
60
+ }
61
+ function reportIncomplete(result, command) {
62
+ const reason = result.incompleteReason;
63
+ if (!reason) return;
64
+ if (command.optsWithGlobals().quiet) return;
65
+ process.stderr.write(`Run incomplete: ${reason}
66
+ `);
67
+ }
29
68
 
30
69
  // src/lib/output.ts
31
70
  var DEFAULT_OUTPUT_FORMAT = "json";
@@ -2715,8 +2754,11 @@ function registerAppsCommands(program) {
2715
2754
  writeConformanceOutput(
2716
2755
  renderConformanceForCli(outputResult, reporter, globalOptions.format)
2717
2756
  );
2718
- if (!result.passed) {
2719
- setProcessExitCode(1);
2757
+ reportScore(scoreFromAppsResult(result), command);
2758
+ reportIncomplete(result, command);
2759
+ const exitCode = conformanceExitCode(result);
2760
+ if (exitCode !== 0) {
2761
+ setProcessExitCode(exitCode);
2720
2762
  }
2721
2763
  });
2722
2764
  addSharedServerOptions(
@@ -2964,8 +3006,13 @@ function registerAppsCommands(program) {
2964
3006
  writeConformanceOutput(
2965
3007
  renderConformanceForCli(outputResult, reporter, globalOptions.format)
2966
3008
  );
2967
- if (!result.passed) {
2968
- setProcessExitCode(1);
3009
+ for (const run of result.results) {
3010
+ reportScore(scoreFromAppsResult(run), command, run.label);
3011
+ reportIncomplete(run, command);
3012
+ }
3013
+ const exitCode = conformanceSuiteExitCode(result.results);
3014
+ if (exitCode !== 0) {
3015
+ setProcessExitCode(exitCode);
2969
3016
  }
2970
3017
  });
2971
3018
  }
@@ -5091,8 +5138,11 @@ function registerEvalCommands(program) {
5091
5138
  "--project <id-or-name>",
5092
5139
  "Project name or ID (defaults to the most recently updated project)"
5093
5140
  ).option(
5094
- "--server <name...>",
5141
+ "--server <id-or-name...>",
5095
5142
  "Override the suite's saved server selection (HTTP servers only)"
5143
+ ).option(
5144
+ "--environment <id-or-name>",
5145
+ "Project environment to run against (must be attached to the suite; optional when it has exactly one)"
5096
5146
  )
5097
5147
  ).action(
5098
5148
  async (options, command) => {
@@ -5104,7 +5154,8 @@ function registerEvalCommands(program) {
5104
5154
  {
5105
5155
  project: options.project,
5106
5156
  suite: options.suite,
5107
- ...options.server ? { servers: options.server } : {}
5157
+ ...options.server ? { servers: options.server } : {},
5158
+ ...options.environment ? { environment: options.environment } : {}
5108
5159
  },
5109
5160
  { client, signal }
5110
5161
  )
@@ -5420,7 +5471,10 @@ function registerEvalCommands(program) {
5420
5471
  }
5421
5472
  );
5422
5473
  addPlatformOptions3(
5423
- evals.command("schedule").description("Enable or disable scheduled runs for a suite").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--enable", "Enable scheduled runs").option("--disable", "Disable scheduled runs").option("--interval <minutes>", "Run interval in minutes (5\u201310080)")
5474
+ evals.command("schedule").description("Enable or disable scheduled runs for a suite").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--enable", "Enable scheduled runs").option("--disable", "Disable scheduled runs").option("--interval <minutes>", "Run interval in minutes (5\u201310080)").option(
5475
+ "--environment <id-or-name>",
5476
+ "Project environment the scheduled runs launch (only with --enable)"
5477
+ )
5424
5478
  ).action(
5425
5479
  async (options, command) => {
5426
5480
  if (options.enable && options.disable) {
@@ -5433,11 +5487,54 @@ function registerEvalCommands(program) {
5433
5487
  project: options.project,
5434
5488
  suite: options.suite,
5435
5489
  enabled: Boolean(options.enable),
5436
- ...options.interval !== void 0 ? { intervalMinutes: Number(options.interval) } : {}
5490
+ ...options.interval !== void 0 ? { intervalMinutes: Number(options.interval) } : {},
5491
+ ...options.environment ? { environment: options.environment } : {}
5437
5492
  });
5438
5493
  await executeOp(setEvalSuiteScheduleOperation, input, options, command);
5439
5494
  }
5440
5495
  );
5496
+ const environments = evals.command("environments").description(
5497
+ "Attach or detach the project environments an eval suite runs against"
5498
+ );
5499
+ addPlatformOptions3(
5500
+ environments.command("set").description(
5501
+ "Replace the suite's attached environments (this sets the whole list)"
5502
+ ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").requiredOption(
5503
+ "--environment <id-or-name...>",
5504
+ "Project environments to attach, in order"
5505
+ ).option("--project <id-or-name>", PROJECT_OPT)
5506
+ ).action(
5507
+ async (options, command) => {
5508
+ await executeOp(
5509
+ setEvalSuiteEnvironmentsOperation,
5510
+ {
5511
+ project: options.project,
5512
+ suite: options.suite,
5513
+ environments: options.environment
5514
+ },
5515
+ options,
5516
+ command
5517
+ );
5518
+ }
5519
+ );
5520
+ addPlatformOptions3(
5521
+ environments.command("clear").description(
5522
+ "Detach every environment, reverting the suite to its saved server selection"
5523
+ ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT)
5524
+ ).action(
5525
+ async (options, command) => {
5526
+ await executeOp(
5527
+ setEvalSuiteEnvironmentsOperation,
5528
+ {
5529
+ project: options.project,
5530
+ suite: options.suite,
5531
+ environments: null
5532
+ },
5533
+ options,
5534
+ command
5535
+ );
5536
+ }
5537
+ );
5441
5538
  const cases = evals.command("cases").description("List, author, and edit an eval suite's test cases");
5442
5539
  addPlatformOptions3(
5443
5540
  cases.command("list").description("List a suite's test cases").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT)
@@ -5469,6 +5566,9 @@ function registerEvalCommands(program) {
5469
5566
  ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").requiredOption("--case <id-or-title>", "Eval case title or ID").option("--project <id-or-name>", PROJECT_OPT).option(
5470
5567
  "--server <id-or-name...>",
5471
5568
  "Override the suite's saved servers for this run"
5569
+ ).option(
5570
+ "--environment <id-or-name>",
5571
+ "Project environment to run against (must be attached to the suite)"
5472
5572
  )
5473
5573
  ).action(
5474
5574
  async (options, command) => {
@@ -5478,7 +5578,8 @@ function registerEvalCommands(program) {
5478
5578
  project: options.project,
5479
5579
  suite: options.suite,
5480
5580
  case: options.case,
5481
- ...options.server?.length ? { servers: options.server } : {}
5581
+ ...options.server?.length ? { servers: options.server } : {},
5582
+ ...options.environment ? { environment: options.environment } : {}
5482
5583
  },
5483
5584
  options,
5484
5585
  command
@@ -5519,8 +5620,11 @@ function registerEvalCommands(program) {
5519
5620
  cases.command("generate").description(
5520
5621
  "AI-generate test cases from the suite's tools (spends credits)"
5521
5622
  ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--mode <normal|negative>", "Generation mode (default normal)").option(
5522
- "--server <name...>",
5623
+ "--server <id-or-name...>",
5523
5624
  "Servers to discover tools from (default: suite's)"
5625
+ ).option(
5626
+ "--environment <id-or-name>",
5627
+ "Discover tools from this attached environment's server set"
5524
5628
  ).option(
5525
5629
  "--case-model <id...>",
5526
5630
  "Execution model(s) for the generated cases"
@@ -5555,6 +5659,7 @@ function registerEvalCommands(program) {
5555
5659
  suite: options.suite,
5556
5660
  ...options.mode ? { mode: options.mode } : {},
5557
5661
  ...options.server ? { servers: options.server } : {},
5662
+ ...options.environment ? { environment: options.environment } : {},
5558
5663
  ...options.caseModel ? { caseModels: options.caseModel.map((model) => ({ model })) } : {},
5559
5664
  ...Object.keys(caseMix).length > 0 ? { caseMix } : {},
5560
5665
  ...options.varyUserStyles ? { varyUserStyles: true } : {}
@@ -6622,8 +6727,12 @@ function registerProtocolCommands(program) {
6622
6727
  const config = buildConfig(options);
6623
6728
  const result = await new MCPConformanceTest(config).run();
6624
6729
  writeConformanceOutput2(renderConformanceForCli(result, reporter, format));
6625
- if (!result.passed) {
6626
- setProcessExitCode(1);
6730
+ reportScore(scoreFromProtocolResult(result), command);
6731
+ reportReadiness(result, command);
6732
+ reportIncomplete(result, command);
6733
+ const exitCode = conformanceExitCode(result);
6734
+ if (exitCode !== 0) {
6735
+ setProcessExitCode(exitCode);
6627
6736
  }
6628
6737
  });
6629
6738
  protocol.command("conformance-suite").description(
@@ -6637,8 +6746,14 @@ function registerProtocolCommands(program) {
6637
6746
  const config = loadProtocolSuiteConfig(options.config);
6638
6747
  const result = await new MCPConformanceSuite(config).run();
6639
6748
  writeConformanceOutput2(renderConformanceForCli(result, reporter, format));
6640
- if (!result.passed) {
6641
- setProcessExitCode(1);
6749
+ for (const run of result.results) {
6750
+ reportScore(scoreFromProtocolResult(run), command, run.label);
6751
+ reportReadiness(run, command);
6752
+ reportIncomplete(run, command);
6753
+ }
6754
+ const exitCode = conformanceSuiteExitCode(result.results);
6755
+ if (exitCode !== 0) {
6756
+ setProcessExitCode(exitCode);
6642
6757
  }
6643
6758
  });
6644
6759
  }
@@ -6999,8 +7114,12 @@ function registerOAuthCommands(program) {
6999
7114
  if (credentialsFileError) {
7000
7115
  throw credentialsFileError;
7001
7116
  }
7002
- if (!result.passed) {
7117
+ reportScore(scoreFromOAuthResult(result), command);
7118
+ reportIncomplete(result, command);
7119
+ if (result.outcome === "failed") {
7003
7120
  setProcessExitCode(1);
7121
+ } else if (result.outcome === "incomplete") {
7122
+ setProcessExitCode(3);
7004
7123
  }
7005
7124
  });
7006
7125
  oauth.command("conformance-suite").description(
@@ -7058,8 +7177,17 @@ function registerOAuthCommands(program) {
7058
7177
  if (credentialsFileError) {
7059
7178
  throw credentialsFileError;
7060
7179
  }
7061
- if (!result.passed) {
7180
+ for (const run of result.results) {
7181
+ reportScore(scoreFromOAuthResult(run), command, run.label);
7182
+ reportIncomplete(run, command);
7183
+ }
7184
+ const flowOutcomes = result.results.map(
7185
+ (run) => run.outcome ?? (run.passed ? "passed" : "failed")
7186
+ );
7187
+ if (flowOutcomes.includes("failed")) {
7062
7188
  setProcessExitCode(1);
7189
+ } else if (flowOutcomes.includes("incomplete")) {
7190
+ setProcessExitCode(3);
7063
7191
  }
7064
7192
  });
7065
7193
  oauth.command("metadata").description("Fetch OAuth metadata from a URL").requiredOption("--url <url>", "OAuth metadata URL").action(async (options, command) => {
@@ -9788,11 +9916,7 @@ var TASKS_CHECK_IDS_BY_CATEGORY = {
9788
9916
  "tasks-undeclared-capability-rejected"
9789
9917
  ]
9790
9918
  };
9791
- function tasksConformanceExitCode(result) {
9792
- if (result.outcome === "incomplete") return 3;
9793
- if (result.outcome === "failed") return 1;
9794
- return result.passed ? 0 : 1;
9795
- }
9919
+ var tasksConformanceExitCode = conformanceExitCode;
9796
9920
  function collectInvalidEntries3(values, allowed) {
9797
9921
  return (values ?? []).filter((value) => !allowed.includes(value));
9798
9922
  }
@@ -10228,6 +10352,7 @@ function registerTasksCommands(program) {
10228
10352
  const output = renderConformanceForCli(outputResult, reporter, format);
10229
10353
  process.stdout.write(output.endsWith("\n") ? output : `${output}
10230
10354
  `);
10355
+ reportScore(scoreFromTasksResult(result), command);
10231
10356
  const incompleteReason = result.incompleteReason;
10232
10357
  if (incompleteReason && !globalOptions.quiet) {
10233
10358
  process.stderr.write(`Run incomplete: ${incompleteReason}