@mcpjam/cli 3.21.0 → 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
@@ -9,7 +9,7 @@ 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, 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, 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';
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.21.0"};
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;
@@ -7040,6 +7040,22 @@ function table(rows) {
7040
7040
  ).join(" ").trimEnd()
7041
7041
  );
7042
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
+ }
7043
7059
  function formatProjectsHuman(projects) {
7044
7060
  if (projects.length === 0) {
7045
7061
  return "No accessible projects.";
@@ -7131,12 +7147,66 @@ function statusGlyph(status) {
7131
7147
  return "!";
7132
7148
  }
7133
7149
  }
7150
+
7151
+ // src/commands/organizations.ts
7134
7152
  function addPlatformOptions8(command) {
7135
7153
  return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
7136
7154
  "--api-url <url>",
7137
7155
  "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
7138
7156
  );
7139
7157
  }
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
+ }
7140
7210
  function platformOptionsOf(command) {
7141
7211
  const nearestFirst = [];
7142
7212
  for (let current = command; current !== null; current = current.parent) {
@@ -7157,7 +7227,7 @@ function requireProject(command, options) {
7157
7227
  }
7158
7228
  return project;
7159
7229
  }
7160
- async function runPlatformCommand8(options, timeoutMs, execute, externalSignal) {
7230
+ async function runPlatformCommand9(options, timeoutMs, execute, externalSignal) {
7161
7231
  const controller = new AbortController();
7162
7232
  const timeoutHandle = setTimeout(() => {
7163
7233
  controller.abort(
@@ -7191,14 +7261,27 @@ function registerProjectsCommands(program) {
7191
7261
  const projects = program.command("projects").description(
7192
7262
  "Operate the MCP servers saved in your hosted MCPJam projects"
7193
7263
  );
7194
- addPlatformOptions8(
7195
- projects.command("list").description("List the projects you can access")
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
+ )
7196
7269
  ).action(async (_options, command) => {
7197
7270
  const globalOptions = getGlobalOptions(command);
7198
- const result = await runPlatformCommand8(
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(
7199
7279
  platformOptionsOf(command),
7200
7280
  globalOptions.timeout,
7201
- ({ client, signal }) => listProjectsOperation.execute({}, { client, signal })
7281
+ ({ client, signal }) => listProjectsOperation.execute(
7282
+ organizationId ? { organizationId } : {},
7283
+ { client, signal }
7284
+ )
7202
7285
  );
7203
7286
  if (globalOptions.format === "human") {
7204
7287
  process.stdout.write(`${formatProjectsHuman(result.items)}
@@ -7207,7 +7290,7 @@ function registerProjectsCommands(program) {
7207
7290
  writeResult(result, globalOptions.format);
7208
7291
  }
7209
7292
  });
7210
- addPlatformOptions8(
7293
+ addPlatformOptions9(
7211
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")
7212
7295
  ).action(
7213
7296
  async (options, command) => {
@@ -7218,7 +7301,7 @@ function registerProjectsCommands(program) {
7218
7301
  ...options.organizationId === void 0 ? {} : { organizationId: options.organizationId },
7219
7302
  ...options.visibility === void 0 ? {} : { visibility: options.visibility }
7220
7303
  });
7221
- const result = await runPlatformCommand8(
7304
+ const result = await runPlatformCommand9(
7222
7305
  platformOptionsOf(command),
7223
7306
  globalOptions.timeout,
7224
7307
  ({ client, signal }) => createProjectOperation.execute(input, { client, signal })
@@ -7226,7 +7309,7 @@ function registerProjectsCommands(program) {
7226
7309
  writeResult(result, globalOptions.format);
7227
7310
  }
7228
7311
  );
7229
- addPlatformOptions8(
7312
+ addPlatformOptions9(
7230
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")
7231
7314
  ).action(
7232
7315
  async (options, command) => {
@@ -7238,7 +7321,7 @@ function registerProjectsCommands(program) {
7238
7321
  ...options.description === void 0 ? {} : { description: options.description },
7239
7322
  ...options.visibility === void 0 ? {} : { visibility: options.visibility }
7240
7323
  });
7241
- const result = await runPlatformCommand8(
7324
+ const result = await runPlatformCommand9(
7242
7325
  platformOptions,
7243
7326
  globalOptions.timeout,
7244
7327
  ({ client, signal }) => updateProjectOperation.execute(input, { client, signal })
@@ -7246,7 +7329,7 @@ function registerProjectsCommands(program) {
7246
7329
  writeResult(result, globalOptions.format);
7247
7330
  }
7248
7331
  );
7249
- addPlatformOptions8(
7332
+ addPlatformOptions9(
7250
7333
  projects.command("delete").description("Delete a project and its project-owned resources").requiredOption("--project <id-or-name>", "Project name or ID")
7251
7334
  ).action(async (_options, command) => {
7252
7335
  const globalOptions = getGlobalOptions(command);
@@ -7254,14 +7337,14 @@ function registerProjectsCommands(program) {
7254
7337
  const input = deleteProjectOperation.inputSchema.parse({
7255
7338
  project: requireProject(command, platformOptions)
7256
7339
  });
7257
- const result = await runPlatformCommand8(
7340
+ const result = await runPlatformCommand9(
7258
7341
  platformOptions,
7259
7342
  globalOptions.timeout,
7260
7343
  ({ client, signal }) => deleteProjectOperation.execute(input, { client, signal })
7261
7344
  );
7262
7345
  writeResult(result, globalOptions.format);
7263
7346
  });
7264
- const servers = addPlatformOptions8(
7347
+ const servers = addPlatformOptions9(
7265
7348
  projects.command("servers").alias("server").description("List and manage the servers saved in a project")
7266
7349
  ).option(
7267
7350
  "--project <id-or-name>",
@@ -7270,7 +7353,7 @@ function registerProjectsCommands(program) {
7270
7353
  servers.action(async (_options, command) => {
7271
7354
  const globalOptions = getGlobalOptions(command);
7272
7355
  const platformOptions = platformOptionsOf(command);
7273
- const result = await runPlatformCommand8(
7356
+ const result = await runPlatformCommand9(
7274
7357
  platformOptions,
7275
7358
  globalOptions.timeout,
7276
7359
  ({ client, signal }) => listProjectServersOperation.execute(
@@ -7292,13 +7375,13 @@ function registerProjectsCommands(program) {
7292
7375
  }
7293
7376
  return parsed;
7294
7377
  };
7295
- addPlatformOptions8(
7378
+ addPlatformOptions9(
7296
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")
7297
7380
  ).action(async (options, command) => {
7298
7381
  const globalOptions = getGlobalOptions(command);
7299
7382
  const platformOptions = platformOptionsOf(command);
7300
7383
  const project = requireProject(command, platformOptions);
7301
- const result = await runPlatformCommand8(
7384
+ const result = await runPlatformCommand9(
7302
7385
  platformOptions,
7303
7386
  globalOptions.timeout,
7304
7387
  ({ client, signal }) => createProjectServerOperation.execute(
@@ -7308,13 +7391,13 @@ function registerProjectsCommands(program) {
7308
7391
  );
7309
7392
  writeResult(result, globalOptions.format);
7310
7393
  });
7311
- addPlatformOptions8(
7394
+ addPlatformOptions9(
7312
7395
  servers.command("get").description("Get one saved MCP server").option("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID")
7313
7396
  ).action(async (options, command) => {
7314
7397
  const globalOptions = getGlobalOptions(command);
7315
7398
  const platformOptions = platformOptionsOf(command);
7316
7399
  const project = requireProject(command, platformOptions);
7317
- const result = await runPlatformCommand8(
7400
+ const result = await runPlatformCommand9(
7318
7401
  platformOptions,
7319
7402
  globalOptions.timeout,
7320
7403
  ({ client, signal }) => getProjectServerOperation.execute(
@@ -7324,14 +7407,14 @@ function registerProjectsCommands(program) {
7324
7407
  );
7325
7408
  writeResult(result, globalOptions.format);
7326
7409
  });
7327
- addPlatformOptions8(
7410
+ addPlatformOptions9(
7328
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")
7329
7412
  ).action(
7330
7413
  async (options, command) => {
7331
7414
  const globalOptions = getGlobalOptions(command);
7332
7415
  const platformOptions = platformOptionsOf(command);
7333
7416
  const project = requireProject(command, platformOptions);
7334
- const result = await runPlatformCommand8(
7417
+ const result = await runPlatformCommand9(
7335
7418
  platformOptions,
7336
7419
  globalOptions.timeout,
7337
7420
  ({ client, signal }) => updateProjectServerOperation.execute(
@@ -7346,13 +7429,13 @@ function registerProjectsCommands(program) {
7346
7429
  writeResult(result, globalOptions.format);
7347
7430
  }
7348
7431
  );
7349
- addPlatformOptions8(
7432
+ addPlatformOptions9(
7350
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")
7351
7434
  ).action(async (options, command) => {
7352
7435
  const globalOptions = getGlobalOptions(command);
7353
7436
  const platformOptions = platformOptionsOf(command);
7354
7437
  const project = requireProject(command, platformOptions);
7355
- const result = await runPlatformCommand8(
7438
+ const result = await runPlatformCommand9(
7356
7439
  platformOptions,
7357
7440
  globalOptions.timeout,
7358
7441
  ({ client, signal }) => deleteProjectServerOperation.execute(
@@ -7362,7 +7445,7 @@ function registerProjectsCommands(program) {
7362
7445
  );
7363
7446
  writeResult(result, globalOptions.format);
7364
7447
  });
7365
- addPlatformOptions8(
7448
+ addPlatformOptions9(
7366
7449
  servers.command("connect").description(
7367
7450
  "Connect an MCP server URL to a project, authorizing in a browser if needed"
7368
7451
  ).requiredOption("--url <url>", "MCP server URL to connect").option("--project <id-or-name>", "Project name or ID").option(
@@ -7384,7 +7467,7 @@ function registerProjectsCommands(program) {
7384
7467
  name: options.name,
7385
7468
  reauthorize: options.reauthorize
7386
7469
  });
7387
- const created = await runPlatformCommand8(
7470
+ const created = await runPlatformCommand9(
7388
7471
  platformOptions,
7389
7472
  globalOptions.timeout,
7390
7473
  ({ client, signal }) => connectProjectServerOperation.execute(input, { client, signal })
@@ -7432,7 +7515,7 @@ function registerProjectsCommands(program) {
7432
7515
  }
7433
7516
  }
7434
7517
  );
7435
- addPlatformOptions8(
7518
+ addPlatformOptions9(
7436
7519
  servers.command("connect-status").description("Check a connection request started by `server connect`").requiredOption("--request <id>", "Connection request id (scr_\u2026)")
7437
7520
  ).action(
7438
7521
  async (options, command) => {
@@ -7440,7 +7523,7 @@ function registerProjectsCommands(program) {
7440
7523
  const input = getProjectServerConnectionStatusOperation.inputSchema.parse({
7441
7524
  connectionRequestId: options.request
7442
7525
  });
7443
- const payload = await runPlatformCommand8(
7526
+ const payload = await runPlatformCommand9(
7444
7527
  platformOptionsOf(command),
7445
7528
  globalOptions.timeout,
7446
7529
  ({ client, signal }) => getProjectServerConnectionStatusOperation.execute(input, {
@@ -7451,7 +7534,7 @@ function registerProjectsCommands(program) {
7451
7534
  writeResult(payload, globalOptions.format);
7452
7535
  }
7453
7536
  );
7454
- addPlatformOptions8(
7537
+ addPlatformOptions9(
7455
7538
  projects.command("status").description(
7456
7539
  "Health-check every server in a project (hosted doctor per server)"
7457
7540
  ).option(
@@ -7461,7 +7544,7 @@ function registerProjectsCommands(program) {
7461
7544
  ).action(async (_options, command) => {
7462
7545
  const globalOptions = getGlobalOptions(command);
7463
7546
  const platformOptions = platformOptionsOf(command);
7464
- const payload = await runPlatformCommand8(
7547
+ const payload = await runPlatformCommand9(
7465
7548
  platformOptions,
7466
7549
  globalOptions.timeout,
7467
7550
  ({ client, signal }) => showServersOperation.execute(
@@ -7508,7 +7591,7 @@ async function pollConnection(options, timeoutMs, connectionRequestId, expiresAt
7508
7591
  for (; ; ) {
7509
7592
  let current;
7510
7593
  try {
7511
- current = await runPlatformCommand8(
7594
+ current = await runPlatformCommand9(
7512
7595
  options,
7513
7596
  timeoutMs,
7514
7597
  ({ client, signal }) => getProjectServerConnectionStatusOperation.execute(
@@ -13285,6 +13368,7 @@ async function main(argv = process.argv, dependencies = {}) {
13285
13368
  registerXaaCommands(program);
13286
13369
  registerProtocolCommands(program);
13287
13370
  registerAuthCommands(program);
13371
+ registerOrganizationsCommands(program);
13288
13372
  registerProjectsCommands(program);
13289
13373
  registerEvalCommands(program);
13290
13374
  registerChatCommands(program);