@mcpjam/cli 5.3.0 → 5.5.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
@@ -9,7 +9,7 @@ import { mkdir, writeFile, readFile, chmod, rename, rm, open, unlink, stat } fro
9
9
  import { spawn } from 'child_process';
10
10
  import { createRequire } from 'module';
11
11
  import os, { homedir } from 'os';
12
- import { getRegistryDirectoryServerOperation, listOrganizationsOperation, listProjectsOperation, createProjectOperation, updateProjectOperation, deleteProjectOperation, connectProjectServerOperation, getProjectServerConnectionStatusOperation, listChatSessionsOperation, resolveProject, createTunnelOperation, listEvalSuiteRunsOperation, runEvalSuiteOperation, getEvalRunOperation, cancelEvalRunOperation, requestEvalRunJudgeOperation, listEvalCheckReposOperation, connectEvalCheckRepoOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createClientOperation, updateClientOperation, setClientServersOperation, duplicateClientOperation, createEnvironmentOperation, ensureAdhocEnvironmentOperation, nameEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, runOperationWithPermalinks, withPermalinkEnvelope, PlatformApiError, installRegistryServerOperation, installRegistryDirectoryServerOperation, getProjectServerOperation, DEFAULT_PLATFORM_API_BASE_URL, projectResolutionError, listProjectServersOperation, createProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, isPlatformApiError, createEvalSuiteOperation, listEvalSuitesOperation, buildAppPermalink, resolveEnvironmentOperation, listClientsOperation, getClientOperation, deleteClientOperation, listEnvironmentsOperation, getEnvironmentOperation, getEnvironmentCapabilitiesOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation, listProjectSkillsOperation, getProjectSkillOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, listScenariosOperation, getScenarioOperation, publishScenarioOperation, unpublishScenarioOperation, PlatformApiClient, listServerToolsOperation, getCapabilitiesOperation, searchSessionsOperation, sendChatMessageOperation, getChatSessionOperation, getChatSessionTraceOperation, listPersonasOperation, getPersonaOperation, createPersonaOperation, updatePersonaOperation, deletePersonaOperation, generatePersonasOperation, getJourneyOperation, createJourneyOperation, updateJourneyOperation, archiveJourneyOperation, generateJourneysOperation, getSwarmOverviewOperation, getJourneyRunScorecardOperation, listSwarmFindingsOperation, dismissSwarmFindingOperation, undismissSwarmFindingOperation, getWaveInsightsOperation, requestWaveInsightsOperation, cancelWaveInsightsOperation, listSwarmsOperation, getSwarmOperation, createSwarmOperation, updateSwarmOperation, archiveSwarmOperation, getUserTestingScenarioOperation, listUserTestingSessionsOperation, getUserTestingSessionOperation, getUserTestingMetricsOperation, getUserTestingUsageOperation, listUserTestingFindingsOperation, getUserTestingSignalsOperation, getUserTestingInsightsOperation, requestUserTestingInsightsOperation, cancelUserTestingInsightsOperation, dismissUserTestingFindingOperation, undismissUserTestingFindingOperation, updateUserTestingScenarioOperation, setUserTestingGuestExecutionOperation, rotateUserTestingLinkOperation, upsertUserTestingMemberOperation, removeUserTestingMemberOperation, rebindUserTestingScenarioOperation, startClaudeReadinessRunOperation, startOpenAIReadinessRunOperation, getReadinessRunOperation, listReadinessRunsOperation, cancelReadinessRunOperation, getReadinessReportOperation, listRegistryDirectorySourcesOperation, searchRegistryDirectoryOperation, listRegistryServersOperation, listRegistryConnectionsOperation, uninstallRegistryServerOperation } from '@mcpjam/sdk/platform';
12
+ import { getRegistryDirectoryServerOperation, listOrganizationsOperation, listProjectsOperation, createProjectOperation, updateProjectOperation, deleteProjectOperation, connectProjectServerOperation, getProjectServerConnectionStatusOperation, cancelProjectServerConnectionOperation, listChatSessionsOperation, resolveProject, createTunnelOperation, listEvalSuiteRunsOperation, runEvalSuiteOperation, getEvalRunOperation, cancelEvalRunOperation, requestEvalRunJudgeOperation, listEvalCheckReposOperation, connectEvalCheckRepoOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createClientOperation, updateClientOperation, setClientServersOperation, duplicateClientOperation, createEnvironmentOperation, ensureAdhocEnvironmentOperation, nameEnvironmentOperation, updateEnvironmentOperation, createSecretOperation, updateSecretOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, runOperationWithPermalinks, withPermalinkEnvelope, PlatformApiError, installRegistryServerOperation, installRegistryDirectoryServerOperation, getProjectServerOperation, DEFAULT_PLATFORM_API_BASE_URL, projectResolutionError, listProjectServersOperation, createProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, isPlatformApiError, createEvalSuiteOperation, listEvalSuitesOperation, buildAppPermalink, listEvalSuiteStageAnalyticsOperation, getEvalRunStageAnalyticsOperation, resolveEnvironmentOperation, listClientsOperation, getClientOperation, deleteClientOperation, listEnvironmentsOperation, getEnvironmentOperation, getEnvironmentCapabilitiesOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listSecretsOperation, getSecretOperation, deleteSecretOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation, listProjectSkillsOperation, getProjectSkillOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, listScenariosOperation, getScenarioOperation, publishScenarioOperation, unpublishScenarioOperation, PlatformApiClient, listServerToolsOperation, getCapabilitiesOperation, searchSessionsOperation, sendChatMessageOperation, getChatSessionOperation, getChatSessionTraceOperation, listPersonasOperation, getPersonaOperation, createPersonaOperation, updatePersonaOperation, deletePersonaOperation, generatePersonasOperation, getJourneyOperation, createJourneyOperation, updateJourneyOperation, archiveJourneyOperation, generateJourneysOperation, getSwarmOverviewOperation, getJourneyRunScorecardOperation, listSwarmFindingsOperation, dismissSwarmFindingOperation, undismissSwarmFindingOperation, getWaveInsightsOperation, requestWaveInsightsOperation, cancelWaveInsightsOperation, listSwarmsOperation, getSwarmOperation, createSwarmOperation, updateSwarmOperation, archiveSwarmOperation, getUserTestingScenarioOperation, listUserTestingSessionsOperation, getUserTestingSessionOperation, getUserTestingMetricsOperation, getUserTestingUsageOperation, listUserTestingFindingsOperation, getUserTestingSignalsOperation, getUserTestingInsightsOperation, requestUserTestingInsightsOperation, cancelUserTestingInsightsOperation, dismissUserTestingFindingOperation, undismissUserTestingFindingOperation, updateUserTestingScenarioOperation, setUserTestingGuestExecutionOperation, rotateUserTestingLinkOperation, upsertUserTestingMemberOperation, removeUserTestingMemberOperation, rebindUserTestingScenarioOperation, startClaudeReadinessRunOperation, startOpenAIReadinessRunOperation, getReadinessRunOperation, listReadinessRunsOperation, cancelReadinessRunOperation, getReadinessReportOperation, listRegistryDirectorySourcesOperation, searchRegistryDirectoryOperation, listRegistryServersOperation, listRegistryConnectionsOperation, uninstallRegistryServerOperation } from '@mcpjam/sdk/platform';
13
13
  import { isDeepStrictEqual } from 'util';
14
14
  import { MAX_BATCH_CREATE_CASES, evalSuiteFileSchema, MAX_IMPORT_NOTE_CHARS, isOpaqueId } from '@mcpjam/sdk/contract';
15
15
  import { HOST_TEMPLATES, HOST_TEMPLATE_IDS, seedHostTemplate } from '@mcpjam/sdk/host-config/templates';
@@ -27,7 +27,7 @@ import { PostHog } from 'posthog-node';
27
27
 
28
28
  // package.json
29
29
  var package_default = {
30
- version: "5.3.0"};
30
+ version: "5.5.0"};
31
31
  function conformanceExitCode(result) {
32
32
  if (result.outcome === "incomplete") return 3;
33
33
  if (result.outcome === "failed") return 1;
@@ -601,9 +601,9 @@ function writeReporterResult(reporter, report) {
601
601
  }
602
602
  writeResult(renderStructuredRunJson(report), "json");
603
603
  }
604
- function writeEvalDecisionSummary(format, summary, destination = process.stdout) {
604
+ function writeEvalDecisionSummary(format, summary, destination = process.stdout, options = {}) {
605
605
  if (format !== "human" || !summary) return;
606
- destination.write(`${formatEvalRunDecisionSummary(summary)}
606
+ destination.write(`${formatEvalRunDecisionSummary(summary, options)}
607
607
  `);
608
608
  }
609
609
  async function writeJsonArtifact(outputPath, payload) {
@@ -4059,6 +4059,51 @@ function resolveExplicitApiUrl(options, env) {
4059
4059
  }
4060
4060
  return void 0;
4061
4061
  }
4062
+ var RESERVED_HEADER_NAMES = /* @__PURE__ */ new Set([
4063
+ "authorization",
4064
+ "idempotency-key",
4065
+ "content-type"
4066
+ ]);
4067
+ var HEADER_NAME_RE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
4068
+ function parseHeader2(raw, source) {
4069
+ const separator = raw.indexOf(":");
4070
+ if (separator < 1) {
4071
+ throw usageError(
4072
+ `${source} must be "Name: value" \u2014 got ${JSON.stringify(raw)}`
4073
+ );
4074
+ }
4075
+ const name = raw.slice(0, separator).trim();
4076
+ const value = raw.slice(separator + 1).trim();
4077
+ if (!HEADER_NAME_RE.test(name)) {
4078
+ throw usageError(`${source} has an invalid header name ${JSON.stringify(name)}`);
4079
+ }
4080
+ if (value.length === 0) {
4081
+ throw usageError(`${source} has an empty value for ${JSON.stringify(name)}`);
4082
+ }
4083
+ if (/[\r\n]/.test(value)) {
4084
+ throw usageError(`${source} value for ${JSON.stringify(name)} contains a line break`);
4085
+ }
4086
+ const lower = name.toLowerCase();
4087
+ if (RESERVED_HEADER_NAMES.has(lower)) {
4088
+ throw usageError(
4089
+ `${source} cannot set ${JSON.stringify(name)} \u2014 it is derived from the credential and request`
4090
+ );
4091
+ }
4092
+ return [lower, value];
4093
+ }
4094
+ function resolvePlatformExtraHeaders(options, env = process.env) {
4095
+ const headers = {};
4096
+ for (const line2 of (env.MCPJAM_API_HEADERS ?? "").split("\n")) {
4097
+ if (line2.trim().length === 0) continue;
4098
+ const [name, value] = parseHeader2(line2, "MCPJAM_API_HEADERS");
4099
+ headers[name] = value;
4100
+ }
4101
+ for (const raw of options.apiHeader ?? []) {
4102
+ const [name, value] = parseHeader2(raw, "--api-header");
4103
+ headers[name] = value;
4104
+ }
4105
+ return Object.keys(headers).length > 0 ? headers : void 0;
4106
+ }
4062
4107
  function resolvePlatformBaseUrl(options, env = process.env) {
4063
4108
  return resolveExplicitApiUrl(options, env) ?? DEFAULT_PLATFORM_API_BASE_URL;
4064
4109
  }
@@ -4068,6 +4113,7 @@ function resolvePlatformOrigin(options, env = process.env) {
4068
4113
  function buildPlatformClient(options, deps = {}) {
4069
4114
  const env = deps.env ?? process.env;
4070
4115
  const credential = resolvePlatformCredential(options, deps);
4116
+ const extraHeaders = resolvePlatformExtraHeaders(options, env);
4071
4117
  let baseUrl = resolveExplicitApiUrl(options, env);
4072
4118
  if (!baseUrl && credential.kind === "oauth") {
4073
4119
  const stored = readStoredAuth(deps.authFilePath ?? getAuthFilePath({ env }));
@@ -4079,7 +4125,8 @@ function buildPlatformClient(options, deps = {}) {
4079
4125
  getAuth: credential.getAuth,
4080
4126
  ...deps.fetchFn ? { fetch: deps.fetchFn } : {},
4081
4127
  ...options.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {},
4082
- userAgent: `mcpjam-cli/${package_default.version}`
4128
+ userAgent: `mcpjam-cli/${package_default.version}`,
4129
+ ...extraHeaders ? { extraHeaders } : {}
4083
4130
  });
4084
4131
  return { client, credentialKind: credential.kind, baseUrl: resolvedBaseUrl };
4085
4132
  }
@@ -4275,6 +4322,9 @@ function addPlatformOptions(command) {
4275
4322
  return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
4276
4323
  "--api-url <url>",
4277
4324
  "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
4325
+ ).option(
4326
+ "--api-header <header...>",
4327
+ 'Extra request header for a deployment behind an edge authenticator, as "Name: value" (repeatable; also MCPJAM_API_HEADERS, newline-separated)'
4278
4328
  );
4279
4329
  }
4280
4330
  function buildCloudClientContext(options, timeoutMs) {
@@ -5320,7 +5370,10 @@ async function listToolNames(client, projectId, server, signal) {
5320
5370
  {
5321
5371
  project: projectId,
5322
5372
  server: server.id,
5323
- ...cursor ? { cursor } : {}
5373
+ // Presence, not truthiness: MCP 2026-07-28
5374
+ // `server/utilities/pagination` makes `""` a valid cursor, and
5375
+ // dropping it here would silently re-read page one.
5376
+ ...cursor !== void 0 ? { cursor } : {}
5324
5377
  },
5325
5378
  { client, signal }
5326
5379
  );
@@ -5328,8 +5381,9 @@ async function listToolNames(client, projectId, server, signal) {
5328
5381
  const name = tool.name;
5329
5382
  if (typeof name === "string" && name.length > 0) names.add(name);
5330
5383
  }
5331
- if (!result.nextCursor) return names;
5332
- cursor = result.nextCursor;
5384
+ const next = typeof result.nextCursor === "string" ? result.nextCursor : void 0;
5385
+ if (next === void 0) return names;
5386
+ cursor = next;
5333
5387
  }
5334
5388
  throw cliError(
5335
5389
  "TOOL_DISCOVERY_UNAVAILABLE",
@@ -7581,7 +7635,7 @@ function selectorField(singular, plural, values) {
7581
7635
  }
7582
7636
  function composeField(options) {
7583
7637
  const models = Array.isArray(options.composeModel) ? options.composeModel : options.composeModel ? [options.composeModel] : void 0;
7584
- const refinements = options.composeComputer !== void 0 || models !== void 0 || options.composeServerGroup !== void 0 || (options.composeSkill?.length ?? 0) > 0 || options.withClientDefault === true || options.saveTargets === true;
7638
+ const refinements = options.composeComputer !== void 0 || models !== void 0 || (options.composeServer?.length ?? 0) > 0 || options.composeServerGroup !== void 0 || options.composeHostServers === true || (options.composeSkill?.length ?? 0) > 0 || options.withClientDefault === true || options.saveTargets === true;
7585
7639
  if (!options.composeHost) {
7586
7640
  if (refinements) {
7587
7641
  throw usageError(
@@ -7590,10 +7644,28 @@ function composeField(options) {
7590
7644
  }
7591
7645
  return {};
7592
7646
  }
7647
+ if (options.composeServerGroup !== void 0 && options.composeServer?.length) {
7648
+ throw usageError(
7649
+ "--compose-server and --compose-server-group both pin the run's servers. Use --compose-server with server names, or --compose-server-group with an existing group ID."
7650
+ );
7651
+ }
7652
+ const pinsServers = options.composeServerGroup !== void 0 || (options.composeServer?.length ?? 0) > 0;
7653
+ if (options.composeHostServers === true && pinsServers) {
7654
+ throw usageError(
7655
+ "--compose-host-servers runs against the host's current list, so it cannot be combined with --compose-server / --compose-server-group, which pin one."
7656
+ );
7657
+ }
7658
+ if (!pinsServers && options.composeHostServers !== true) {
7659
+ throw usageError(
7660
+ "--compose-host needs to know which servers to test: add --compose-server <name>. To deliberately use whatever servers the host points at right now \u2014 which changes when the host is edited \u2014 pass --compose-host-servers."
7661
+ );
7662
+ }
7593
7663
  return {
7594
7664
  compose: {
7595
7665
  host: options.composeHost,
7596
7666
  ...options.composeServerGroup !== void 0 ? { serverGroup: options.composeServerGroup } : {},
7667
+ ...options.composeHostServers === true ? { hostServers: true } : {},
7668
+ ...selectorField("server", "servers", options.composeServer),
7597
7669
  ...models !== void 0 ? { models } : {},
7598
7670
  ...options.withClientDefault === true ? { includeClientDefault: true } : {},
7599
7671
  ...options.saveTargets === true ? { saveTargets: true } : {},
@@ -8646,7 +8718,8 @@ async function runEvalCompare(options, command) {
8646
8718
  report: outcome.report,
8647
8719
  reporter,
8648
8720
  out: options.out,
8649
- format: globalOptions.format
8721
+ format: globalOptions.format,
8722
+ ...outcome.decisionSummary ? { decisionSummary: outcome.decisionSummary } : {}
8650
8723
  },
8651
8724
  outcome.compare ? buildRunCompareReport(outcome.compare, outcome.report, {
8652
8725
  flakyCases: outcome.flakyCases,
@@ -8828,7 +8901,16 @@ async function writeCompareResult(args, structured) {
8828
8901
  return;
8829
8902
  }
8830
8903
  writeResult(
8831
- { compare: args.report, exitCode: evalGateExitCode(args.report) },
8904
+ {
8905
+ compare: args.report,
8906
+ exitCode: evalGateExitCode(args.report),
8907
+ // JSON ONLY. `writeResult` pretty-prints this same object in human
8908
+ // format, so including it there would put the raw wire enums on the
8909
+ // terminal immediately above the label-aware block that exists to
8910
+ // replace them — the narrative twice, once unreadably. `eval status`
8911
+ // strips it for exactly this reason.
8912
+ ...args.format === "json" && args.decisionSummary ? { decisionSummary: args.decisionSummary } : {}
8913
+ },
8832
8914
  args.format
8833
8915
  );
8834
8916
  }
@@ -9217,9 +9299,15 @@ function registerEvalCommands(program) {
9217
9299
  ).option(
9218
9300
  "--save-targets",
9219
9301
  "Attach the composed environments to the suite (append, capped at 10). Default is ephemeral."
9302
+ ).option(
9303
+ "--compose-server <id-or-name...>",
9304
+ "Server(s) to pin on the composed stack. Snapshots them into a server group, so the run keeps testing these servers even if the host's own server list changes later. Mutually exclusive with --compose-server-group."
9220
9305
  ).option(
9221
9306
  "--compose-server-group <id>",
9222
9307
  "Standalone server group to pin on the composed stack"
9308
+ ).option(
9309
+ "--compose-host-servers",
9310
+ "Run against whatever servers the host points at right now, instead of pinning a set. Editing that host later changes what a rerun tests."
9223
9311
  ).option(
9224
9312
  "--compose-skill <id...>",
9225
9313
  "Project-shared skill IDs to pin on the composed stack"
@@ -9422,7 +9510,7 @@ function registerEvalCommands(program) {
9422
9510
  ] : []
9423
9511
  );
9424
9512
  if (!needsReport) {
9425
- const soloSummary = globalOptions.format === "human" && result.targets.length === 1 && runs.length === 1 && TERMINAL_RUN_STATUSES.has(runs[0].status) ? await readEvalRunDecisionSummary(
9513
+ const soloSummary = result.targets.length === 1 && runs.length === 1 && TERMINAL_RUN_STATUSES.has(runs[0].status) ? await readEvalRunDecisionSummary(
9426
9514
  client,
9427
9515
  signal,
9428
9516
  result.project.id,
@@ -9539,7 +9627,20 @@ function registerEvalCommands(program) {
9539
9627
  writeReporterResult(reporter, report);
9540
9628
  } else {
9541
9629
  writeResult(
9542
- { launch: result, runs: completion.runs },
9630
+ {
9631
+ launch: result,
9632
+ runs: completion.runs,
9633
+ // ONE DOCUMENT, and the decision belongs in it. `--format json` is
9634
+ // the stable contract and the human block below is not, so a
9635
+ // pipeline that reads stdout used to get run ids and a status and
9636
+ // had to make a second call to learn what the run decided.
9637
+ //
9638
+ // JSON ONLY, though: `writeResult` pretty-prints this same object
9639
+ // in human format, so leaving it ungated would print the raw wire
9640
+ // enums directly above the label-aware block written to replace
9641
+ // them. `eval status` strips it for the same reason.
9642
+ ...globalOptions.format === "json" && completion.decisionSummary ? { decisionSummary: completion.decisionSummary } : {}
9643
+ },
9543
9644
  globalOptions.format
9544
9645
  );
9545
9646
  writeRunGroupSummary(globalOptions.format, webOrigin, result);
@@ -9577,24 +9678,45 @@ function registerEvalCommands(program) {
9577
9678
  );
9578
9679
  addProjectOption(
9579
9680
  evals.command("status").description("Get the status and summary of an eval run").requiredOption("--run <id>", "Eval run ID (from `eval run`)")
9681
+ ).option(
9682
+ "--diagnostics-limit <n>",
9683
+ "Failure diagnostics per page (1\u2013200; default 20)"
9684
+ ).option(
9685
+ "--diagnostics-cursor <cursor>",
9686
+ "Cursor from a previous response's decisionSummary.diagnostics.nextCursor"
9687
+ ).option(
9688
+ "--stages",
9689
+ "Print all six user-value chain rows for each failing trial (human output)"
9580
9690
  ).action(
9581
9691
  async (options, command) => {
9582
9692
  const globalOptions = getGlobalOptions(command);
9583
9693
  let webOrigin = DEFAULT_PLATFORM_ORIGIN;
9584
9694
  let decisionSummary;
9585
9695
  const resolved = resolveCloudProjectArgs(options);
9696
+ const input = validateOpInput(
9697
+ getEvalRunOperation,
9698
+ {
9699
+ runId: options.run,
9700
+ ...resolved.project === void 0 ? {} : { project: resolved.project },
9701
+ ...options.diagnosticsLimit !== void 0 ? {
9702
+ diagnosticsLimit: parsePositiveInteger(
9703
+ options.diagnosticsLimit,
9704
+ "--diagnostics-limit"
9705
+ )
9706
+ } : {},
9707
+ ...options.diagnosticsCursor !== void 0 ? { diagnosticsCursor: options.diagnosticsCursor } : {}
9708
+ },
9709
+ { projectOptional: true }
9710
+ );
9586
9711
  const result = await runPlatformOperation(
9587
9712
  platformOptionsOf(command),
9588
9713
  globalOptions.timeout,
9589
9714
  async (context) => {
9590
9715
  webOrigin = context.webOrigin;
9591
- const result2 = await getEvalRunOperation.execute(
9592
- {
9593
- runId: options.run,
9594
- ...resolved.project === void 0 ? {} : { project: resolved.project }
9595
- },
9596
- { client: context.client, signal: context.signal }
9597
- );
9716
+ const result2 = await getEvalRunOperation.execute(input, {
9717
+ client: context.client,
9718
+ signal: context.signal
9719
+ });
9598
9720
  if (globalOptions.format === "human" && TERMINAL_RUN_STATUSES.has(result2.run.status) && result2.run.result !== "passed") {
9599
9721
  decisionSummary = result2.decisionSummary;
9600
9722
  }
@@ -9614,7 +9736,8 @@ function registerEvalCommands(program) {
9614
9736
  writeEvalDecisionSummary(
9615
9737
  globalOptions.format,
9616
9738
  decisionSummary,
9617
- process.stdout
9739
+ process.stdout,
9740
+ { stages: options.stages === true }
9618
9741
  );
9619
9742
  writeRunLink(globalOptions.format, webOrigin, {
9620
9743
  projectId: result.project.id,
@@ -9623,6 +9746,48 @@ function registerEvalCommands(program) {
9623
9746
  });
9624
9747
  }
9625
9748
  );
9749
+ addProjectOption(
9750
+ evals.command("stage-analytics").description(
9751
+ "Read the user-value chain funnel for one run (--run) or a suite's runs as a trend series (--suite)"
9752
+ )
9753
+ ).option("--run <id>", "Eval run ID \u2014 one run's funnel").option(
9754
+ "--suite <id-or-name>",
9755
+ "Eval suite name or ID \u2014 one page of runs, newest first"
9756
+ ).option(
9757
+ "--cursor <cursor>",
9758
+ "Pagination cursor from a previous response (--suite only)"
9759
+ ).option("--limit <n>", "Documents per page, 1-100 (--suite only)").action(
9760
+ async (options, command) => {
9761
+ if (options.run === void 0 === (options.suite === void 0)) {
9762
+ throw usageError(
9763
+ "Provide either --run <id> or --suite <id-or-name>, not both."
9764
+ );
9765
+ }
9766
+ const suiteMode = options.suite !== void 0;
9767
+ if (!suiteMode && (options.cursor !== void 0 || options.limit !== void 0)) {
9768
+ throw usageError("--cursor and --limit apply to --suite only.");
9769
+ }
9770
+ const operation = suiteMode ? listEvalSuiteStageAnalyticsOperation : getEvalRunStageAnalyticsOperation;
9771
+ const input = validateOpInput(
9772
+ operation,
9773
+ {
9774
+ ...options.project === void 0 ? {} : { project: options.project },
9775
+ ...suiteMode ? {
9776
+ suite: options.suite,
9777
+ ...options.cursor !== void 0 ? { cursor: options.cursor } : {},
9778
+ ...options.limit !== void 0 ? { limit: parsePositiveInteger(options.limit, "--limit") } : {}
9779
+ } : { runId: options.run }
9780
+ },
9781
+ { projectOptional: true }
9782
+ );
9783
+ await executeOp(
9784
+ operation,
9785
+ input,
9786
+ options,
9787
+ command
9788
+ );
9789
+ }
9790
+ );
9626
9791
  addProjectOption(
9627
9792
  evals.command("cancel").description(
9628
9793
  "Cancel an in-flight eval run (no-op if already cancelled; errors if it already finished)"
@@ -10256,9 +10421,15 @@ function registerEvalCommands(program) {
10256
10421
  ).option(
10257
10422
  "--compose-model <id>",
10258
10423
  "One model to run this case on. A matrix of models is suite-level (`eval run`) only."
10424
+ ).option(
10425
+ "--compose-server <id-or-name...>",
10426
+ "Server(s) to pin on the composed stack. Snapshots them into a server group, so the run keeps testing these servers even if the host's own server list changes later. Mutually exclusive with --compose-server-group."
10259
10427
  ).option(
10260
10428
  "--compose-server-group <id>",
10261
10429
  "Standalone server group to pin on the composed stack"
10430
+ ).option(
10431
+ "--compose-host-servers",
10432
+ "Run against whatever servers the host points at right now, instead of pinning a set. Editing that host later changes what a rerun tests."
10262
10433
  ).option(
10263
10434
  "--compose-skill <id...>",
10264
10435
  "Project-shared skill IDs to pin on the composed stack"
@@ -11522,6 +11693,8 @@ function registerProjectsCommands(program) {
11522
11693
  process.stderr.write(
11523
11694
  `Not waiting. Follow it with:
11524
11695
  mcpjam cloud projects servers connect-status --request ${created.connectionRequestId}
11696
+ Or stop it with:
11697
+ mcpjam cloud projects servers connect-cancel --request ${created.connectionRequestId}
11525
11698
  `
11526
11699
  );
11527
11700
  }
@@ -11540,6 +11713,7 @@ function registerProjectsCommands(program) {
11540
11713
  process.stderr.write(
11541
11714
  `Stopped waiting; the request is still ${latest.status} and continues in the cloud.
11542
11715
  mcpjam cloud projects servers connect-status --request ${created.connectionRequestId}
11716
+ mcpjam cloud projects servers connect-cancel --request ${created.connectionRequestId}
11543
11717
  `
11544
11718
  );
11545
11719
  process.exitCode = 1;
@@ -11564,6 +11738,24 @@ function registerProjectsCommands(program) {
11564
11738
  writeResult(payload, globalOptions.format);
11565
11739
  }
11566
11740
  );
11741
+ servers.command("connect-cancel").description("Cancel a pending connection request started by `server connect`").requiredOption("--request <id>", "Connection request id (scr_\u2026)").action(
11742
+ async (options, command) => {
11743
+ const globalOptions = getGlobalOptions(command);
11744
+ const input = cancelProjectServerConnectionOperation.inputSchema.parse({
11745
+ connectionRequestId: options.request
11746
+ });
11747
+ const payload = await runPlatformCommand(
11748
+ platformOptionsOf(command),
11749
+ globalOptions.timeout,
11750
+ ({ client, signal }) => cancelProjectServerConnectionOperation.execute(input, {
11751
+ client,
11752
+ signal
11753
+ }),
11754
+ { cloudScope: { kind: "account" }, quiet: globalOptions.quiet }
11755
+ );
11756
+ writeResult(payload, globalOptions.format);
11757
+ }
11758
+ );
11567
11759
  projects.command("status").description(
11568
11760
  "Health-check every server in a project (hosted doctor per server)"
11569
11761
  ).option(
@@ -11758,6 +11950,243 @@ function registerScenariosCommands(program) {
11758
11950
  }
11759
11951
  );
11760
11952
  }
11953
+ function resolveSecretValue(options, { required }) {
11954
+ const supplied = [
11955
+ options.value !== void 0 ? "--value" : null,
11956
+ options.valueFile !== void 0 ? "--value-file" : null,
11957
+ options.valueEnv !== void 0 ? "--value-env" : null
11958
+ ].filter((flag) => flag !== null);
11959
+ if (supplied.length > 1) {
11960
+ throw usageError(
11961
+ `Provide exactly one of --value, --value-file, or --value-env (got ${supplied.join(
11962
+ ", "
11963
+ )}).`
11964
+ );
11965
+ }
11966
+ if (supplied.length === 0) {
11967
+ if (!required) return void 0;
11968
+ throw usageError(
11969
+ "A value is required. Prefer --value-file <path>, --value-env <VAR>, or `--value -` to read stdin; --value <literal> works but is written to your shell history."
11970
+ );
11971
+ }
11972
+ if (options.valueEnv !== void 0) {
11973
+ const value = process.env[options.valueEnv];
11974
+ if (value === void 0 || value === "") {
11975
+ throw usageError(
11976
+ `Environment variable "${options.valueEnv}" is not set (or is empty).`
11977
+ );
11978
+ }
11979
+ return value;
11980
+ }
11981
+ const readStdinOrFile = (path9) => {
11982
+ try {
11983
+ return path9 === "-" ? readFileSync(0, "utf8") : readFileSync(path9, "utf8");
11984
+ } catch (error) {
11985
+ throw usageError(
11986
+ path9 === "-" ? "Failed to read the secret value from stdin." : `Failed to read the secret value from "${path9}".`,
11987
+ { source: error instanceof Error ? error.message : String(error) }
11988
+ );
11989
+ }
11990
+ };
11991
+ const stripOneTrailingNewline = (text) => text.replace(/\r?\n$/, "");
11992
+ if (options.valueFile !== void 0) {
11993
+ const raw = readStdinOrFile(options.valueFile);
11994
+ const text = options.valueFile === "-" ? stripOneTrailingNewline(raw) : raw;
11995
+ if (text === "") throw usageError("The secret value is empty.");
11996
+ return text;
11997
+ }
11998
+ if (options.value === "-") {
11999
+ const text = stripOneTrailingNewline(readStdinOrFile("-"));
12000
+ if (text === "") throw usageError("The secret value is empty.");
12001
+ return text;
12002
+ }
12003
+ if (options.value === "") throw usageError("The secret value is empty.");
12004
+ return options.value;
12005
+ }
12006
+ function brokerFields(options) {
12007
+ return {
12008
+ ...options.host !== void 0 && options.host.length > 0 ? { brokerHosts: options.host } : {},
12009
+ ...options.header !== void 0 ? { brokerHeader: options.header } : {},
12010
+ ...options.template !== void 0 ? { brokerTemplate: options.template } : {}
12011
+ };
12012
+ }
12013
+ function collectHost(value, previous = []) {
12014
+ return [...previous, value];
12015
+ }
12016
+ function registerSecretsCommands(program) {
12017
+ const secrets = program.command("secrets").description(
12018
+ "Store and manage the project credentials a workflow needs (stripe, gh, psql). Write-only: no command prints a value."
12019
+ );
12020
+ secrets.command("list").description(
12021
+ "List the project's secrets \u2014 metadata only. Shows the project-shared ones plus your own personal ones."
12022
+ ).option(
12023
+ "--project <id-or-name>",
12024
+ "Project name or ID (defaults to the most recently updated project)"
12025
+ ).action(
12026
+ async (options, command) => {
12027
+ const globalOptions = getGlobalOptions(command);
12028
+ const result = await runPlatformOperation(
12029
+ platformOptionsOf(command),
12030
+ globalOptions.timeout,
12031
+ ({ client, signal }) => listSecretsOperation.execute(
12032
+ { project: resolveCloudProjectArgs(options).project },
12033
+ { client, signal }
12034
+ )
12035
+ );
12036
+ writeResult(result, globalOptions.format);
12037
+ }
12038
+ );
12039
+ secrets.command("show").description(
12040
+ "Show one secret's metadata: delivery mode, host binding, sharing, last delivery. Never its value."
12041
+ ).requiredOption("--secret <id>", "Secret ID, from `cloud secrets list`").option("--project <id-or-name>", "Project name or ID").action(
12042
+ async (options, command) => {
12043
+ const globalOptions = getGlobalOptions(command);
12044
+ const result = await runPlatformOperation(
12045
+ platformOptionsOf(command),
12046
+ globalOptions.timeout,
12047
+ ({ client, signal }) => getSecretOperation.execute(
12048
+ {
12049
+ project: resolveCloudProjectArgs(options).project,
12050
+ secret: options.secret
12051
+ },
12052
+ { client, signal }
12053
+ )
12054
+ );
12055
+ writeResult(result, globalOptions.format);
12056
+ }
12057
+ );
12058
+ secrets.command("set").description(
12059
+ "Create a secret. The value comes from --value-file, --value-env, or stdin \u2014 never a positional argument."
12060
+ ).requiredOption(
12061
+ "--name <NAME>",
12062
+ "Environment-variable name (STRIPE_API_KEY). Uppercase, digits, underscores; not starting with a digit. Immutable."
12063
+ ).requiredOption(
12064
+ "--delivery <mode>",
12065
+ "brokered (the proxy injects it outside the sandbox \u2014 extraction-proof, not use-proof, HTTPS only) or materialized (a real env var inside the box, which is what a CLI can read, and which `env` prints)"
12066
+ ).option(
12067
+ "--value-file <path>",
12068
+ "Read the value from a file, VERBATIM \u2014 a trailing newline is kept, because in a PEM block it is part of the credential. `-` reads stdin instead, which drops one trailing newline. Preferred."
12069
+ ).option("--value-env <VAR>", "Read the value from an environment variable.").option(
12070
+ "--value <literal>",
12071
+ "The value inline, or `-` to read stdin. SCRIPTING ONLY: an inline literal is written to your shell history and is visible in `ps` while the command runs."
12072
+ ).option("--description <text>", "What this credential is for.").option(
12073
+ "--host <hostname>",
12074
+ "Brokered only, repeatable: an exact hostname the header is injected on (api.stripe.com). No scheme, no port, no wildcard.",
12075
+ collectHost
12076
+ ).option(
12077
+ "--header <name>",
12078
+ "Brokered only: the header name, e.g. Authorization."
12079
+ ).option(
12080
+ "--template <value>",
12081
+ 'Brokered only: the header value with {} where the secret goes, e.g. "Bearer {}".'
12082
+ ).option(
12083
+ "--sharing <scope>",
12084
+ "project (default; delivered to every member's sessions, admin-only) or user (personal; delivered only in sessions you start)"
12085
+ ).option(
12086
+ "--idempotency-key <key>",
12087
+ "Retry key. Pass one: a retried create without it fails as a name conflict with the row the first attempt already made."
12088
+ ).action(
12089
+ async (options, command) => {
12090
+ const globalOptions = getGlobalOptions(command);
12091
+ const value = resolveSecretValue(options, { required: true });
12092
+ const input = createSecretOperation.inputSchema.safeParse({
12093
+ project: resolveCloudProjectArgs(options).project,
12094
+ name: options.name,
12095
+ value,
12096
+ ...options.description !== void 0 ? { description: options.description } : {},
12097
+ delivery: options.delivery,
12098
+ ...brokerFields(options),
12099
+ ...options.sharing !== void 0 ? { sharing: options.sharing } : {},
12100
+ ...options.idempotencyKey !== void 0 ? { idempotencyKey: options.idempotencyKey } : {}
12101
+ });
12102
+ if (!input.success) {
12103
+ throw usageError(
12104
+ `Invalid input: ${input.error.issues.map(
12105
+ (issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`
12106
+ ).join("; ")}`
12107
+ );
12108
+ }
12109
+ const result = await runPlatformOperation(
12110
+ platformOptionsOf(command),
12111
+ globalOptions.timeout,
12112
+ ({ client, signal }) => createSecretOperation.execute(input.data, { client, signal })
12113
+ );
12114
+ writeResult(result, globalOptions.format);
12115
+ }
12116
+ );
12117
+ secrets.command("update").description(
12118
+ "Rotate a secret's value and/or change how it is delivered. A rotation reaches NEW RUNS ONLY \u2014 a session already running keeps the value it was given."
12119
+ ).requiredOption("--secret <id>", "Secret ID, from `cloud secrets list`").option("--project <id-or-name>", "Project name or ID").option(
12120
+ "--value-file <path>",
12121
+ "Read the new value from a file, VERBATIM \u2014 a trailing newline is kept. `-` reads stdin instead, which drops one trailing newline. Preferred."
12122
+ ).option(
12123
+ "--value-env <VAR>",
12124
+ "Read the new value from an environment variable."
12125
+ ).option(
12126
+ "--value <literal>",
12127
+ "The new value inline, or `-` to read stdin. SCRIPTING ONLY \u2014 see `secrets set`."
12128
+ ).option("--description <text>", "Replacement description.").option(
12129
+ "--clear-description",
12130
+ "Remove the description entirely, leaving the secret with none."
12131
+ ).option(
12132
+ "--delivery <mode>",
12133
+ "brokered or materialized. Switching to brokered needs --host/--header/--template in the same call; switching to materialized clears them."
12134
+ ).option("--host <hostname>", "Brokered only, repeatable.", collectHost).option("--header <name>", "Brokered only: the header name.").option("--template <value>", 'Brokered only: e.g. "Bearer {}".').action(
12135
+ async (options, command) => {
12136
+ const globalOptions = getGlobalOptions(command);
12137
+ if (options.description !== void 0 && options.clearDescription) {
12138
+ throw usageError(
12139
+ "Provide either --description or --clear-description, not both."
12140
+ );
12141
+ }
12142
+ const value = resolveSecretValue(options, { required: false });
12143
+ const input = updateSecretOperation.inputSchema.safeParse({
12144
+ project: resolveCloudProjectArgs(options).project,
12145
+ secret: options.secret,
12146
+ ...value !== void 0 ? { value } : {},
12147
+ // `--clear-description` is the flag spelling of the `null` the REST
12148
+ // route and the SDK client already accept. Distinct from
12149
+ // `--description ""`, which SETS an empty description.
12150
+ ...options.clearDescription ? { description: null } : {},
12151
+ ...options.description !== void 0 ? { description: options.description } : {},
12152
+ ...options.delivery !== void 0 ? { delivery: options.delivery } : {},
12153
+ ...brokerFields(options)
12154
+ });
12155
+ if (!input.success) {
12156
+ throw usageError(
12157
+ `Invalid input: ${input.error.issues.map(
12158
+ (issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`
12159
+ ).join("; ")}`
12160
+ );
12161
+ }
12162
+ const result = await runPlatformOperation(
12163
+ platformOptionsOf(command),
12164
+ globalOptions.timeout,
12165
+ ({ client, signal }) => updateSecretOperation.execute(input.data, { client, signal })
12166
+ );
12167
+ writeResult(result, globalOptions.format);
12168
+ }
12169
+ );
12170
+ secrets.command("rm").description(
12171
+ "Delete a secret. HARD: the row and the encrypted value both go, and MCPJam stops delivering it. Not blocked when an environment still selects it \u2014 deletion never waits on cleanup. This does NOT revoke the credential at the provider that issued it, and runs already in flight keep the value they were handed."
12172
+ ).requiredOption("--secret <id>", "Secret ID, from `cloud secrets list`").option("--project <id-or-name>", "Project name or ID").action(
12173
+ async (options, command) => {
12174
+ const globalOptions = getGlobalOptions(command);
12175
+ const result = await runPlatformOperation(
12176
+ platformOptionsOf(command),
12177
+ globalOptions.timeout,
12178
+ ({ client, signal }) => deleteSecretOperation.execute(
12179
+ {
12180
+ project: resolveCloudProjectArgs(options).project,
12181
+ secret: options.secret
12182
+ },
12183
+ { client, signal }
12184
+ )
12185
+ );
12186
+ writeResult(result, globalOptions.format);
12187
+ }
12188
+ );
12189
+ }
11761
12190
  function requireQuery(value) {
11762
12191
  const trimmed2 = value?.trim() ?? "";
11763
12192
  if (trimmed2.length === 0) {
@@ -13837,6 +14266,7 @@ function registerCloudCommands(program) {
13837
14266
  registerEvalCommands(cloud);
13838
14267
  registerClientsCommands(cloud);
13839
14268
  registerEnvironmentsCommands(cloud);
14269
+ registerSecretsCommands(cloud);
13840
14270
  registerImagesCommands(cloud);
13841
14271
  registerSkillsCommands(cloud);
13842
14272
  cloud.commandsGroup("Swarms and user testing:");
@@ -13906,12 +14336,12 @@ function applyHostVisibility(tools, manager, serverId, policy) {
13906
14336
  var TOOLS_PAGE_CAP = 50;
13907
14337
  async function assertToolVisibleToHost(manager, serverId, toolName, host) {
13908
14338
  if (host.policy.respectToolVisibility === false) return;
13909
- const seenCursors = /* @__PURE__ */ new Set();
13910
14339
  let cursor;
13911
14340
  for (let page = 0; page < TOOLS_PAGE_CAP; page++) {
13912
14341
  const result = await manager.listTools(
13913
14342
  serverId,
13914
- cursor ? { cursor } : void 0
14343
+ // Presence, not truthiness: `""` is a valid continuation cursor.
14344
+ cursor !== void 0 ? { cursor } : void 0
13915
14345
  );
13916
14346
  const tool = (result.tools ?? []).find(
13917
14347
  (t) => t.name === toolName
@@ -13925,9 +14355,7 @@ async function assertToolVisibleToHost(manager, serverId, toolName, host) {
13925
14355
  return;
13926
14356
  }
13927
14357
  cursor = result.nextCursor;
13928
- if (!cursor) return;
13929
- if (seenCursors.has(cursor)) break;
13930
- seenCursors.add(cursor);
14358
+ if (cursor === void 0) return;
13931
14359
  }
13932
14360
  throw usageError(
13933
14361
  `Could not verify "${toolName}" is visible to host "${host.id}" \u2014 the server's tool list is too long to page through. Omit --host to call it as an operator.`
@@ -14553,8 +14981,8 @@ function registerCompatCommands(program) {
14553
14981
  tools.push(
14554
14982
  ...result2.tools
14555
14983
  );
14556
- cursor = result2.nextCursor;
14557
- if (!cursor) break;
14984
+ cursor = typeof result2.nextCursor === "string" ? result2.nextCursor : void 0;
14985
+ if (cursor === void 0) break;
14558
14986
  if (page === TOOLS_PAGE_CAP2 - 1) truncated = true;
14559
14987
  }
14560
14988
  const toolsData = { tools };
@@ -14941,7 +15369,8 @@ function extractHeaders(headers) {
14941
15369
  async function listToolsWithMetadata(manager, params) {
14942
15370
  const result = await manager.listTools(
14943
15371
  params.serverId,
14944
- params.cursor ? { cursor: params.cursor } : void 0
15372
+ // Presence, not truthiness: `""` is a valid continuation cursor.
15373
+ params.cursor !== void 0 ? { cursor: params.cursor } : void 0
14945
15374
  );
14946
15375
  const tools = result.tools ?? [];
14947
15376
  const toolsMetadata = manager.getAllToolsMetadata(params.serverId);
@@ -15339,7 +15768,7 @@ function createMcpJamMcpServer(options) {
15339
15768
  },
15340
15769
  async ({ server: name, cursor, templates }) => runTool(async () => {
15341
15770
  requireConnected(name);
15342
- const params = cursor ? { cursor } : void 0;
15771
+ const params = cursor !== void 0 ? { cursor } : void 0;
15343
15772
  return templates ? manager.listResourceTemplates(name, params) : manager.listResources(name, params);
15344
15773
  })
15345
15774
  );
@@ -15444,7 +15873,10 @@ function createMcpJamMcpServer(options) {
15444
15873
  },
15445
15874
  async ({ server: name, cursor }) => runTool(async () => {
15446
15875
  requireConnected(name);
15447
- return manager.listPrompts(name, cursor ? { cursor } : void 0);
15876
+ return manager.listPrompts(
15877
+ name,
15878
+ cursor !== void 0 ? { cursor } : void 0
15879
+ );
15448
15880
  })
15449
15881
  );
15450
15882
  server.registerTool(
@@ -17505,7 +17937,8 @@ function registerResourcesCommands(program) {
17505
17937
  config,
17506
17938
  (manager, serverId) => manager.listResourceTemplates(
17507
17939
  serverId,
17508
- options.cursor ? { cursor: options.cursor } : void 0
17940
+ // Presence, not truthiness: `""` is a valid continuation cursor.
17941
+ options.cursor !== void 0 ? { cursor: options.cursor } : void 0
17509
17942
  ),
17510
17943
  {
17511
17944
  timeout: globalOptions.timeout,