@mcpjam/cli 3.11.1 → 3.13.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,15 +2,17 @@
2
2
  import { Command, CommanderError } from 'commander';
3
3
  import { realpathSync, mkdirSync, writeFileSync, readFileSync, existsSync, statSync, closeSync, renameSync, openSync } from 'fs';
4
4
  import { pathToFileURL } from 'url';
5
- import { probeMcpServer, redactSensitiveValue, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, listPrompts, getPrompt, MCPAppsConformanceTest, MCPAppsConformanceSuite, runOAuthLogin, OAuthConformanceTest, OAuthConformanceSuite, MCPConformanceTest, MCPConformanceSuite, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, openUrlInBrowser, MCPClientManager, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, OAuthProxyError, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS } from '@mcpjam/sdk';
5
+ import { probeMcpServer, redactSensitiveValue, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, MCPAppsConformanceSuite, runOAuthLogin, OAuthConformanceTest, OAuthConformanceSuite, MCPConformanceTest, MCPConformanceSuite, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, openUrlInBrowser, MCPClientManager, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, OAuthProxyError, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS } from '@mcpjam/sdk';
6
6
  import { mkdir, writeFile, readFile, chmod, rename, rm } from 'fs/promises';
7
7
  import path2, { dirname, join, basename } from 'path';
8
8
  import { randomUUID } from 'crypto';
9
9
  import { spawn } from 'child_process';
10
10
  import { createRequire } from 'module';
11
11
  import os, { homedir } from 'os';
12
- import { cancelEvalRunOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createHostOperation, updateHostOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listProjectsOperation, listProjectServersOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation } from '@mcpjam/sdk/platform';
13
- import { HOST_TEMPLATES as HOST_TEMPLATES$1 } from '@mcpjam/sdk/host-config/templates';
12
+ import { cancelEvalRunOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createHostOperation, updateHostOperation, createEnvironmentOperation, updateEnvironmentOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listProjectsOperation, listProjectServersOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation, listEnvironmentsOperation, getEnvironmentOperation, buildEnvironmentOperation, listEnvironmentBuildsOperation, useEnvironmentOperation, resetComputerOperation, promoteEnvironmentOperation, deleteEnvironmentOperation } from '@mcpjam/sdk/platform';
13
+ import { buildHostProfilesFromCatalog, buildMarketHostProfiles, scanWidgetUsage, evaluateMarketHosts, fetchHostCompatCatalog } from '@mcpjam/sdk/host-compat';
14
+ import { HOST_TEMPLATES as HOST_TEMPLATES$1, HOST_TEMPLATE_IDS, seedHostTemplate } from '@mcpjam/sdk/host-config/templates';
15
+ import { applyVisibilityPolicyAndCountSignals, isAppOnlyTool, extractHostExecutionPolicy, hostConnectionProfile } from '@mcpjam/sdk/host-config/internal';
14
16
  import { StdioServerTransport, McpServer } from '@modelcontextprotocol/server';
15
17
  import { z } from 'zod';
16
18
  import { PostHog } from 'posthog-node';
@@ -21,7 +23,7 @@ import { WebSocket } from 'ws';
21
23
 
22
24
  // package.json
23
25
  var package_default = {
24
- version: "3.11.1"};
26
+ version: "3.13.0"};
25
27
 
26
28
  // src/lib/output.ts
27
29
  var DEFAULT_OUTPUT_FORMAT = "json";
@@ -822,6 +824,12 @@ function addSharedServerOptions(command) {
822
824
  'Stdio environment assignment in "KEY=VALUE" format. Pass multiple values or repeat the flag.'
823
825
  ).option("--cwd <path>", "Working directory for the stdio MCP server process");
824
826
  }
827
+ function addHostOption(command) {
828
+ return command.option(
829
+ "--host <id>",
830
+ "Connect as this host (e.g. claude, chatgpt, cursor) \u2014 sends its identity/capabilities/protocol and applies its tool visibility"
831
+ );
832
+ }
825
833
  function getGlobalOptions(command) {
826
834
  const options = command.optsWithGlobals();
827
835
  return {
@@ -3388,6 +3396,430 @@ function registerAuthCommands(program) {
3388
3396
  }
3389
3397
  });
3390
3398
  }
3399
+ function resolveHostConnection(hostId) {
3400
+ if (!HOST_TEMPLATE_IDS.includes(hostId)) {
3401
+ throw usageError(
3402
+ `Unknown host "${hostId}". Valid hosts: ${HOST_TEMPLATE_IDS.join(", ")}.`
3403
+ );
3404
+ }
3405
+ const id = hostId;
3406
+ const seeded = seedHostTemplate(id);
3407
+ return {
3408
+ id,
3409
+ connection: hostConnectionProfile(seeded),
3410
+ policy: extractHostExecutionPolicy(seeded, id)
3411
+ };
3412
+ }
3413
+ function resolveHostFromOptions(options) {
3414
+ if (!options.host) return void 0;
3415
+ if (options.clientCapabilities !== void 0) {
3416
+ throw usageError(
3417
+ "--host advertises the host's client capabilities; pass --host or --client-capabilities, not both."
3418
+ );
3419
+ }
3420
+ return resolveHostConnection(options.host);
3421
+ }
3422
+ function applyHostToConfig(config, host) {
3423
+ const identity = {
3424
+ ...host.clientInfo ? { clientInfo: host.clientInfo } : {},
3425
+ ...host.clientCapabilities ? { clientCapabilities: host.clientCapabilities } : {},
3426
+ ...host.supportedProtocolVersions ? { supportedProtocolVersions: host.supportedProtocolVersions } : {}
3427
+ };
3428
+ const httpOnly = "url" in config && host.mcpProtocolVersion ? { mcpProtocolVersion: host.mcpProtocolVersion } : {};
3429
+ return { ...config, ...identity, ...httpOnly };
3430
+ }
3431
+ function applyHostVisibility(tools, manager, serverId, policy) {
3432
+ const record = {};
3433
+ for (const tool of tools) {
3434
+ record[String(tool.name)] = { ...tool, _serverId: serverId };
3435
+ }
3436
+ const signals = applyVisibilityPolicyAndCountSignals(
3437
+ record,
3438
+ manager,
3439
+ policy
3440
+ );
3441
+ const visible = tools.filter((tool) => String(tool.name) in record);
3442
+ return { tools: visible, toolsDroppedVisibility: signals.toolsDroppedVisibility };
3443
+ }
3444
+ var TOOLS_PAGE_CAP = 50;
3445
+ async function assertToolVisibleToHost(manager, serverId, toolName, host) {
3446
+ if (host.policy.respectToolVisibility === false) return;
3447
+ const seenCursors = /* @__PURE__ */ new Set();
3448
+ let cursor;
3449
+ for (let page = 0; page < TOOLS_PAGE_CAP; page++) {
3450
+ const result = await manager.listTools(
3451
+ serverId,
3452
+ cursor ? { cursor } : void 0
3453
+ );
3454
+ const tool = (result.tools ?? []).find(
3455
+ (t) => t.name === toolName
3456
+ );
3457
+ if (tool) {
3458
+ if (isAppOnlyTool(tool._meta)) {
3459
+ throw usageError(
3460
+ `Tool "${toolName}" is app-only \u2014 not visible to host "${host.id}"'s model. Omit --host to call it as an operator.`
3461
+ );
3462
+ }
3463
+ return;
3464
+ }
3465
+ cursor = result.nextCursor;
3466
+ if (!cursor) return;
3467
+ if (seenCursors.has(cursor)) break;
3468
+ seenCursors.add(cursor);
3469
+ }
3470
+ throw usageError(
3471
+ `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.`
3472
+ );
3473
+ }
3474
+
3475
+ // src/lib/ephemeral.ts
3476
+ async function withEphemeralManager(config, fn, options) {
3477
+ const resolvedConfig = options?.host ? applyHostToConfig(config, options.host) : config;
3478
+ return withEphemeralClient(resolvedConfig, fn, {
3479
+ serverId: "__cli__",
3480
+ clientName: "mcpjam",
3481
+ timeout: options?.timeout ?? 3e4,
3482
+ rpcLogger: options?.rpcLogger,
3483
+ retryPolicy: options?.retryPolicy
3484
+ });
3485
+ }
3486
+
3487
+ // src/commands/compat.ts
3488
+ var TOOLS_PAGE_CAP2 = 50;
3489
+ var CATALOG_FETCH_TIMEOUT_MS = 2500;
3490
+ async function resolveHostCatalog(options) {
3491
+ if (options.offline) return null;
3492
+ return fetchHostCompatCatalog({
3493
+ baseUrl: options.catalogUrl,
3494
+ timeoutMs: CATALOG_FETCH_TIMEOUT_MS
3495
+ });
3496
+ }
3497
+ function registerCompatCommands(program) {
3498
+ addRetryOptions(
3499
+ addSharedServerOptions(
3500
+ program.command("compat").description(
3501
+ "Check whether an MCP server's tools and widgets work on each AI host (Claude, ChatGPT, Cursor, Copilot, Codex, Goose, \u2026)"
3502
+ ).option(
3503
+ "--host <id>",
3504
+ "Only report this host id. Repeat for several. Default: all.",
3505
+ (value, previous = []) => [...previous, value],
3506
+ []
3507
+ ).option(
3508
+ "--offline",
3509
+ "Skip the live host-catalog fetch and use the bundled catalog (zero MCPJam network)."
3510
+ ).option(
3511
+ "--catalog-url <url>",
3512
+ "Base URL to fetch the live host catalog from. Default: the hosted MCPJam API."
3513
+ )
3514
+ )
3515
+ ).action(async (options, command) => {
3516
+ const globalOptions = getGlobalOptions(command);
3517
+ const retryPolicy = parseRetryPolicy(options);
3518
+ const catalogResult = await resolveHostCatalog(options);
3519
+ const liveCatalog = catalogResult?.ok && catalogResult.source === "live" ? catalogResult.catalog : void 0;
3520
+ const catalogSource = liveCatalog ? "live" : "bundled";
3521
+ const validHostIds = (liveCatalog ? buildHostProfilesFromCatalog(liveCatalog) : buildMarketHostProfiles()).map((p) => p.id);
3522
+ const requestedHosts = options.host;
3523
+ const unknownHosts = requestedHosts.filter(
3524
+ (id) => !validHostIds.includes(id)
3525
+ );
3526
+ if (unknownHosts.length > 0) {
3527
+ throw usageError(
3528
+ `Unknown host id${unknownHosts.length === 1 ? "" : "s"}: ${unknownHosts.join(", ")}. Valid: ${validHostIds.join(", ")}`
3529
+ );
3530
+ }
3531
+ const config = parseServerConfig({
3532
+ ...options,
3533
+ timeout: globalOptions.timeout
3534
+ });
3535
+ const result = await withEphemeralManager(
3536
+ config,
3537
+ async (manager, serverId) => {
3538
+ const tools = [];
3539
+ let cursor;
3540
+ let truncated = false;
3541
+ for (let page = 0; page < TOOLS_PAGE_CAP2; page++) {
3542
+ const result2 = await listTools(manager, { serverId, cursor });
3543
+ tools.push(
3544
+ ...result2.tools
3545
+ );
3546
+ cursor = result2.nextCursor;
3547
+ if (!cursor) break;
3548
+ if (page === TOOLS_PAGE_CAP2 - 1) truncated = true;
3549
+ }
3550
+ const toolsData = { tools };
3551
+ const widgetUsage = await scanWidgetUsage(toolsData, async (uri) => {
3552
+ const { content } = await readResource(manager, { serverId, uri });
3553
+ return content;
3554
+ });
3555
+ const { requirements, reports } = evaluateMarketHosts(toolsData, {
3556
+ widgetUsage,
3557
+ toolsTruncated: truncated,
3558
+ catalog: liveCatalog
3559
+ });
3560
+ const hostFilter = new Set(options.host);
3561
+ const hosts = (hostFilter.size > 0 ? reports.filter((r) => hostFilter.has(r.hostId)) : reports).map((r) => ({
3562
+ hostId: r.hostId,
3563
+ hostLabel: r.hostLabel,
3564
+ verdict: r.verdict,
3565
+ provenance: r.provenance,
3566
+ findings: r.findings
3567
+ }));
3568
+ const summary = { works: 0, degraded: 0, blocked: 0, unknown: 0 };
3569
+ for (const h of hosts) summary[h.verdict] += 1;
3570
+ return {
3571
+ target: describeTarget(options),
3572
+ catalogSource,
3573
+ // Always present for a stable contract: the backend publish version
3574
+ // when live, else 0 (the "not a backend publish" sentinel) for the
3575
+ // bundled/offline fallback.
3576
+ catalogVersion: liveCatalog && catalogResult?.ok ? catalogResult.version : 0,
3577
+ widgets: {
3578
+ total: requirements.widgets.mcpAppsOnly.length + requirements.widgets.openaiAppsOnly.length + requirements.widgets.dual.length,
3579
+ appOnly: requirements.appOnlyWidgets.length
3580
+ },
3581
+ unknownDimensions: requirements.unknownDimensions,
3582
+ summary,
3583
+ hosts
3584
+ };
3585
+ },
3586
+ {
3587
+ timeout: globalOptions.timeout,
3588
+ retryPolicy
3589
+ }
3590
+ );
3591
+ if (!globalOptions.quiet) {
3592
+ const catalogNote = liveCatalog && catalogResult?.ok ? `host catalog: live v${catalogResult.version}` : `host catalog: bundled${options.offline ? " (--offline)" : ""}`;
3593
+ process.stderr.write(`\x1B[2m${catalogNote}\x1B[0m
3594
+ `);
3595
+ }
3596
+ writeResult(result, globalOptions.format);
3597
+ });
3598
+ }
3599
+ function addPlatformOptions(command) {
3600
+ return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
3601
+ "--api-url <url>",
3602
+ "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
3603
+ );
3604
+ }
3605
+ async function runPlatformCommand(options, timeoutMs, execute) {
3606
+ const controller = new AbortController();
3607
+ const timeoutHandle = setTimeout(() => {
3608
+ controller.abort(
3609
+ new PlatformApiError(`Request timed out after ${timeoutMs}ms`, "TIMEOUT", {
3610
+ status: 0
3611
+ })
3612
+ );
3613
+ }, timeoutMs);
3614
+ timeoutHandle.unref?.();
3615
+ try {
3616
+ const { client } = buildPlatformClient({ ...options, timeoutMs });
3617
+ return await execute({ client, signal: controller.signal });
3618
+ } catch (error) {
3619
+ if (controller.signal.aborted && controller.signal.reason instanceof PlatformApiError) {
3620
+ throw toCliError(controller.signal.reason);
3621
+ }
3622
+ throw toCliError(error);
3623
+ } finally {
3624
+ clearTimeout(timeoutHandle);
3625
+ }
3626
+ }
3627
+ function loadDockerfileText(file) {
3628
+ let text;
3629
+ try {
3630
+ text = file === "-" ? readFileSync(0, "utf8") : readFileSync(file, "utf8");
3631
+ } catch (error) {
3632
+ throw usageError(`Failed to read --file "${file}".`, {
3633
+ source: error instanceof Error ? error.message : String(error)
3634
+ });
3635
+ }
3636
+ if (text.trim() === "") throw usageError("--file input is empty.");
3637
+ return text;
3638
+ }
3639
+ function validateInput(op, raw) {
3640
+ const parsed = op.inputSchema.safeParse(raw);
3641
+ if (!parsed.success) {
3642
+ const detail = parsed.error.issues.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ");
3643
+ throw usageError(`Invalid input: ${detail}`);
3644
+ }
3645
+ return parsed.data;
3646
+ }
3647
+ function registerEnvironmentsCommands(program) {
3648
+ const env = program.command("env").description(
3649
+ "List, build, and manage custom Computer environments (Dockerfile images) in your hosted MCPJam projects"
3650
+ );
3651
+ addPlatformOptions(
3652
+ env.command("list").description("List the environments in a project").option(
3653
+ "--project <id-or-name>",
3654
+ "Project name or ID (defaults to the most recently updated project)"
3655
+ )
3656
+ ).action(async (options, command) => {
3657
+ const globalOptions = getGlobalOptions(command);
3658
+ const result = await runPlatformCommand(
3659
+ options,
3660
+ globalOptions.timeout,
3661
+ ({ client, signal }) => listEnvironmentsOperation.execute(
3662
+ { project: options.project },
3663
+ { client, signal }
3664
+ )
3665
+ );
3666
+ writeResult(result, globalOptions.format);
3667
+ });
3668
+ addPlatformOptions(
3669
+ env.command("get").description("Show one environment's Dockerfile and latest build status").requiredOption("--environment <id-or-name>", "Environment name or ID").option("--project <id-or-name>", "Project name or ID")
3670
+ ).action(
3671
+ async (options, command) => {
3672
+ const globalOptions = getGlobalOptions(command);
3673
+ const result = await runPlatformCommand(
3674
+ options,
3675
+ globalOptions.timeout,
3676
+ ({ client, signal }) => getEnvironmentOperation.execute(
3677
+ { project: options.project, environment: options.environment },
3678
+ { client, signal }
3679
+ )
3680
+ );
3681
+ writeResult(result, globalOptions.format);
3682
+ }
3683
+ );
3684
+ addPlatformOptions(
3685
+ env.command("create").description("Create an environment from a Dockerfile (--file, or - for stdin)").requiredOption("--name <name>", "Display name for the new environment").requiredOption(
3686
+ "--file <path>",
3687
+ "Dockerfile path, or - to read it from stdin"
3688
+ ).option("--project <id-or-name>", "Project name or ID")
3689
+ ).action(
3690
+ async (options, command) => {
3691
+ const globalOptions = getGlobalOptions(command);
3692
+ const dockerfile = loadDockerfileText(options.file);
3693
+ const input = validateInput(createEnvironmentOperation, {
3694
+ project: options.project,
3695
+ name: options.name,
3696
+ dockerfile
3697
+ });
3698
+ const result = await runPlatformCommand(
3699
+ options,
3700
+ globalOptions.timeout,
3701
+ ({ client, signal }) => createEnvironmentOperation.execute(input, { client, signal })
3702
+ );
3703
+ writeResult(result, globalOptions.format);
3704
+ }
3705
+ );
3706
+ addPlatformOptions(
3707
+ env.command("edit").description("Edit an environment's name and/or Dockerfile").requiredOption("--environment <id-or-name>", "Environment name or ID").option("--project <id-or-name>", "Project name or ID").option("--name <name>", "New display name").option("--file <path>", "Replacement Dockerfile path (or - for stdin)")
3708
+ ).action(
3709
+ async (options, command) => {
3710
+ const globalOptions = getGlobalOptions(command);
3711
+ const dockerfile = options.file !== void 0 ? loadDockerfileText(options.file) : void 0;
3712
+ const input = validateInput(updateEnvironmentOperation, {
3713
+ project: options.project,
3714
+ environment: options.environment,
3715
+ ...options.name !== void 0 ? { name: options.name } : {},
3716
+ ...dockerfile !== void 0 ? { dockerfile } : {}
3717
+ });
3718
+ const result = await runPlatformCommand(
3719
+ options,
3720
+ globalOptions.timeout,
3721
+ ({ client, signal }) => updateEnvironmentOperation.execute(input, { client, signal })
3722
+ );
3723
+ writeResult(result, globalOptions.format);
3724
+ }
3725
+ );
3726
+ addPlatformOptions(
3727
+ env.command("build").description("Build the environment's image (async \u2014 poll `env logs` for status)").requiredOption("--environment <id-or-name>", "Environment name or ID").option("--project <id-or-name>", "Project name or ID")
3728
+ ).action(
3729
+ async (options, command) => {
3730
+ const globalOptions = getGlobalOptions(command);
3731
+ const result = await runPlatformCommand(
3732
+ options,
3733
+ globalOptions.timeout,
3734
+ ({ client, signal }) => buildEnvironmentOperation.execute(
3735
+ { project: options.project, environment: options.environment },
3736
+ { client, signal }
3737
+ )
3738
+ );
3739
+ writeResult(result, globalOptions.format);
3740
+ }
3741
+ );
3742
+ addPlatformOptions(
3743
+ env.command("logs").description("Show an environment's builds (newest first) with their log preview").requiredOption("--environment <id-or-name>", "Environment name or ID").option("--project <id-or-name>", "Project name or ID")
3744
+ ).action(
3745
+ async (options, command) => {
3746
+ const globalOptions = getGlobalOptions(command);
3747
+ const result = await runPlatformCommand(
3748
+ options,
3749
+ globalOptions.timeout,
3750
+ ({ client, signal }) => listEnvironmentBuildsOperation.execute(
3751
+ { project: options.project, environment: options.environment },
3752
+ { client, signal }
3753
+ )
3754
+ );
3755
+ writeResult(result, globalOptions.format);
3756
+ }
3757
+ );
3758
+ addPlatformOptions(
3759
+ env.command("use").description(
3760
+ "Boot your computer from this environment (rebuilds it \u2014 installed files are wiped)"
3761
+ ).requiredOption("--environment <id-or-name>", "Environment name or ID").option("--project <id-or-name>", "Project name or ID")
3762
+ ).action(
3763
+ async (options, command) => {
3764
+ const globalOptions = getGlobalOptions(command);
3765
+ const result = await runPlatformCommand(
3766
+ options,
3767
+ globalOptions.timeout,
3768
+ ({ client, signal }) => useEnvironmentOperation.execute(
3769
+ { project: options.project, environment: options.environment },
3770
+ { client, signal }
3771
+ )
3772
+ );
3773
+ writeResult(result, globalOptions.format);
3774
+ }
3775
+ );
3776
+ addPlatformOptions(
3777
+ env.command("reset").description("Reset your computer to its current image (wipes mutable state)").option("--project <id-or-name>", "Project name or ID")
3778
+ ).action(async (options, command) => {
3779
+ const globalOptions = getGlobalOptions(command);
3780
+ const result = await runPlatformCommand(
3781
+ options,
3782
+ globalOptions.timeout,
3783
+ ({ client, signal }) => resetComputerOperation.execute(
3784
+ { project: options.project },
3785
+ { client, signal }
3786
+ )
3787
+ );
3788
+ writeResult(result, globalOptions.format);
3789
+ });
3790
+ addPlatformOptions(
3791
+ env.command("promote").description("Share a personal-draft environment with the whole project (admin only)").requiredOption("--environment <id-or-name>", "Environment name or ID").option("--project <id-or-name>", "Project name or ID")
3792
+ ).action(
3793
+ async (options, command) => {
3794
+ const globalOptions = getGlobalOptions(command);
3795
+ const result = await runPlatformCommand(
3796
+ options,
3797
+ globalOptions.timeout,
3798
+ ({ client, signal }) => promoteEnvironmentOperation.execute(
3799
+ { project: options.project, environment: options.environment },
3800
+ { client, signal }
3801
+ )
3802
+ );
3803
+ writeResult(result, globalOptions.format);
3804
+ }
3805
+ );
3806
+ addPlatformOptions(
3807
+ env.command("delete").description("Permanently delete an environment from a project").requiredOption("--environment <id-or-name>", "Environment name or ID").option("--project <id-or-name>", "Project name or ID")
3808
+ ).action(
3809
+ async (options, command) => {
3810
+ const globalOptions = getGlobalOptions(command);
3811
+ const result = await runPlatformCommand(
3812
+ options,
3813
+ globalOptions.timeout,
3814
+ ({ client, signal }) => deleteEnvironmentOperation.execute(
3815
+ { project: options.project, environment: options.environment },
3816
+ { client, signal }
3817
+ )
3818
+ );
3819
+ writeResult(result, globalOptions.format);
3820
+ }
3821
+ );
3822
+ }
3391
3823
 
3392
3824
  // src/lib/eval-screenshots.ts
3393
3825
  function asRecord(value) {
@@ -3499,13 +3931,13 @@ function encodeInlineImage(data, protocol) {
3499
3931
  }
3500
3932
 
3501
3933
  // src/commands/eval.ts
3502
- function addPlatformOptions(command) {
3934
+ function addPlatformOptions2(command) {
3503
3935
  return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
3504
3936
  "--api-url <url>",
3505
3937
  "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
3506
3938
  );
3507
3939
  }
3508
- async function runPlatformCommand(options, timeoutMs, execute) {
3940
+ async function runPlatformCommand2(options, timeoutMs, execute) {
3509
3941
  const controller = new AbortController();
3510
3942
  const timeoutHandle = setTimeout(() => {
3511
3943
  controller.abort(
@@ -3615,7 +4047,7 @@ function validateOpInput(op, raw) {
3615
4047
  }
3616
4048
  async function executeOp(op, input, options, command) {
3617
4049
  const globalOptions = getGlobalOptions(command);
3618
- const result = await runPlatformCommand(
4050
+ const result = await runPlatformCommand2(
3619
4051
  options,
3620
4052
  globalOptions.timeout,
3621
4053
  ({ client, signal }) => op.execute(input, { client, signal })
@@ -3715,7 +4147,7 @@ function resolveScreenshotPath(out, shot, index, total) {
3715
4147
  }
3716
4148
  function registerEvalCommands(program) {
3717
4149
  const evals = program.command("eval").description("Author and run eval suites in your hosted MCPJam projects");
3718
- addPlatformOptions(
4150
+ addPlatformOptions2(
3719
4151
  evals.command("create").description(
3720
4152
  "Create a runnable eval suite from authored test cases (does not run it)"
3721
4153
  ).option(
@@ -3740,21 +4172,21 @@ function registerEvalCommands(program) {
3740
4172
  ).action(async (options, command) => {
3741
4173
  const globalOptions = getGlobalOptions(command);
3742
4174
  const input = loadSuiteDefinition(options);
3743
- const result = await runPlatformCommand(
4175
+ const result = await runPlatformCommand2(
3744
4176
  options,
3745
4177
  globalOptions.timeout,
3746
4178
  ({ client, signal }) => createEvalSuiteOperation.execute(input, { client, signal })
3747
4179
  );
3748
4180
  writeResult(result, globalOptions.format);
3749
4181
  });
3750
- addPlatformOptions(
4182
+ addPlatformOptions2(
3751
4183
  evals.command("list").description("List the eval suites saved in a project").option(
3752
4184
  "--project <id-or-name>",
3753
4185
  "Project name or ID (defaults to the most recently updated project)"
3754
4186
  )
3755
4187
  ).action(async (options, command) => {
3756
4188
  const globalOptions = getGlobalOptions(command);
3757
- const result = await runPlatformCommand(
4189
+ const result = await runPlatformCommand2(
3758
4190
  options,
3759
4191
  globalOptions.timeout,
3760
4192
  ({ client, signal }) => listEvalSuitesOperation.execute(
@@ -3764,7 +4196,7 @@ function registerEvalCommands(program) {
3764
4196
  );
3765
4197
  writeResult(result, globalOptions.format);
3766
4198
  });
3767
- addPlatformOptions(
4199
+ addPlatformOptions2(
3768
4200
  evals.command("run").description("Start an eval run of an existing suite (asynchronous)").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option(
3769
4201
  "--project <id-or-name>",
3770
4202
  "Project name or ID (defaults to the most recently updated project)"
@@ -3775,7 +4207,7 @@ function registerEvalCommands(program) {
3775
4207
  ).action(
3776
4208
  async (options, command) => {
3777
4209
  const globalOptions = getGlobalOptions(command);
3778
- const result = await runPlatformCommand(
4210
+ const result = await runPlatformCommand2(
3779
4211
  options,
3780
4212
  globalOptions.timeout,
3781
4213
  ({ client, signal }) => runEvalSuiteOperation.execute(
@@ -3790,12 +4222,12 @@ function registerEvalCommands(program) {
3790
4222
  writeResult(result, globalOptions.format);
3791
4223
  }
3792
4224
  );
3793
- addPlatformOptions(
4225
+ addPlatformOptions2(
3794
4226
  evals.command("status").description("Get the status and summary of an eval run").requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption("--project <id-or-name>", "Project name or ID")
3795
4227
  ).action(
3796
4228
  async (options, command) => {
3797
4229
  const globalOptions = getGlobalOptions(command);
3798
- const result = await runPlatformCommand(
4230
+ const result = await runPlatformCommand2(
3799
4231
  options,
3800
4232
  globalOptions.timeout,
3801
4233
  ({ client, signal }) => getEvalRunOperation.execute(
@@ -3806,7 +4238,7 @@ function registerEvalCommands(program) {
3806
4238
  writeResult(result, globalOptions.format);
3807
4239
  }
3808
4240
  );
3809
- addPlatformOptions(
4241
+ addPlatformOptions2(
3810
4242
  evals.command("cancel").description(
3811
4243
  "Cancel an in-flight eval run (no-op if already cancelled; errors if it already finished)"
3812
4244
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption("--project <id-or-name>", "Project name or ID")
@@ -3821,7 +4253,7 @@ function registerEvalCommands(program) {
3821
4253
  }
3822
4254
  );
3823
4255
  const PROJECT_OPT = "Project name or ID (defaults to most recently updated)";
3824
- addPlatformOptions(
4256
+ addPlatformOptions2(
3825
4257
  evals.command("iterations").description(
3826
4258
  "List per-iteration results for an eval run (pass/fail, tool calls, tokens, latency)"
3827
4259
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
@@ -3839,7 +4271,7 @@ function registerEvalCommands(program) {
3839
4271
  await executeOp(listEvalRunIterationsOperation, input, options, command);
3840
4272
  }
3841
4273
  );
3842
- addPlatformOptions(
4274
+ addPlatformOptions2(
3843
4275
  evals.command("trace").description(
3844
4276
  "Fetch the full trace for one eval iteration (large: full message history + spans)"
3845
4277
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
@@ -3863,7 +4295,7 @@ function registerEvalCommands(program) {
3863
4295
  );
3864
4296
  }
3865
4297
  );
3866
- addPlatformOptions(
4298
+ addPlatformOptions2(
3867
4299
  evals.command("steps").description(
3868
4300
  "Per-authored-step results for one eval iteration: status (ok/fail/skipped/pending), reason, and evidence (screenshot/video URLs). The fastest way to see WHICH step failed and why."
3869
4301
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
@@ -3887,7 +4319,7 @@ function registerEvalCommands(program) {
3887
4319
  );
3888
4320
  }
3889
4321
  );
3890
- addPlatformOptions(
4322
+ addPlatformOptions2(
3891
4323
  evals.command("screenshot").description(
3892
4324
  "Show the widget screenshot(s) an eval iteration rendered \u2014 inline when the terminal supports it, otherwise the image URL"
3893
4325
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
@@ -3904,7 +4336,7 @@ function registerEvalCommands(program) {
3904
4336
  async (options, command) => {
3905
4337
  const globalOptions = getGlobalOptions(command);
3906
4338
  const index = options.index !== void 0 ? parsePositiveInteger(options.index, "--index") : void 0;
3907
- const result = await runPlatformCommand(
4339
+ const result = await runPlatformCommand2(
3908
4340
  options,
3909
4341
  globalOptions.timeout,
3910
4342
  ({ client, signal }) => getEvalIterationTraceOperation.execute(
@@ -3995,7 +4427,7 @@ function registerEvalCommands(program) {
3995
4427
  }
3996
4428
  }
3997
4429
  );
3998
- addPlatformOptions(
4430
+ addPlatformOptions2(
3999
4431
  evals.command("video").description(
4000
4432
  "Get the Playwright replay video (.webm) an eval iteration recorded \u2014 prints the URL, or downloads it with --out"
4001
4433
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
@@ -4008,7 +4440,7 @@ function registerEvalCommands(program) {
4008
4440
  ).action(
4009
4441
  async (options, command) => {
4010
4442
  const globalOptions = getGlobalOptions(command);
4011
- const result = await runPlatformCommand(
4443
+ const result = await runPlatformCommand2(
4012
4444
  options,
4013
4445
  globalOptions.timeout,
4014
4446
  ({ client, signal }) => getEvalIterationTraceOperation.execute(
@@ -4059,7 +4491,7 @@ function registerEvalCommands(program) {
4059
4491
  `);
4060
4492
  }
4061
4493
  );
4062
- addPlatformOptions(
4494
+ addPlatformOptions2(
4063
4495
  evals.command("get").description("Show an eval suite's full settings").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT)
4064
4496
  ).action(
4065
4497
  async (options, command) => {
@@ -4071,7 +4503,7 @@ function registerEvalCommands(program) {
4071
4503
  );
4072
4504
  }
4073
4505
  );
4074
- addPlatformOptions(
4506
+ addPlatformOptions2(
4075
4507
  evals.command("update").description(
4076
4508
  "Edit an eval suite's settings (only the flags you pass change)"
4077
4509
  ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--file <path>", "Suite-update JSON body (or - for stdin)").option("--json <json>", "Inline suite-update JSON (or @file, or -)").option("--name <name>", "Rename the suite").option("--description <text>", "Suite description").option(
@@ -4085,7 +4517,7 @@ function registerEvalCommands(program) {
4085
4517
  );
4086
4518
  await executeOp(updateEvalSuiteOperation, input, options, command);
4087
4519
  });
4088
- addPlatformOptions(
4520
+ addPlatformOptions2(
4089
4521
  evals.command("delete").description("Permanently delete an eval suite (and its cases and runs)").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT)
4090
4522
  ).action(
4091
4523
  async (options, command) => {
@@ -4097,7 +4529,7 @@ function registerEvalCommands(program) {
4097
4529
  );
4098
4530
  }
4099
4531
  );
4100
- addPlatformOptions(
4532
+ addPlatformOptions2(
4101
4533
  evals.command("schedule").description("Enable or disable scheduled runs for a suite").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--enable", "Enable scheduled runs").option("--disable", "Disable scheduled runs").option("--interval <minutes>", "Run interval in minutes (5\u201310080)")
4102
4534
  ).action(
4103
4535
  async (options, command) => {
@@ -4117,7 +4549,7 @@ function registerEvalCommands(program) {
4117
4549
  }
4118
4550
  );
4119
4551
  const cases = evals.command("cases").description("List, author, and edit an eval suite's test cases");
4120
- addPlatformOptions(
4552
+ addPlatformOptions2(
4121
4553
  cases.command("list").description("List a suite's test cases").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT)
4122
4554
  ).action(
4123
4555
  async (options, command) => {
@@ -4129,7 +4561,7 @@ function registerEvalCommands(program) {
4129
4561
  );
4130
4562
  }
4131
4563
  );
4132
- addPlatformOptions(
4564
+ addPlatformOptions2(
4133
4565
  cases.command("get").description("Show one test case").requiredOption("--suite <id-or-name>", "Eval suite name or ID").requiredOption("--case <id-or-title>", "Eval case title or ID").option("--project <id-or-name>", PROJECT_OPT)
4134
4566
  ).action(
4135
4567
  async (options, command) => {
@@ -4141,7 +4573,7 @@ function registerEvalCommands(program) {
4141
4573
  );
4142
4574
  }
4143
4575
  );
4144
- addPlatformOptions(
4576
+ addPlatformOptions2(
4145
4577
  cases.command("run").description(
4146
4578
  "Run a single case as a persisted, fully-queryable run (inspect it with `eval iterations` / `eval steps` like any run)"
4147
4579
  ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").requiredOption("--case <id-or-title>", "Eval case title or ID").option("--project <id-or-name>", PROJECT_OPT).option(
@@ -4163,7 +4595,7 @@ function registerEvalCommands(program) {
4163
4595
  );
4164
4596
  }
4165
4597
  );
4166
- addPlatformOptions(
4598
+ addPlatformOptions2(
4167
4599
  cases.command("create").description("Add a test case to a suite (definition via --file/--json)").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--file <path>", "Case JSON body (or - for stdin)").option("--json <json>", "Inline case JSON (or @file, or -)").option("--title <title>", "Case title (overrides the body)")
4168
4600
  ).action(async (options, command) => {
4169
4601
  const input = validateOpInput(
@@ -4172,7 +4604,7 @@ function registerEvalCommands(program) {
4172
4604
  );
4173
4605
  await executeOp(createEvalCaseOperation, input, options, command);
4174
4606
  });
4175
- addPlatformOptions(
4607
+ addPlatformOptions2(
4176
4608
  cases.command("update").description("Edit a test case (definition via --file/--json)").requiredOption("--suite <id-or-name>", "Eval suite name or ID").requiredOption("--case <id-or-title>", "Eval case title or ID").option("--project <id-or-name>", PROJECT_OPT).option("--file <path>", "Case JSON body (or - for stdin)").option("--json <json>", "Inline case JSON (or @file, or -)").option("--title <title>", "Rename the case")
4177
4609
  ).action(async (options, command) => {
4178
4610
  const input = validateOpInput(
@@ -4181,7 +4613,7 @@ function registerEvalCommands(program) {
4181
4613
  );
4182
4614
  await executeOp(updateEvalCaseOperation, input, options, command);
4183
4615
  });
4184
- addPlatformOptions(
4616
+ addPlatformOptions2(
4185
4617
  cases.command("delete").description("Permanently delete a test case").requiredOption("--suite <id-or-name>", "Eval suite name or ID").requiredOption("--case <id-or-title>", "Eval case title or ID").option("--project <id-or-name>", PROJECT_OPT)
4186
4618
  ).action(
4187
4619
  async (options, command) => {
@@ -4193,7 +4625,7 @@ function registerEvalCommands(program) {
4193
4625
  );
4194
4626
  }
4195
4627
  );
4196
- addPlatformOptions(
4628
+ addPlatformOptions2(
4197
4629
  cases.command("generate").description(
4198
4630
  "AI-generate test cases from the suite's tools (spends credits)"
4199
4631
  ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--mode <normal|negative>", "Generation mode (default normal)").option(
@@ -4242,13 +4674,13 @@ function registerEvalCommands(program) {
4242
4674
  );
4243
4675
  }
4244
4676
  var HOST_TEMPLATES = HOST_TEMPLATES$1.map(({ id, label }) => ({ id, label }));
4245
- function addPlatformOptions2(command) {
4677
+ function addPlatformOptions3(command) {
4246
4678
  return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
4247
4679
  "--api-url <url>",
4248
4680
  "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
4249
4681
  );
4250
4682
  }
4251
- async function runPlatformCommand2(options, timeoutMs, execute) {
4683
+ async function runPlatformCommand3(options, timeoutMs, execute) {
4252
4684
  const controller = new AbortController();
4253
4685
  const timeoutHandle = setTimeout(() => {
4254
4686
  controller.abort(
@@ -4308,26 +4740,26 @@ function registerHostsCommands(program) {
4308
4740
  const globalOptions = getGlobalOptions(command);
4309
4741
  writeResult({ items: HOST_TEMPLATES }, globalOptions.format);
4310
4742
  });
4311
- addPlatformOptions2(
4743
+ addPlatformOptions3(
4312
4744
  hosts.command("list").description("List the hosts saved in a project").option(
4313
4745
  "--project <id-or-name>",
4314
4746
  "Project name or ID (defaults to the most recently updated project)"
4315
4747
  )
4316
4748
  ).action(async (options, command) => {
4317
4749
  const globalOptions = getGlobalOptions(command);
4318
- const result = await runPlatformCommand2(
4750
+ const result = await runPlatformCommand3(
4319
4751
  options,
4320
4752
  globalOptions.timeout,
4321
4753
  ({ client, signal }) => listHostsOperation.execute({ project: options.project }, { client, signal })
4322
4754
  );
4323
4755
  writeResult(result, globalOptions.format);
4324
4756
  });
4325
- addPlatformOptions2(
4757
+ addPlatformOptions3(
4326
4758
  hosts.command("get").description("Show one host's full settings, including its host config").requiredOption("--host <id-or-name>", "Host name or ID").option("--project <id-or-name>", "Project name or ID")
4327
4759
  ).action(
4328
4760
  async (options, command) => {
4329
4761
  const globalOptions = getGlobalOptions(command);
4330
- const result = await runPlatformCommand2(
4762
+ const result = await runPlatformCommand3(
4331
4763
  options,
4332
4764
  globalOptions.timeout,
4333
4765
  ({ client, signal }) => getHostOperation.execute(
@@ -4338,7 +4770,7 @@ function registerHostsCommands(program) {
4338
4770
  writeResult(result, globalOptions.format);
4339
4771
  }
4340
4772
  );
4341
- addPlatformOptions2(
4773
+ addPlatformOptions3(
4342
4774
  hosts.command("create").description(
4343
4775
  "Create a host from a built-in template (--template) or a full host config (--file/--json)"
4344
4776
  ).requiredOption("--name <name>", "Display name for the new host").option("--project <id-or-name>", "Project name or ID").option(
@@ -4352,14 +4784,14 @@ function registerHostsCommands(program) {
4352
4784
  async (options, command) => {
4353
4785
  const globalOptions = getGlobalOptions(command);
4354
4786
  const config = loadConfigObject(options);
4355
- const input = validateInput(createHostOperation, {
4787
+ const input = validateInput2(createHostOperation, {
4356
4788
  project: options.project,
4357
4789
  name: options.name,
4358
4790
  ...options.template !== void 0 ? { template: options.template } : {},
4359
4791
  ...options.theme !== void 0 ? { theme: options.theme } : {},
4360
4792
  ...config !== void 0 ? { config } : {}
4361
4793
  });
4362
- const result = await runPlatformCommand2(
4794
+ const result = await runPlatformCommand3(
4363
4795
  options,
4364
4796
  globalOptions.timeout,
4365
4797
  ({ client, signal }) => createHostOperation.execute(input, { client, signal })
@@ -4367,19 +4799,19 @@ function registerHostsCommands(program) {
4367
4799
  writeResult(result, globalOptions.format);
4368
4800
  }
4369
4801
  );
4370
- addPlatformOptions2(
4802
+ addPlatformOptions3(
4371
4803
  hosts.command("update").description("Edit a host's name and/or its host config").requiredOption("--host <id-or-name>", "Host name or ID").option("--project <id-or-name>", "Project name or ID").option("--name <name>", "New display name").option("--file <path>", "Replacement host config v2 JSON (or - for stdin)").option("--json <json>", "Inline replacement host config v2 JSON (or @file, or -)")
4372
4804
  ).action(
4373
4805
  async (options, command) => {
4374
4806
  const globalOptions = getGlobalOptions(command);
4375
4807
  const config = loadConfigObject(options);
4376
- const input = validateInput(updateHostOperation, {
4808
+ const input = validateInput2(updateHostOperation, {
4377
4809
  project: options.project,
4378
4810
  host: options.host,
4379
4811
  ...options.name !== void 0 ? { name: options.name } : {},
4380
4812
  ...config !== void 0 ? { config } : {}
4381
4813
  });
4382
- const result = await runPlatformCommand2(
4814
+ const result = await runPlatformCommand3(
4383
4815
  options,
4384
4816
  globalOptions.timeout,
4385
4817
  ({ client, signal }) => updateHostOperation.execute(input, { client, signal })
@@ -4387,12 +4819,12 @@ function registerHostsCommands(program) {
4387
4819
  writeResult(result, globalOptions.format);
4388
4820
  }
4389
4821
  );
4390
- addPlatformOptions2(
4822
+ addPlatformOptions3(
4391
4823
  hosts.command("delete").description("Permanently delete a host from a project").requiredOption("--host <id-or-name>", "Host name or ID").option("--project <id-or-name>", "Project name or ID")
4392
4824
  ).action(
4393
4825
  async (options, command) => {
4394
4826
  const globalOptions = getGlobalOptions(command);
4395
- const result = await runPlatformCommand2(
4827
+ const result = await runPlatformCommand3(
4396
4828
  options,
4397
4829
  globalOptions.timeout,
4398
4830
  ({ client, signal }) => deleteHostOperation.execute(
@@ -4407,7 +4839,7 @@ function registerHostsCommands(program) {
4407
4839
  }
4408
4840
  );
4409
4841
  }
4410
- function validateInput(op, raw) {
4842
+ function validateInput2(op, raw) {
4411
4843
  const parsed = op.inputSchema.safeParse(raw);
4412
4844
  if (!parsed.success) {
4413
4845
  const detail = parsed.error.issues.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ");
@@ -5166,13 +5598,13 @@ function statusGlyph(status) {
5166
5598
  }
5167
5599
 
5168
5600
  // src/commands/projects.ts
5169
- function addPlatformOptions3(command) {
5601
+ function addPlatformOptions4(command) {
5170
5602
  return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
5171
5603
  "--api-url <url>",
5172
5604
  "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
5173
5605
  );
5174
5606
  }
5175
- async function runPlatformCommand3(options, timeoutMs, execute) {
5607
+ async function runPlatformCommand4(options, timeoutMs, execute) {
5176
5608
  const controller = new AbortController();
5177
5609
  const timeoutHandle = setTimeout(() => {
5178
5610
  controller.abort(
@@ -5200,11 +5632,11 @@ async function runPlatformCommand3(options, timeoutMs, execute) {
5200
5632
  }
5201
5633
  function registerProjectsCommands(program) {
5202
5634
  const projects = program.command("projects").description("Operate the MCP servers saved in your hosted MCPJam projects");
5203
- addPlatformOptions3(
5635
+ addPlatformOptions4(
5204
5636
  projects.command("list").description("List the projects you can access")
5205
5637
  ).action(async (options, command) => {
5206
5638
  const globalOptions = getGlobalOptions(command);
5207
- const result = await runPlatformCommand3(
5639
+ const result = await runPlatformCommand4(
5208
5640
  options,
5209
5641
  globalOptions.timeout,
5210
5642
  ({ client, signal }) => listProjectsOperation.execute({}, { client, signal })
@@ -5216,14 +5648,14 @@ function registerProjectsCommands(program) {
5216
5648
  writeResult(result, globalOptions.format);
5217
5649
  }
5218
5650
  });
5219
- addPlatformOptions3(
5651
+ addPlatformOptions4(
5220
5652
  projects.command("servers").description("List the servers saved in a project").option(
5221
5653
  "--project <id-or-name>",
5222
5654
  "Project name or ID (defaults to the most recently updated project)"
5223
5655
  )
5224
5656
  ).action(async (options, command) => {
5225
5657
  const globalOptions = getGlobalOptions(command);
5226
- const result = await runPlatformCommand3(
5658
+ const result = await runPlatformCommand4(
5227
5659
  options,
5228
5660
  globalOptions.timeout,
5229
5661
  ({ client, signal }) => listProjectServersOperation.execute(
@@ -5238,7 +5670,7 @@ function registerProjectsCommands(program) {
5238
5670
  writeResult(result, globalOptions.format);
5239
5671
  }
5240
5672
  });
5241
- addPlatformOptions3(
5673
+ addPlatformOptions4(
5242
5674
  projects.command("status").description(
5243
5675
  "Health-check every server in a project (hosted doctor per server)"
5244
5676
  ).option(
@@ -5247,7 +5679,7 @@ function registerProjectsCommands(program) {
5247
5679
  )
5248
5680
  ).action(async (options, command) => {
5249
5681
  const globalOptions = getGlobalOptions(command);
5250
- const payload = await runPlatformCommand3(
5682
+ const payload = await runPlatformCommand4(
5251
5683
  options,
5252
5684
  globalOptions.timeout,
5253
5685
  ({ client, signal }) => showServersOperation.execute(
@@ -6111,26 +6543,18 @@ function statusToErrorCode(status) {
6111
6543
  if (status === 504) return "TIMEOUT";
6112
6544
  return "INTERNAL_ERROR";
6113
6545
  }
6114
- async function withEphemeralManager(config, fn, options) {
6115
- return withEphemeralClient(config, fn, {
6116
- serverId: "__cli__",
6117
- clientName: "mcpjam",
6118
- timeout: options?.timeout ?? 3e4,
6119
- rpcLogger: options?.rpcLogger,
6120
- retryPolicy: options?.retryPolicy
6121
- });
6122
- }
6123
-
6124
- // src/commands/prompts.ts
6125
6546
  function registerPromptCommands(program) {
6126
6547
  const prompts = program.command("prompts").description("List and fetch MCP prompts");
6127
- addRetryOptions(
6128
- addSharedServerOptions(
6129
- prompts.command("list").description("List prompts exposed by an MCP server").option("--cursor <cursor>", "Pagination cursor")
6548
+ addHostOption(
6549
+ addRetryOptions(
6550
+ addSharedServerOptions(
6551
+ prompts.command("list").description("List prompts exposed by an MCP server").option("--cursor <cursor>", "Pagination cursor")
6552
+ )
6130
6553
  )
6131
6554
  ).action(async (options, command) => {
6132
6555
  const globalOptions = getGlobalOptions(command);
6133
6556
  const retryPolicy = parseRetryPolicy(options);
6557
+ const host = resolveHostFromOptions(options);
6134
6558
  const target = describeTarget(options);
6135
6559
  const collector = globalOptions.rpc ? createCliRpcLogCollector({ __cli__: target }) : void 0;
6136
6560
  const config = parseServerConfig({
@@ -6143,7 +6567,8 @@ function registerPromptCommands(program) {
6143
6567
  {
6144
6568
  timeout: globalOptions.timeout,
6145
6569
  rpcLogger: collector?.rpcLogger,
6146
- retryPolicy
6570
+ retryPolicy,
6571
+ host: host?.connection
6147
6572
  }
6148
6573
  );
6149
6574
  writeResult(
@@ -6151,16 +6576,19 @@ function registerPromptCommands(program) {
6151
6576
  globalOptions.format
6152
6577
  );
6153
6578
  });
6154
- addRetryOptions(
6155
- addSharedServerOptions(
6156
- prompts.command("get").description("Get a named prompt from an MCP server").option("--prompt-name <prompt>", "Prompt name").option("--name <prompt>", "Alias for --prompt-name").option(
6157
- "--prompt-args <json>",
6158
- "Prompt arguments as JSON, @path, or - for stdin"
6579
+ addHostOption(
6580
+ addRetryOptions(
6581
+ addSharedServerOptions(
6582
+ prompts.command("get").description("Get a named prompt from an MCP server").option("--prompt-name <prompt>", "Prompt name").option("--name <prompt>", "Alias for --prompt-name").option(
6583
+ "--prompt-args <json>",
6584
+ "Prompt arguments as JSON, @path, or - for stdin"
6585
+ )
6159
6586
  )
6160
6587
  )
6161
6588
  ).action(async (options, command) => {
6162
6589
  const globalOptions = getGlobalOptions(command);
6163
6590
  const retryPolicy = parseRetryPolicy(options);
6591
+ const host = resolveHostFromOptions(options);
6164
6592
  const target = describeTarget(options);
6165
6593
  const collector = globalOptions.rpc ? createCliRpcLogCollector({ __cli__: target }) : void 0;
6166
6594
  const promptName = resolveAliasedStringOption(
@@ -6187,7 +6615,8 @@ function registerPromptCommands(program) {
6187
6615
  {
6188
6616
  timeout: globalOptions.timeout,
6189
6617
  rpcLogger: collector?.rpcLogger,
6190
- retryPolicy
6618
+ retryPolicy,
6619
+ host: host?.connection
6191
6620
  }
6192
6621
  );
6193
6622
  writeResult(
@@ -6198,13 +6627,16 @@ function registerPromptCommands(program) {
6198
6627
  }
6199
6628
  function registerResourcesCommands(program) {
6200
6629
  const resources = program.command("resources").description("List and read MCP resources");
6201
- addRetryOptions(
6202
- addSharedServerOptions(
6203
- resources.command("list").description("List resources exposed by an MCP server").option("--cursor <cursor>", "Pagination cursor")
6630
+ addHostOption(
6631
+ addRetryOptions(
6632
+ addSharedServerOptions(
6633
+ resources.command("list").description("List resources exposed by an MCP server").option("--cursor <cursor>", "Pagination cursor")
6634
+ )
6204
6635
  )
6205
6636
  ).action(async (options, command) => {
6206
6637
  const globalOptions = getGlobalOptions(command);
6207
6638
  const retryPolicy = parseRetryPolicy(options);
6639
+ const host = resolveHostFromOptions(options);
6208
6640
  const target = describeTarget(options);
6209
6641
  const collector = globalOptions.rpc ? createCliRpcLogCollector({ __cli__: target }) : void 0;
6210
6642
  const config = parseServerConfig({
@@ -6217,7 +6649,8 @@ function registerResourcesCommands(program) {
6217
6649
  {
6218
6650
  timeout: globalOptions.timeout,
6219
6651
  rpcLogger: collector?.rpcLogger,
6220
- retryPolicy
6652
+ retryPolicy,
6653
+ host: host?.connection
6221
6654
  }
6222
6655
  );
6223
6656
  writeResult(
@@ -6225,13 +6658,16 @@ function registerResourcesCommands(program) {
6225
6658
  globalOptions.format
6226
6659
  );
6227
6660
  });
6228
- addRetryOptions(
6229
- addSharedServerOptions(
6230
- resources.command("read").description("Read a resource from an MCP server").option("--resource-uri <uri>", "Resource URI").option("--uri <uri>", "Alias for --resource-uri")
6661
+ addHostOption(
6662
+ addRetryOptions(
6663
+ addSharedServerOptions(
6664
+ resources.command("read").description("Read a resource from an MCP server").option("--resource-uri <uri>", "Resource URI").option("--uri <uri>", "Alias for --resource-uri")
6665
+ )
6231
6666
  )
6232
6667
  ).action(async (options, command) => {
6233
6668
  const globalOptions = getGlobalOptions(command);
6234
6669
  const retryPolicy = parseRetryPolicy(options);
6670
+ const host = resolveHostFromOptions(options);
6235
6671
  const target = describeTarget(options);
6236
6672
  const collector = globalOptions.rpc ? createCliRpcLogCollector({ __cli__: target }) : void 0;
6237
6673
  const resourceUri = resolveAliasedStringOption(
@@ -6253,7 +6689,8 @@ function registerResourcesCommands(program) {
6253
6689
  {
6254
6690
  timeout: globalOptions.timeout,
6255
6691
  rpcLogger: collector?.rpcLogger,
6256
- retryPolicy
6692
+ retryPolicy,
6693
+ host: host?.connection
6257
6694
  }
6258
6695
  );
6259
6696
  writeResult(
@@ -6261,13 +6698,16 @@ function registerResourcesCommands(program) {
6261
6698
  globalOptions.format
6262
6699
  );
6263
6700
  });
6264
- addRetryOptions(
6265
- addSharedServerOptions(
6266
- resources.command("templates").description("List resource templates exposed by an MCP server").option("--cursor <cursor>", "Pagination cursor")
6701
+ addHostOption(
6702
+ addRetryOptions(
6703
+ addSharedServerOptions(
6704
+ resources.command("templates").description("List resource templates exposed by an MCP server").option("--cursor <cursor>", "Pagination cursor")
6705
+ )
6267
6706
  )
6268
6707
  ).action(async (options, command) => {
6269
6708
  const globalOptions = getGlobalOptions(command);
6270
6709
  const retryPolicy = parseRetryPolicy(options);
6710
+ const host = resolveHostFromOptions(options);
6271
6711
  const target = describeTarget(options);
6272
6712
  const collector = globalOptions.rpc ? createCliRpcLogCollector({ __cli__: target }) : void 0;
6273
6713
  const config = parseServerConfig({
@@ -6283,7 +6723,8 @@ function registerResourcesCommands(program) {
6283
6723
  {
6284
6724
  timeout: globalOptions.timeout,
6285
6725
  rpcLogger: collector?.rpcLogger,
6286
- retryPolicy
6726
+ retryPolicy,
6727
+ host: host?.connection
6287
6728
  }
6288
6729
  );
6289
6730
  writeResult(
@@ -7458,13 +7899,16 @@ function writeTelemetryStatus(status, format) {
7458
7899
  }
7459
7900
  function registerToolsCommands(program) {
7460
7901
  const tools = program.command("tools").description("List and invoke MCP server tools");
7461
- addRetryOptions(
7462
- addSharedServerOptions(
7463
- tools.command("list").description("List tools exposed by an MCP server").option("--cursor <cursor>", "Pagination cursor").option("--model-id <model>", "Model id used for token counting")
7902
+ addHostOption(
7903
+ addRetryOptions(
7904
+ addSharedServerOptions(
7905
+ tools.command("list").description("List tools exposed by an MCP server").option("--cursor <cursor>", "Pagination cursor").option("--model-id <model>", "Model id used for token counting")
7906
+ )
7464
7907
  )
7465
7908
  ).action(async (options, command) => {
7466
7909
  const globalOptions = getGlobalOptions(command);
7467
7910
  const retryPolicy = parseRetryPolicy(options);
7911
+ const host = resolveHostFromOptions(options);
7468
7912
  const target = describeTarget(options);
7469
7913
  const collector = globalOptions.rpc ? createCliRpcLogCollector({ __cli__: target }) : void 0;
7470
7914
  const config = parseServerConfig({
@@ -7473,15 +7917,40 @@ function registerToolsCommands(program) {
7473
7917
  });
7474
7918
  const result = await withEphemeralManager(
7475
7919
  config,
7476
- (manager, serverId) => listToolsWithMetadata(manager, {
7477
- serverId,
7478
- cursor: options.cursor,
7479
- modelId: options.modelId
7480
- }),
7920
+ async (manager, serverId) => {
7921
+ const listed = await listToolsWithMetadata(manager, {
7922
+ serverId,
7923
+ cursor: options.cursor,
7924
+ modelId: options.modelId
7925
+ });
7926
+ if (!host) return listed;
7927
+ const { tools: visibleTools, toolsDroppedVisibility } = applyHostVisibility(
7928
+ listed.tools,
7929
+ manager,
7930
+ serverId,
7931
+ host.policy
7932
+ );
7933
+ const visibleNames = new Set(
7934
+ visibleTools.map((tool) => String(tool.name))
7935
+ );
7936
+ return {
7937
+ ...listed,
7938
+ tools: visibleTools,
7939
+ toolsMetadata: Object.fromEntries(
7940
+ Object.entries(listed.toolsMetadata).filter(
7941
+ ([name]) => visibleNames.has(name)
7942
+ )
7943
+ ),
7944
+ ...listed.tokenCount === void 0 ? {} : { tokenCount: estimateTokensFromChars(JSON.stringify(visibleTools)) },
7945
+ host: host.id,
7946
+ toolsDroppedVisibility
7947
+ };
7948
+ },
7481
7949
  {
7482
7950
  timeout: globalOptions.timeout,
7483
7951
  rpcLogger: collector?.rpcLogger,
7484
- retryPolicy
7952
+ retryPolicy,
7953
+ host: host?.connection
7485
7954
  }
7486
7955
  );
7487
7956
  writeResult(
@@ -7489,52 +7958,55 @@ function registerToolsCommands(program) {
7489
7958
  globalOptions.format
7490
7959
  );
7491
7960
  });
7492
- addSharedServerOptions(
7493
- tools.command("call").description("Call an MCP tool").option("--tool-name <tool>", "Tool name").option("--name <tool>", "Alias for --tool-name").option(
7494
- "--tool-args <json>",
7495
- "Tool parameter object as JSON, @path, or - for stdin"
7496
- ).option("--params <json>", "Alias for --tool-args").option("--tool-args-stdin", "Read tool parameter JSON from stdin").option(
7497
- "--validate-response",
7498
- "Validate the MCP tool-call envelope returned by the server"
7499
- ).option(
7500
- "--expect-success",
7501
- "Evaluate the tool-call outcome policy against isError"
7502
- ).option(
7503
- "--reporter <reporter>",
7504
- "Structured reporter output: json-summary or junit-xml"
7505
- ).option(
7506
- "--debug-out <path>",
7507
- "Write a structured debug artifact to a file"
7508
- ).option(
7509
- "--ui",
7510
- "Render the tool result in Inspector Playground; opens a browser by default in a TTY"
7511
- ).option(
7512
- "--require-render",
7513
- "Treat skipped Inspector renders as errors (with --ui)"
7514
- ).option(
7515
- "--open",
7516
- "Open Inspector in the system browser before rendering (default with --ui in a TTY)"
7517
- ).option(
7518
- "--no-open",
7519
- "Start/use Inspector without opening a system browser"
7520
- ).option(
7521
- "--attach-only",
7522
- "Require an already-running Inspector browser client; do not start or open Inspector"
7523
- ).option("--inspector-url <url>", "Local Inspector base URL (with --ui)").option(
7524
- "--frontend-url <url>",
7525
- "Inspector frontend URL (with --ui; overrides health-advertised frontend and skips discovery)"
7526
- ).option(
7527
- "--server-name <name>",
7528
- "Server name inside Inspector (with --ui)"
7529
- ).option(
7530
- "--protocol <protocol>",
7531
- 'Render protocol: "mcp-apps" or "openai-sdk" (with --ui)'
7532
- ).option(
7533
- "--device <device>",
7534
- 'Render device: "mobile", "tablet", "desktop", or "custom" (with --ui)'
7535
- ).option("--theme <theme>", 'Render theme: "light" or "dark" (with --ui)').option("--locale <locale>", "Render locale (with --ui)").option("--time-zone <iana>", "Render IANA timezone (with --ui)")
7961
+ addHostOption(
7962
+ addSharedServerOptions(
7963
+ tools.command("call").description("Call an MCP tool").option("--tool-name <tool>", "Tool name").option("--name <tool>", "Alias for --tool-name").option(
7964
+ "--tool-args <json>",
7965
+ "Tool parameter object as JSON, @path, or - for stdin"
7966
+ ).option("--params <json>", "Alias for --tool-args").option("--tool-args-stdin", "Read tool parameter JSON from stdin").option(
7967
+ "--validate-response",
7968
+ "Validate the MCP tool-call envelope returned by the server"
7969
+ ).option(
7970
+ "--expect-success",
7971
+ "Evaluate the tool-call outcome policy against isError"
7972
+ ).option(
7973
+ "--reporter <reporter>",
7974
+ "Structured reporter output: json-summary or junit-xml"
7975
+ ).option(
7976
+ "--debug-out <path>",
7977
+ "Write a structured debug artifact to a file"
7978
+ ).option(
7979
+ "--ui",
7980
+ "Render the tool result in Inspector Playground; opens a browser by default in a TTY"
7981
+ ).option(
7982
+ "--require-render",
7983
+ "Treat skipped Inspector renders as errors (with --ui)"
7984
+ ).option(
7985
+ "--open",
7986
+ "Open Inspector in the system browser before rendering (default with --ui in a TTY)"
7987
+ ).option(
7988
+ "--no-open",
7989
+ "Start/use Inspector without opening a system browser"
7990
+ ).option(
7991
+ "--attach-only",
7992
+ "Require an already-running Inspector browser client; do not start or open Inspector"
7993
+ ).option("--inspector-url <url>", "Local Inspector base URL (with --ui)").option(
7994
+ "--frontend-url <url>",
7995
+ "Inspector frontend URL (with --ui; overrides health-advertised frontend and skips discovery)"
7996
+ ).option(
7997
+ "--server-name <name>",
7998
+ "Server name inside Inspector (with --ui)"
7999
+ ).option(
8000
+ "--protocol <protocol>",
8001
+ 'Render protocol: "mcp-apps" or "openai-sdk" (with --ui)'
8002
+ ).option(
8003
+ "--device <device>",
8004
+ 'Render device: "mobile", "tablet", "desktop", or "custom" (with --ui)'
8005
+ ).option("--theme <theme>", 'Render theme: "light" or "dark" (with --ui)').option("--locale <locale>", "Render locale (with --ui)").option("--time-zone <iana>", "Render IANA timezone (with --ui)")
8006
+ )
7536
8007
  ).action(async (options, command) => {
7537
8008
  const globalOptions = getGlobalOptions(command);
8009
+ const host = resolveHostFromOptions(options);
7538
8010
  const target = describeTarget(options);
7539
8011
  const primaryCollector = globalOptions.rpc || options.debugOut ? createCliRpcLogCollector({ __cli__: target }) : void 0;
7540
8012
  const snapshotCollector = options.debugOut ? createCliRpcLogCollector({ __cli__: target }) : void 0;
@@ -7598,10 +8070,14 @@ function registerToolsCommands(program) {
7598
8070
  try {
7599
8071
  result = await withEphemeralManager(
7600
8072
  config,
7601
- (manager, serverId) => manager.executeTool(serverId, toolName, params),
8073
+ async (manager, serverId) => {
8074
+ if (host) await assertToolVisibleToHost(manager, serverId, toolName, host);
8075
+ return manager.executeTool(serverId, toolName, params);
8076
+ },
7602
8077
  {
7603
8078
  timeout: globalOptions.timeout,
7604
- rpcLogger: primaryCollector?.rpcLogger
8079
+ rpcLogger: primaryCollector?.rpcLogger,
8080
+ host: host?.connection
7605
8081
  }
7606
8082
  );
7607
8083
  } catch (error) {
@@ -9125,6 +9601,7 @@ async function main(argv = process.argv, dependencies = {}) {
9125
9601
  registerServerCommands(program);
9126
9602
  registerToolsCommands(program);
9127
9603
  registerResourcesCommands(program);
9604
+ registerCompatCommands(program);
9128
9605
  registerPromptCommands(program);
9129
9606
  registerAppsCommands(program);
9130
9607
  registerOAuthCommands(program);
@@ -9133,6 +9610,7 @@ async function main(argv = process.argv, dependencies = {}) {
9133
9610
  registerProjectsCommands(program);
9134
9611
  registerEvalCommands(program);
9135
9612
  registerHostsCommands(program);
9613
+ registerEnvironmentsCommands(program);
9136
9614
  registerTunnelCommands(program);
9137
9615
  registerInspectorCommands(program);
9138
9616
  registerMcpCommands(program);