@mcpjam/cli 3.20.1 → 3.22.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, redactForTelemetry, 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';
5
+ import { probeMcpServer, redactForTelemetry, 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, openUrlInBrowser, 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, 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 { createProjectOperation, updateProjectOperation, deleteProjectOperation, listEvalSuiteRunsOperation, cancelEvalRunOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, listChatboxesOperation, getChatboxOperation, listChatSessionsOperation, createHostOperation, updateHostOperation, setHostServersOperation, duplicateHostOperation, createEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listProjectsOperation, listProjectServersOperation, createProjectServerOperation, getProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation, listEnvironmentsOperation, getEnvironmentOperation, resolveEnvironmentOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, publishScenarioOperation, unpublishScenarioOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation } from '@mcpjam/sdk/platform';
12
+ import { createProjectOperation, updateProjectOperation, deleteProjectOperation, connectProjectServerOperation, getProjectServerConnectionStatusOperation, listEvalSuiteRunsOperation, cancelEvalRunOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, listChatboxesOperation, getChatboxOperation, listChatSessionsOperation, createHostOperation, updateHostOperation, setHostServersOperation, duplicateHostOperation, createEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listOrganizationsOperation, listProjectsOperation, listProjectServersOperation, createProjectServerOperation, getProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation, listEnvironmentsOperation, getEnvironmentOperation, resolveEnvironmentOperation, getEnvironmentCapabilitiesOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, publishScenarioOperation, unpublishScenarioOperation, 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,7 @@ import { WebSocket } from 'ws';
25
25
 
26
26
  // package.json
27
27
  var package_default = {
28
- version: "3.20.1"};
28
+ version: "3.22.0"};
29
29
  function conformanceExitCode(result) {
30
30
  if (result.outcome === "incomplete") return 3;
31
31
  if (result.outcome === "failed") return 1;
@@ -4641,6 +4641,27 @@ function validateInput2(op, raw) {
4641
4641
  }
4642
4642
  return parsed.data;
4643
4643
  }
4644
+ async function assertModelOverridesSupported(options, timeoutMs, args) {
4645
+ if (!args.supplied) return;
4646
+ const result = await runPlatformCommand3(
4647
+ options,
4648
+ timeoutMs,
4649
+ ({ client, signal }) => getEnvironmentCapabilitiesOperation.execute(
4650
+ { project: args.project },
4651
+ { client, signal }
4652
+ )
4653
+ );
4654
+ const supported = result.capabilities.modelOverrides;
4655
+ if (!supported) {
4656
+ throw usageError(
4657
+ 'This MCPJam deployment does not support environment model overrides. Upgrade the platform, or omit --model / --clear-model / "modelId".'
4658
+ );
4659
+ }
4660
+ }
4661
+ function projectSelector(options, body) {
4662
+ if (options.project !== void 0) return { project: options.project };
4663
+ return typeof body.project === "string" && body.project.trim() ? { project: body.project } : {};
4664
+ }
4644
4665
  function loadJsonObject(options) {
4645
4666
  if (options.file !== void 0 && options.json !== void 0) {
4646
4667
  throw usageError("Provide either --file or --json, not both.");
@@ -4751,22 +4772,30 @@ function registerEnvironmentsCommands(program) {
4751
4772
  environments.command("create").description(
4752
4773
  "Create a project environment (requires project admin). Body fields may be supplied via --file/--json"
4753
4774
  ).option("--project <id-or-name>", "Project name or ID").option("--name <name>", "Display name for the new environment").option("--host-id <id>", "ID of the host this environment runs against").option("--description <text>", "Optional description").option(
4775
+ "--model <id>",
4776
+ "Model this environment runs, overriding the model pinned on its host. Omit to inherit the host's. Stored verbatim \u2014 pass exactly the id the provider request should carry"
4777
+ ).option(
4754
4778
  "--sandbox-image <id>",
4755
4779
  "Project-shared sandbox image (see `mcpjam images`) to pin: eval runs boot a fresh sandbox from it"
4756
4780
  ).option(
4757
4781
  "--file <path>",
4758
- "Environment JSON file with any of name/hostId/description/serverAttachmentId/skillSelection/pluginVersionIds/sandboxImageId (or - for stdin)"
4782
+ "Environment JSON file with any of name/hostId/description/serverAttachmentId/modelId/skillSelection/pluginVersionIds/sandboxImageId (or - for stdin)"
4759
4783
  ).option("--json <json>", "Inline environment JSON (or @file, or -)")
4760
4784
  ).action(
4761
4785
  async (options, command) => {
4762
4786
  const globalOptions = getGlobalOptions(command);
4763
4787
  const body = loadJsonObject(options) ?? {};
4788
+ await assertModelOverridesSupported(options, globalOptions.timeout, {
4789
+ supplied: options.model !== void 0 || "modelId" in body,
4790
+ ...projectSelector(options, body)
4791
+ });
4764
4792
  const input = validateInput2(createEnvironmentOperation, {
4765
4793
  ...body,
4766
4794
  ...options.project !== void 0 ? { project: options.project } : {},
4767
4795
  ...options.name !== void 0 ? { name: options.name } : {},
4768
4796
  ...options.hostId !== void 0 ? { hostId: options.hostId } : {},
4769
4797
  ...options.description !== void 0 ? { description: options.description } : {},
4798
+ ...options.model !== void 0 ? { modelId: options.model } : {},
4770
4799
  ...options.sandboxImage !== void 0 ? { sandboxImageId: options.sandboxImage } : {}
4771
4800
  });
4772
4801
  const result = await runPlatformCommand3(
@@ -4779,13 +4808,19 @@ function registerEnvironmentsCommands(program) {
4779
4808
  );
4780
4809
  addPlatformOptions3(
4781
4810
  environments.command("update").description(
4782
- "Edit an environment. Only the fields you pass change; use --file/--json with a null value to clear serverAttachmentId, skillSelection, pluginVersionIds, or sandboxImageId"
4811
+ "Edit an environment. Only the fields you pass change; use --clear-model, or --file/--json with a null value, to clear serverAttachmentId, modelId, skillSelection, pluginVersionIds, or sandboxImageId"
4783
4812
  ).requiredOption("--environment <id-or-name>", "Environment name or ID").requiredOption(
4784
4813
  "--expected-revision <n>",
4785
4814
  "The revision you last read (from `environments get`); a stale value is rejected instead of overwriting a concurrent edit"
4786
4815
  ).option("--project <id-or-name>", "Project name or ID").option("--name <name>", "New display name").option("--host-id <id>", "New host for this environment").option(
4787
4816
  "--description <text>",
4788
4817
  "New description (empty string clears it)"
4818
+ ).option(
4819
+ "--model <id>",
4820
+ "New model override, replacing the host's pinned model"
4821
+ ).option(
4822
+ "--clear-model",
4823
+ "Clear the model override so the environment inherits its host's model again"
4789
4824
  ).option(
4790
4825
  "--sandbox-image <id>",
4791
4826
  `New sandbox-image pin (clear via --json '{"sandboxImageId": null}')`
@@ -4797,6 +4832,13 @@ function registerEnvironmentsCommands(program) {
4797
4832
  async (options, command) => {
4798
4833
  const globalOptions = getGlobalOptions(command);
4799
4834
  const body = loadJsonObject(options) ?? {};
4835
+ if (options.model !== void 0 && options.clearModel) {
4836
+ throw usageError("Provide either --model or --clear-model, not both.");
4837
+ }
4838
+ await assertModelOverridesSupported(options, globalOptions.timeout, {
4839
+ supplied: options.model !== void 0 || options.clearModel === true || "modelId" in body,
4840
+ ...projectSelector(options, body)
4841
+ });
4800
4842
  const input = validateInput2(updateEnvironmentOperation, {
4801
4843
  ...body,
4802
4844
  ...options.project !== void 0 ? { project: options.project } : {},
@@ -4805,6 +4847,10 @@ function registerEnvironmentsCommands(program) {
4805
4847
  ...options.name !== void 0 ? { name: options.name } : {},
4806
4848
  ...options.hostId !== void 0 ? { hostId: options.hostId } : {},
4807
4849
  ...options.description !== void 0 ? { description: options.description } : {},
4850
+ // `--clear-model` is the flag spelling of the JSON `"modelId": null`
4851
+ // both this command and the API already accept; neither is removed.
4852
+ ...options.clearModel ? { modelId: null } : {},
4853
+ ...options.model !== void 0 ? { modelId: options.model } : {},
4808
4854
  ...options.sandboxImage !== void 0 ? { sandboxImageId: options.sandboxImage } : {}
4809
4855
  });
4810
4856
  const result = await runPlatformCommand3(
@@ -6994,6 +7040,22 @@ function table(rows) {
6994
7040
  ).join(" ").trimEnd()
6995
7041
  );
6996
7042
  }
7043
+ function formatOrganizationsHuman(organizations) {
7044
+ if (organizations.length === 0) {
7045
+ return "No accessible organizations.";
7046
+ }
7047
+ const lines = table([
7048
+ ["ID", "NAME", "PLAN", "ROLE"],
7049
+ ...organizations.map((organization) => [
7050
+ organization.id,
7051
+ organization.name,
7052
+ organization.plan ?? "-",
7053
+ organization.myRole ?? "-"
7054
+ ])
7055
+ ]);
7056
+ lines.push("", `${organizations.length} organization(s).`);
7057
+ return lines.join("\n");
7058
+ }
6997
7059
  function formatProjectsHuman(projects) {
6998
7060
  if (projects.length === 0) {
6999
7061
  return "No accessible projects.";
@@ -7086,7 +7148,7 @@ function statusGlyph(status) {
7086
7148
  }
7087
7149
  }
7088
7150
 
7089
- // src/commands/projects.ts
7151
+ // src/commands/organizations.ts
7090
7152
  function addPlatformOptions8(command) {
7091
7153
  return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
7092
7154
  "--api-url <url>",
@@ -7094,6 +7156,78 @@ function addPlatformOptions8(command) {
7094
7156
  );
7095
7157
  }
7096
7158
  async function runPlatformCommand8(options, timeoutMs, execute) {
7159
+ const controller = new AbortController();
7160
+ const timeoutHandle = setTimeout(() => {
7161
+ controller.abort(
7162
+ new PlatformApiError(`Request timed out after ${timeoutMs}ms`, "TIMEOUT", {
7163
+ status: 0
7164
+ })
7165
+ );
7166
+ }, timeoutMs);
7167
+ timeoutHandle.unref?.();
7168
+ try {
7169
+ const { client } = buildPlatformClient({ ...options, timeoutMs });
7170
+ return await execute({ client, signal: controller.signal });
7171
+ } catch (error) {
7172
+ if (controller.signal.aborted && controller.signal.reason instanceof PlatformApiError) {
7173
+ throw toCliError(controller.signal.reason);
7174
+ }
7175
+ throw toCliError(error);
7176
+ } finally {
7177
+ clearTimeout(timeoutHandle);
7178
+ }
7179
+ }
7180
+ function registerOrganizationsCommands(program) {
7181
+ const organizations = program.command("organizations").alias("orgs").description("Inspect the MCPJam organizations you belong to");
7182
+ addPlatformOptions8(
7183
+ organizations.command("list").description(
7184
+ "List your organizations and their ids (an sk_ key sees only its own)"
7185
+ )
7186
+ // `--api-key` / `--api-url` are declared only here, not on the group, so
7187
+ // Commander hands them to this action directly — no `optsWithGlobals`
7188
+ // merge dance like `projects`, whose `servers` group duplicates them.
7189
+ ).action(async (options, command) => {
7190
+ const globalOptions = getGlobalOptions(command);
7191
+ const result = await runPlatformCommand8(
7192
+ options,
7193
+ globalOptions.timeout,
7194
+ ({ client, signal }) => listOrganizationsOperation.execute({}, { client, signal })
7195
+ );
7196
+ if (globalOptions.format === "human") {
7197
+ process.stdout.write(`${formatOrganizationsHuman(result.items)}
7198
+ `);
7199
+ } else {
7200
+ writeResult(result, globalOptions.format);
7201
+ }
7202
+ });
7203
+ }
7204
+ function addPlatformOptions9(command) {
7205
+ return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
7206
+ "--api-url <url>",
7207
+ "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
7208
+ );
7209
+ }
7210
+ function platformOptionsOf(command) {
7211
+ const nearestFirst = [];
7212
+ for (let current = command; current !== null; current = current.parent) {
7213
+ nearestFirst.push(current);
7214
+ }
7215
+ const merged = {};
7216
+ for (const cmd of nearestFirst.reverse()) {
7217
+ for (const [key, value] of Object.entries(cmd.opts())) {
7218
+ if (value !== void 0) merged[key] = value;
7219
+ }
7220
+ }
7221
+ return merged;
7222
+ }
7223
+ function requireProject(command, options) {
7224
+ const project = options.project?.trim();
7225
+ if (!project) {
7226
+ command.error("error: required option '--project <id-or-name>' not specified");
7227
+ }
7228
+ return project;
7229
+ }
7230
+ async function runPlatformCommand9(options, timeoutMs, execute, externalSignal) {
7097
7231
  const controller = new AbortController();
7098
7232
  const timeoutHandle = setTimeout(() => {
7099
7233
  controller.abort(
@@ -7107,6 +7241,9 @@ async function runPlatformCommand8(options, timeoutMs, execute) {
7107
7241
  );
7108
7242
  }, timeoutMs);
7109
7243
  timeoutHandle.unref?.();
7244
+ const onExternalAbort = () => controller.abort(externalSignal?.reason);
7245
+ if (externalSignal?.aborted) onExternalAbort();
7246
+ else externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
7110
7247
  try {
7111
7248
  const { client } = buildPlatformClient({ ...options, timeoutMs });
7112
7249
  return await execute({ client, signal: controller.signal });
@@ -7117,20 +7254,34 @@ async function runPlatformCommand8(options, timeoutMs, execute) {
7117
7254
  throw toCliError(error);
7118
7255
  } finally {
7119
7256
  clearTimeout(timeoutHandle);
7257
+ externalSignal?.removeEventListener("abort", onExternalAbort);
7120
7258
  }
7121
7259
  }
7122
7260
  function registerProjectsCommands(program) {
7123
7261
  const projects = program.command("projects").description(
7124
7262
  "Operate the MCP servers saved in your hosted MCPJam projects"
7125
7263
  );
7126
- addPlatformOptions8(
7127
- projects.command("list").description("List the projects you can access")
7128
- ).action(async (options, command) => {
7264
+ addPlatformOptions9(
7265
+ projects.command("list").description("List the projects you can access").option(
7266
+ "--organization-id <id>",
7267
+ "Restrict the listing to one organization (see `mcpjam organizations list`)"
7268
+ )
7269
+ ).action(async (_options, command) => {
7129
7270
  const globalOptions = getGlobalOptions(command);
7130
- const result = await runPlatformCommand8(
7131
- options,
7271
+ const rawOrganization = command.opts().organizationId;
7272
+ if (rawOrganization !== void 0 && rawOrganization.trim() === "") {
7273
+ command.error(
7274
+ "error: option '--organization-id <id>' cannot be empty"
7275
+ );
7276
+ }
7277
+ const organizationId = rawOrganization?.trim();
7278
+ const result = await runPlatformCommand9(
7279
+ platformOptionsOf(command),
7132
7280
  globalOptions.timeout,
7133
- ({ client, signal }) => listProjectsOperation.execute({}, { client, signal })
7281
+ ({ client, signal }) => listProjectsOperation.execute(
7282
+ organizationId ? { organizationId } : {},
7283
+ { client, signal }
7284
+ )
7134
7285
  );
7135
7286
  if (globalOptions.format === "human") {
7136
7287
  process.stdout.write(`${formatProjectsHuman(result.items)}
@@ -7139,7 +7290,7 @@ function registerProjectsCommands(program) {
7139
7290
  writeResult(result, globalOptions.format);
7140
7291
  }
7141
7292
  });
7142
- addPlatformOptions8(
7293
+ addPlatformOptions9(
7143
7294
  projects.command("create").description("Create a hosted MCPJam project").requiredOption("--name <name>", "Project name").option("--description <text>", "Project description").option("--organization-id <id>", "Organization ID").option("--visibility <visibility>", "public or private")
7144
7295
  ).action(
7145
7296
  async (options, command) => {
@@ -7150,60 +7301,63 @@ function registerProjectsCommands(program) {
7150
7301
  ...options.organizationId === void 0 ? {} : { organizationId: options.organizationId },
7151
7302
  ...options.visibility === void 0 ? {} : { visibility: options.visibility }
7152
7303
  });
7153
- const result = await runPlatformCommand8(
7154
- options,
7304
+ const result = await runPlatformCommand9(
7305
+ platformOptionsOf(command),
7155
7306
  globalOptions.timeout,
7156
7307
  ({ client, signal }) => createProjectOperation.execute(input, { client, signal })
7157
7308
  );
7158
7309
  writeResult(result, globalOptions.format);
7159
7310
  }
7160
7311
  );
7161
- addPlatformOptions8(
7312
+ addPlatformOptions9(
7162
7313
  projects.command("update").description("Update project metadata").requiredOption("--project <id-or-name>", "Project name or ID").option("--name <name>", "New project name").option("--description <text>", "New project description").option("--visibility <visibility>", "public or private")
7163
7314
  ).action(
7164
7315
  async (options, command) => {
7165
7316
  const globalOptions = getGlobalOptions(command);
7317
+ const platformOptions = platformOptionsOf(command);
7166
7318
  const input = updateProjectOperation.inputSchema.parse({
7167
- project: options.project,
7319
+ project: requireProject(command, platformOptions),
7168
7320
  ...options.name === void 0 ? {} : { name: options.name },
7169
7321
  ...options.description === void 0 ? {} : { description: options.description },
7170
7322
  ...options.visibility === void 0 ? {} : { visibility: options.visibility }
7171
7323
  });
7172
- const result = await runPlatformCommand8(
7173
- options,
7324
+ const result = await runPlatformCommand9(
7325
+ platformOptions,
7174
7326
  globalOptions.timeout,
7175
7327
  ({ client, signal }) => updateProjectOperation.execute(input, { client, signal })
7176
7328
  );
7177
7329
  writeResult(result, globalOptions.format);
7178
7330
  }
7179
7331
  );
7180
- addPlatformOptions8(
7332
+ addPlatformOptions9(
7181
7333
  projects.command("delete").description("Delete a project and its project-owned resources").requiredOption("--project <id-or-name>", "Project name or ID")
7182
- ).action(async (options, command) => {
7334
+ ).action(async (_options, command) => {
7183
7335
  const globalOptions = getGlobalOptions(command);
7336
+ const platformOptions = platformOptionsOf(command);
7184
7337
  const input = deleteProjectOperation.inputSchema.parse({
7185
- project: options.project
7338
+ project: requireProject(command, platformOptions)
7186
7339
  });
7187
- const result = await runPlatformCommand8(
7188
- options,
7340
+ const result = await runPlatformCommand9(
7341
+ platformOptions,
7189
7342
  globalOptions.timeout,
7190
7343
  ({ client, signal }) => deleteProjectOperation.execute(input, { client, signal })
7191
7344
  );
7192
7345
  writeResult(result, globalOptions.format);
7193
7346
  });
7194
- const servers = addPlatformOptions8(
7347
+ const servers = addPlatformOptions9(
7195
7348
  projects.command("servers").alias("server").description("List and manage the servers saved in a project")
7196
7349
  ).option(
7197
7350
  "--project <id-or-name>",
7198
7351
  "Project name or ID (defaults to the most recently updated project)"
7199
7352
  );
7200
- servers.action(async (options, command) => {
7353
+ servers.action(async (_options, command) => {
7201
7354
  const globalOptions = getGlobalOptions(command);
7202
- const result = await runPlatformCommand8(
7203
- options,
7355
+ const platformOptions = platformOptionsOf(command);
7356
+ const result = await runPlatformCommand9(
7357
+ platformOptions,
7204
7358
  globalOptions.timeout,
7205
7359
  ({ client, signal }) => listProjectServersOperation.execute(
7206
- { project: options.project },
7360
+ { project: platformOptions.project },
7207
7361
  { client, signal }
7208
7362
  )
7209
7363
  );
@@ -7221,45 +7375,51 @@ function registerProjectsCommands(program) {
7221
7375
  }
7222
7376
  return parsed;
7223
7377
  };
7224
- addPlatformOptions8(
7225
- servers.command("create").alias("add").description("Create a saved MCP server").requiredOption("--project <id-or-name>", "Project name or ID").requiredOption("--body <json>", "Server JSON body")
7378
+ addPlatformOptions9(
7379
+ servers.command("create").alias("add").description("Create a saved MCP server").option("--project <id-or-name>", "Project name or ID").requiredOption("--body <json>", "Server JSON body")
7226
7380
  ).action(async (options, command) => {
7227
7381
  const globalOptions = getGlobalOptions(command);
7228
- const result = await runPlatformCommand8(
7229
- options,
7382
+ const platformOptions = platformOptionsOf(command);
7383
+ const project = requireProject(command, platformOptions);
7384
+ const result = await runPlatformCommand9(
7385
+ platformOptions,
7230
7386
  globalOptions.timeout,
7231
7387
  ({ client, signal }) => createProjectServerOperation.execute(
7232
- { project: options.project, body: parseBody(options.body) },
7388
+ { project, body: parseBody(options.body) },
7233
7389
  { client, signal }
7234
7390
  )
7235
7391
  );
7236
7392
  writeResult(result, globalOptions.format);
7237
7393
  });
7238
- addPlatformOptions8(
7239
- servers.command("get").description("Get one saved MCP server").requiredOption("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID")
7394
+ addPlatformOptions9(
7395
+ servers.command("get").description("Get one saved MCP server").option("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID")
7240
7396
  ).action(async (options, command) => {
7241
7397
  const globalOptions = getGlobalOptions(command);
7242
- const result = await runPlatformCommand8(
7243
- options,
7398
+ const platformOptions = platformOptionsOf(command);
7399
+ const project = requireProject(command, platformOptions);
7400
+ const result = await runPlatformCommand9(
7401
+ platformOptions,
7244
7402
  globalOptions.timeout,
7245
7403
  ({ client, signal }) => getProjectServerOperation.execute(
7246
- { project: options.project, serverId: options.server },
7404
+ { project, serverId: options.server },
7247
7405
  { client, signal }
7248
7406
  )
7249
7407
  );
7250
7408
  writeResult(result, globalOptions.format);
7251
7409
  });
7252
- addPlatformOptions8(
7253
- servers.command("update").description("Update one saved MCP server").requiredOption("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID").requiredOption("--body <json>", "Patch JSON body")
7410
+ addPlatformOptions9(
7411
+ servers.command("update").description("Update one saved MCP server").option("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID").requiredOption("--body <json>", "Patch JSON body")
7254
7412
  ).action(
7255
7413
  async (options, command) => {
7256
7414
  const globalOptions = getGlobalOptions(command);
7257
- const result = await runPlatformCommand8(
7258
- options,
7415
+ const platformOptions = platformOptionsOf(command);
7416
+ const project = requireProject(command, platformOptions);
7417
+ const result = await runPlatformCommand9(
7418
+ platformOptions,
7259
7419
  globalOptions.timeout,
7260
7420
  ({ client, signal }) => updateProjectServerOperation.execute(
7261
7421
  {
7262
- project: options.project,
7422
+ project,
7263
7423
  serverId: options.server,
7264
7424
  body: parseBody(options.body)
7265
7425
  },
@@ -7269,34 +7429,126 @@ function registerProjectsCommands(program) {
7269
7429
  writeResult(result, globalOptions.format);
7270
7430
  }
7271
7431
  );
7272
- addPlatformOptions8(
7273
- servers.command("delete").alias("remove").description("Delete one saved MCP server").requiredOption("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID")
7432
+ addPlatformOptions9(
7433
+ servers.command("delete").alias("remove").description("Delete one saved MCP server").option("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID")
7274
7434
  ).action(async (options, command) => {
7275
7435
  const globalOptions = getGlobalOptions(command);
7276
- const result = await runPlatformCommand8(
7277
- options,
7436
+ const platformOptions = platformOptionsOf(command);
7437
+ const project = requireProject(command, platformOptions);
7438
+ const result = await runPlatformCommand9(
7439
+ platformOptions,
7278
7440
  globalOptions.timeout,
7279
7441
  ({ client, signal }) => deleteProjectServerOperation.execute(
7280
- { project: options.project, serverId: options.server },
7442
+ { project, serverId: options.server },
7281
7443
  { client, signal }
7282
7444
  )
7283
7445
  );
7284
7446
  writeResult(result, globalOptions.format);
7285
7447
  });
7286
- addPlatformOptions8(
7448
+ addPlatformOptions9(
7449
+ servers.command("connect").description(
7450
+ "Connect an MCP server URL to a project, authorizing in a browser if needed"
7451
+ ).requiredOption("--url <url>", "MCP server URL to connect").option("--project <id-or-name>", "Project name or ID").option(
7452
+ "--server <id>",
7453
+ "Existing server ID, when the project has several on this URL"
7454
+ ).option("--name <name>", "Name for the server, if one is created").option("--reauthorize", "Force a fresh authorization").option("--no-browser", "Print the authorization link instead of opening it").option("--no-wait", "Return as soon as the request is created")
7455
+ ).action(
7456
+ async (options, command) => {
7457
+ const globalOptions = getGlobalOptions(command);
7458
+ const platformOptions = platformOptionsOf(command);
7459
+ const input = connectProjectServerOperation.inputSchema.parse({
7460
+ url: options.url,
7461
+ // NOT `options.project` — the `servers` group declares `--project` too
7462
+ // and therefore consumes it, so the subcommand's own copy is always
7463
+ // undefined and this command quietly connected to the default project
7464
+ // instead of the one that was named.
7465
+ project: platformOptions.project,
7466
+ serverId: options.server,
7467
+ name: options.name,
7468
+ reauthorize: options.reauthorize
7469
+ });
7470
+ const created = await runPlatformCommand9(
7471
+ platformOptions,
7472
+ globalOptions.timeout,
7473
+ ({ client, signal }) => connectProjectServerOperation.execute(input, { client, signal })
7474
+ );
7475
+ if (created.handoffUrl) {
7476
+ process.stderr.write(
7477
+ `Open this link to finish connecting:
7478
+ ${created.handoffUrl}
7479
+ `
7480
+ );
7481
+ if (options.browser !== false) {
7482
+ await openUrlInBrowser(created.handoffUrl).catch(() => {
7483
+ process.stderr.write(
7484
+ "Could not open a browser automatically \u2014 open the link above.\n"
7485
+ );
7486
+ });
7487
+ }
7488
+ }
7489
+ if (options.wait === false || isTerminalConnectionStatus(created.status)) {
7490
+ if (options.wait === false && !isTerminalConnectionStatus(created.status)) {
7491
+ process.stderr.write(
7492
+ `Not waiting. Follow it with:
7493
+ mcpjam projects server connect-status --request ${created.connectionRequestId}
7494
+ `
7495
+ );
7496
+ }
7497
+ writeResult(created, globalOptions.format);
7498
+ return;
7499
+ }
7500
+ const settled = await pollConnection(
7501
+ platformOptions,
7502
+ globalOptions.timeout,
7503
+ created.connectionRequestId,
7504
+ created.expiresAt
7505
+ );
7506
+ const latest = settled.result ?? created;
7507
+ writeResult(latest, globalOptions.format);
7508
+ if (settled.gaveUp) {
7509
+ process.stderr.write(
7510
+ `Stopped waiting; the request is still ${latest.status} and continues in the cloud.
7511
+ mcpjam projects server connect-status --request ${created.connectionRequestId}
7512
+ `
7513
+ );
7514
+ process.exitCode = 1;
7515
+ }
7516
+ }
7517
+ );
7518
+ addPlatformOptions9(
7519
+ servers.command("connect-status").description("Check a connection request started by `server connect`").requiredOption("--request <id>", "Connection request id (scr_\u2026)")
7520
+ ).action(
7521
+ async (options, command) => {
7522
+ const globalOptions = getGlobalOptions(command);
7523
+ const input = getProjectServerConnectionStatusOperation.inputSchema.parse({
7524
+ connectionRequestId: options.request
7525
+ });
7526
+ const payload = await runPlatformCommand9(
7527
+ platformOptionsOf(command),
7528
+ globalOptions.timeout,
7529
+ ({ client, signal }) => getProjectServerConnectionStatusOperation.execute(input, {
7530
+ client,
7531
+ signal
7532
+ })
7533
+ );
7534
+ writeResult(payload, globalOptions.format);
7535
+ }
7536
+ );
7537
+ addPlatformOptions9(
7287
7538
  projects.command("status").description(
7288
7539
  "Health-check every server in a project (hosted doctor per server)"
7289
7540
  ).option(
7290
7541
  "--project <id-or-name>",
7291
7542
  "Project name or ID (defaults to the most recently updated project)"
7292
7543
  )
7293
- ).action(async (options, command) => {
7544
+ ).action(async (_options, command) => {
7294
7545
  const globalOptions = getGlobalOptions(command);
7295
- const payload = await runPlatformCommand8(
7296
- options,
7546
+ const platformOptions = platformOptionsOf(command);
7547
+ const payload = await runPlatformCommand9(
7548
+ platformOptions,
7297
7549
  globalOptions.timeout,
7298
7550
  ({ client, signal }) => showServersOperation.execute(
7299
- { project: options.project },
7551
+ { project: platformOptions.project },
7300
7552
  { client, signal }
7301
7553
  )
7302
7554
  );
@@ -7308,6 +7560,75 @@ function registerProjectsCommands(program) {
7308
7560
  }
7309
7561
  });
7310
7562
  }
7563
+ var TERMINAL_CONNECTION_STATUSES = /* @__PURE__ */ new Set([
7564
+ "ready",
7565
+ "failed",
7566
+ "expired",
7567
+ "cancelled"
7568
+ ]);
7569
+ function isTerminalConnectionStatus(status) {
7570
+ return TERMINAL_CONNECTION_STATUSES.has(status);
7571
+ }
7572
+ var FALLBACK_POLL_WINDOW_MS = 60 * 60 * 1e3;
7573
+ async function pollConnection(options, timeoutMs, connectionRequestId, expiresAt) {
7574
+ let delayMs = 2e3;
7575
+ const expiryMs = expiresAt ? Date.parse(expiresAt) : Number.NaN;
7576
+ const deadline = Number.isFinite(expiryMs) ? expiryMs : Date.now() + FALLBACK_POLL_WINDOW_MS;
7577
+ let interrupted = false;
7578
+ let wakeSleep;
7579
+ const interruptController = new AbortController();
7580
+ let lastResult;
7581
+ const onInterrupt = () => {
7582
+ interrupted = true;
7583
+ process.stderr.write(
7584
+ "\nStopped watching. The request continues in the cloud \u2014 open the link above to finish it.\n"
7585
+ );
7586
+ wakeSleep?.();
7587
+ interruptController.abort(new Error("Interrupted by the user."));
7588
+ };
7589
+ process.once("SIGINT", onInterrupt);
7590
+ try {
7591
+ for (; ; ) {
7592
+ let current;
7593
+ try {
7594
+ current = await runPlatformCommand9(
7595
+ options,
7596
+ timeoutMs,
7597
+ ({ client, signal }) => getProjectServerConnectionStatusOperation.execute(
7598
+ { connectionRequestId },
7599
+ { client, signal }
7600
+ ),
7601
+ interruptController.signal
7602
+ );
7603
+ } catch (error) {
7604
+ if (!interrupted) throw error;
7605
+ return { result: lastResult, gaveUp: true };
7606
+ }
7607
+ lastResult = current;
7608
+ if (isTerminalConnectionStatus(current.status)) {
7609
+ return { result: current, gaveUp: false };
7610
+ }
7611
+ if (interrupted) return { result: current, gaveUp: true };
7612
+ if (Date.now() + delayMs > deadline) {
7613
+ return { result: current, gaveUp: true };
7614
+ }
7615
+ await new Promise((resolve) => {
7616
+ const timer = setTimeout(resolve, delayMs);
7617
+ wakeSleep = () => {
7618
+ clearTimeout(timer);
7619
+ resolve();
7620
+ };
7621
+ });
7622
+ wakeSleep = void 0;
7623
+ if (interrupted) {
7624
+ return { result: current, gaveUp: true };
7625
+ }
7626
+ delayMs = Math.min(delayMs * 1.5, 1e4);
7627
+ }
7628
+ } finally {
7629
+ process.removeListener("SIGINT", onInterrupt);
7630
+ }
7631
+ }
7311
7632
  function registerProtocolCommands(program) {
7312
7633
  const protocol = program.command("protocol").description("MCP protocol inspection and conformance checks");
7313
7634
  protocol.command("conformance").description("Run MCP protocol conformance checks against an HTTP server").requiredOption("--url <url>", "MCP server URL").option("--access-token <token>", "Bearer access token for HTTP servers").option(
@@ -13024,6 +13345,7 @@ function registerInspectorCommands(program) {
13024
13345
  // src/index.ts
13025
13346
  var pkgVersion = package_default.version;
13026
13347
  async function main(argv = process.argv, dependencies = {}) {
13348
+ process.exitCode = 0;
13027
13349
  const program = addGlobalOptions(
13028
13350
  new Command().name("mcpjam").version(pkgVersion, "-v, --version", "output the CLI version").description(
13029
13351
  "Test, debug, and validate MCP servers. Health checks, OAuth conformance, tool-surface diffing, and structured triage from the terminal or CI."
@@ -13046,6 +13368,7 @@ async function main(argv = process.argv, dependencies = {}) {
13046
13368
  registerXaaCommands(program);
13047
13369
  registerProtocolCommands(program);
13048
13370
  registerAuthCommands(program);
13371
+ registerOrganizationsCommands(program);
13049
13372
  registerProjectsCommands(program);
13050
13373
  registerEvalCommands(program);
13051
13374
  registerChatCommands(program);