@mcpjam/cli 3.16.0 → 3.18.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,7 +2,7 @@
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, SubscriptionCoordinator, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, MCPAppsConformanceSuite, MCPTasksConformanceTest, runOAuthLogin, OAuthConformanceTest, OAuthConformanceSuite, runXaaFlow, MCPConformanceTest, MCPConformanceSuite, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, DEFAULT_SUBSCRIPTION_RECONNECT_POLICY, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, normalizeRegistrationStrategy, normalizeXaaClientAuth, normalizeIdentityAssertionFormat, IDENTITY_ASSERTION_FORMATS, XAA_CONFIDENTIAL_CIMD_ORIGIN, getLocalConfidentialCimdProvider, isKnownProtocolVersion, MCP_PROTOCOL_VERSIONS, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, openUrlInBrowser, MCPClientManager, canDeclareTasksExtension, createStrictElicitationContentValidator, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, MCP_TASKS_CHECK_CATEGORIES, MCP_TASKS_CHECK_IDS, OAuthProxyError, isLoopbackHost, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS, TaskLifecycleEngine, driveTaskToTerminal, extensionTaskToObservation, legacyTaskToObservation, isUnknownTaskError, isMCPTasksWireError, LEGACY_TASK_STATUSES } from '@mcpjam/sdk';
5
+ import { probeMcpServer, redactSensitiveValue, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, classifyMcpHeader, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, SubscriptionCoordinator, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, MCPAppsConformanceSuite, MCPTasksConformanceTest, runOAuthLogin, OAuthConformanceTest, OAuthConformanceSuite, runXaaFlow, MCPConformanceTest, MCPConformanceSuite, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, DEFAULT_SUBSCRIPTION_RECONNECT_POLICY, isKnownProtocolVersion, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, normalizeRegistrationStrategy, normalizeXaaClientAuth, normalizeIdentityAssertionFormat, IDENTITY_ASSERTION_FORMATS, XAA_CONFIDENTIAL_CIMD_ORIGIN, getLocalConfidentialCimdProvider, MCP_PROTOCOL_VERSIONS, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, openUrlInBrowser, MCPClientManager, decodeMcpHeaderValue, canDeclareTasksExtension, createStrictElicitationContentValidator, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, MCP_TASKS_CHECK_CATEGORIES, MCP_TASKS_CHECK_IDS, OAuthProxyError, isLoopbackHost, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS, TaskLifecycleEngine, driveTaskToTerminal, extensionTaskToObservation, legacyTaskToObservation, isUnknownTaskError, isMCPTasksWireError, LEGACY_TASK_STATUSES } from '@mcpjam/sdk';
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';
@@ -25,7 +25,7 @@ import { WebSocket } from 'ws';
25
25
 
26
26
  // package.json
27
27
  var package_default = {
28
- version: "3.16.0"};
28
+ version: "3.18.0"};
29
29
 
30
30
  // src/lib/output.ts
31
31
  var DEFAULT_OUTPUT_FORMAT = "json";
@@ -841,6 +841,23 @@ function addHostOption(command) {
841
841
  "Connect as this host (e.g. claude, chatgpt, cursor) \u2014 sends its identity/capabilities/protocol and applies its tool visibility"
842
842
  );
843
843
  }
844
+ function addConformanceOptions(command) {
845
+ return command.option(
846
+ "--first-page-only",
847
+ "Read only the first page of paginated lists, like the real hosts that never follow nextCursor. On 2026-07-28 this also stops SEP-2243 Mcp-Param-* mirroring for tools past page one, because the mirroring source is the page-one-only list the client cached."
848
+ ).option(
849
+ "--no-mrtr",
850
+ "Do NOT drive MRTR (resultType: input_required) rounds \u2014 call as a client that never implemented the 2026 pattern. Stops advertising elicitation on a modern connection, so a server that would have elicited answers -32021 instead."
851
+ );
852
+ }
853
+ function conformanceConfigFromOptions(options) {
854
+ return {
855
+ ...options.firstPageOnly === true ? { firstPageOnly: true } : {},
856
+ // Commander defaults a `--no-x` flag to `true`, so only an explicit
857
+ // `false` means the user asked to disable MRTR.
858
+ ...options.mrtr === false ? { supportsMrtr: false } : {}
859
+ };
860
+ }
844
861
  function getGlobalOptions(command) {
845
862
  const options = command.optsWithGlobals();
846
863
  return {
@@ -2673,6 +2690,9 @@ function registerAppsCommands(program) {
2673
2690
  ).option(
2674
2691
  "--reporter <reporter>",
2675
2692
  "Structured reporter output: json-summary or junit-xml"
2693
+ ).option(
2694
+ "--protocol-version <version>",
2695
+ "Pin the MCP protocol version for the conformance connection (e.g. 2026-07-28). HTTP targets only."
2676
2696
  )
2677
2697
  ).action(async (options, command) => {
2678
2698
  const reporter = parseReporterFormat(options.reporter);
@@ -2978,8 +2998,22 @@ function buildAppsConformanceConfig(options) {
2978
2998
  )
2979
2999
  )
2980
3000
  ) : void 0;
3001
+ const trimmedProtocolVersion = options.protocolVersion?.trim();
3002
+ let mcpProtocolVersion;
3003
+ if (trimmedProtocolVersion) {
3004
+ if (!isKnownProtocolVersion(trimmedProtocolVersion)) {
3005
+ throw usageError(`Unknown --protocol-version: ${trimmedProtocolVersion}`);
3006
+ }
3007
+ if (!("url" in serverConfig) || !serverConfig.url) {
3008
+ throw usageError(
3009
+ "--protocol-version can only be used with an HTTP target (--url)."
3010
+ );
3011
+ }
3012
+ mcpProtocolVersion = trimmedProtocolVersion;
3013
+ }
2981
3014
  return {
2982
3015
  ...serverConfig,
3016
+ ...mcpProtocolVersion ? { mcpProtocolVersion } : {},
2983
3017
  ...resolvedCheckIds && resolvedCheckIds.length > 0 ? { checkIds: resolvedCheckIds } : {}
2984
3018
  };
2985
3019
  }
@@ -3436,8 +3470,20 @@ function applyHostToConfig(config, host) {
3436
3470
  ...host.clientCapabilities ? { clientCapabilities: host.clientCapabilities } : {},
3437
3471
  ...host.supportedProtocolVersions ? { supportedProtocolVersions: host.supportedProtocolVersions } : {}
3438
3472
  };
3439
- const httpOnly = "url" in config && host.mcpProtocolVersion ? { mcpProtocolVersion: host.mcpProtocolVersion } : {};
3440
- return { ...config, ...identity, ...httpOnly };
3473
+ const httpOnly = "url" in config ? {
3474
+ ...host.mcpProtocolVersion ? { mcpProtocolVersion: host.mcpProtocolVersion } : {},
3475
+ ...host.mirrorToolParamHeaders === false ? { mirrorToolParamHeaders: false } : {}
3476
+ } : {};
3477
+ const conformance = {
3478
+ ...host.firstPageOnly ? { firstPageOnly: true } : {},
3479
+ ...host.supportsMrtr === false ? { supportsMrtr: false } : {}
3480
+ };
3481
+ return {
3482
+ ...config,
3483
+ ...identity,
3484
+ ...httpOnly,
3485
+ ...conformance
3486
+ };
3441
3487
  }
3442
3488
  function applyHostVisibility(tools, manager, serverId, policy) {
3443
3489
  const record = {};
@@ -4549,8 +4595,11 @@ function registerEnvironmentsCommands(program) {
4549
4595
  environments.command("create").description(
4550
4596
  "Create a project environment (requires project admin). Body fields may be supplied via --file/--json"
4551
4597
  ).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(
4598
+ "--sandbox-image <id>",
4599
+ "Project-shared sandbox image (see `mcpjam images`) to pin: eval runs boot a fresh sandbox from it"
4600
+ ).option(
4552
4601
  "--file <path>",
4553
- "Environment JSON file with any of name/hostId/description/serverAttachmentId/skillSelection/pluginVersionIds (or - for stdin)"
4602
+ "Environment JSON file with any of name/hostId/description/serverAttachmentId/skillSelection/pluginVersionIds/sandboxImageId (or - for stdin)"
4554
4603
  ).option("--json <json>", "Inline environment JSON (or @file, or -)")
4555
4604
  ).action(
4556
4605
  async (options, command) => {
@@ -4561,7 +4610,8 @@ function registerEnvironmentsCommands(program) {
4561
4610
  ...options.project !== void 0 ? { project: options.project } : {},
4562
4611
  ...options.name !== void 0 ? { name: options.name } : {},
4563
4612
  ...options.hostId !== void 0 ? { hostId: options.hostId } : {},
4564
- ...options.description !== void 0 ? { description: options.description } : {}
4613
+ ...options.description !== void 0 ? { description: options.description } : {},
4614
+ ...options.sandboxImage !== void 0 ? { sandboxImageId: options.sandboxImage } : {}
4565
4615
  });
4566
4616
  const result = await runPlatformCommand2(
4567
4617
  options,
@@ -4573,13 +4623,16 @@ function registerEnvironmentsCommands(program) {
4573
4623
  );
4574
4624
  addPlatformOptions2(
4575
4625
  environments.command("update").description(
4576
- "Edit an environment. Only the fields you pass change; use --file/--json with a null value to clear serverAttachmentId, skillSelection, or pluginVersionIds"
4626
+ "Edit an environment. Only the fields you pass change; use --file/--json with a null value to clear serverAttachmentId, skillSelection, pluginVersionIds, or sandboxImageId"
4577
4627
  ).requiredOption("--environment <id-or-name>", "Environment name or ID").requiredOption(
4578
4628
  "--expected-revision <n>",
4579
4629
  "The revision you last read (from `environments get`); a stale value is rejected instead of overwriting a concurrent edit"
4580
4630
  ).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(
4581
4631
  "--description <text>",
4582
4632
  "New description (empty string clears it)"
4633
+ ).option(
4634
+ "--sandbox-image <id>",
4635
+ `New sandbox-image pin (clear via --json '{"sandboxImageId": null}')`
4583
4636
  ).option(
4584
4637
  "--file <path>",
4585
4638
  "Environment JSON file with the fields to change (or - for stdin)"
@@ -4595,7 +4648,8 @@ function registerEnvironmentsCommands(program) {
4595
4648
  expectedRevision: parseRevision(options.expectedRevision),
4596
4649
  ...options.name !== void 0 ? { name: options.name } : {},
4597
4650
  ...options.hostId !== void 0 ? { hostId: options.hostId } : {},
4598
- ...options.description !== void 0 ? { description: options.description } : {}
4651
+ ...options.description !== void 0 ? { description: options.description } : {},
4652
+ ...options.sandboxImage !== void 0 ? { sandboxImageId: options.sandboxImage } : {}
4599
4653
  });
4600
4654
  const result = await runPlatformCommand2(
4601
4655
  options,
@@ -10185,6 +10239,55 @@ function registerTasksCommands(program) {
10185
10239
  }
10186
10240
  });
10187
10241
  }
10242
+ function parseMcpHeaderOption(values) {
10243
+ if (!values || values.length === 0) return void 0;
10244
+ const out = {};
10245
+ for (const entry of values) {
10246
+ const index = entry.indexOf("=");
10247
+ if (index <= 0) {
10248
+ throw usageError(
10249
+ `--mcp-header must be in "Name=Value" format (got "${entry}").`
10250
+ );
10251
+ }
10252
+ const name = entry.slice(0, index).trim();
10253
+ if (name === "") {
10254
+ throw usageError(
10255
+ `--mcp-header must be in "Name=Value" format (got "${entry}").`
10256
+ );
10257
+ }
10258
+ out[name] = entry.slice(index + 1);
10259
+ }
10260
+ return out;
10261
+ }
10262
+ function createMcpParamHeaderProbe() {
10263
+ let captured;
10264
+ return {
10265
+ httpLogger: (event) => {
10266
+ if (captured !== void 0) return;
10267
+ if (event.bodyValues?.method !== "tools/call") return;
10268
+ const params = {};
10269
+ for (const [name, value] of Object.entries(event.request.headers)) {
10270
+ if (classifyMcpHeader(name) === "param") {
10271
+ const decoded = decodeMcpHeaderValue(value);
10272
+ params[name] = decoded.decodeError ? value : decoded.value;
10273
+ }
10274
+ }
10275
+ captured = params;
10276
+ },
10277
+ mirrored: () => captured
10278
+ };
10279
+ }
10280
+ function reportMirroredParamHeaders(probe, globalOptions) {
10281
+ if (!probe || globalOptions.quiet) return;
10282
+ process.stderr.write(`${describeMirroredParamHeaders(probe.mirrored())}
10283
+ `);
10284
+ }
10285
+ function describeMirroredParamHeaders(mirrored) {
10286
+ if (mirrored === void 0) return "Mcp-Param-*: none (no HTTP tools/call observed)";
10287
+ const entries = Object.entries(mirrored);
10288
+ if (entries.length === 0) return "Mcp-Param-*: none sent";
10289
+ return `Mcp-Param-*: ${entries.map(([name, value]) => `${name}=${value}`).join(", ")}`;
10290
+ }
10188
10291
  async function runTaskAugmentedToolCall(args) {
10189
10292
  const {
10190
10293
  options,
@@ -10353,7 +10456,9 @@ function registerToolsCommands(program) {
10353
10456
  addHostOption(
10354
10457
  addRetryOptions(
10355
10458
  addSharedServerOptions(
10356
- 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")
10459
+ addConformanceOptions(
10460
+ 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")
10461
+ )
10357
10462
  )
10358
10463
  )
10359
10464
  ).action(async (options, command) => {
@@ -10362,10 +10467,13 @@ function registerToolsCommands(program) {
10362
10467
  const host = resolveHostFromOptions(options);
10363
10468
  const target = describeTarget(options);
10364
10469
  const collector = globalOptions.rpc ? createCliRpcLogCollector({ __cli__: target }) : void 0;
10365
- const config = parseServerConfig({
10366
- ...options,
10367
- timeout: globalOptions.timeout
10368
- });
10470
+ const config = {
10471
+ ...parseServerConfig({
10472
+ ...options,
10473
+ timeout: globalOptions.timeout
10474
+ }),
10475
+ ...conformanceConfigFromOptions(options)
10476
+ };
10369
10477
  const result = await withEphemeralManager(
10370
10478
  config,
10371
10479
  async (manager, serverId) => {
@@ -10412,68 +10520,78 @@ function registerToolsCommands(program) {
10412
10520
  addHostOption(
10413
10521
  addSharedServerOptions(
10414
10522
  addTaskWatchTuningOptions(
10415
- tools.command("call").description("Call an MCP tool").option("--tool-name <tool>", "Tool name").option("--name <tool>", "Alias for --tool-name").option(
10416
- "--interactive",
10417
- "Drive the modern input_required (multi-round-trip) loop: render embedded elicitations to the terminal and collect responses from stdin"
10418
- ).option(
10419
- "--yes",
10420
- "With --interactive, run non-interactively: decline every embedded input request instead of prompting"
10421
- ).option(
10422
- "--tool-args <json>",
10423
- "Tool parameter object as JSON, @path, or - for stdin"
10424
- ).option("--params <json>", "Alias for --tool-args").option("--tool-args-stdin", "Read tool parameter JSON from stdin").option(
10425
- "--validate-response",
10426
- "Validate the MCP tool-call envelope returned by the server"
10427
- ).option(
10428
- "--expect-success",
10429
- "Evaluate the tool-call outcome policy against isError"
10430
- ).option(
10431
- "--reporter <reporter>",
10432
- "Structured reporter output: json-summary or junit-xml"
10433
- ).option(
10434
- "--debug-out <path>",
10435
- "Write a structured debug artifact to a file"
10436
- ).option(
10437
- "--ui",
10438
- "Render the tool result in Inspector Playground; opens a browser by default in a TTY"
10439
- ).option(
10440
- "--require-render",
10441
- "Treat skipped Inspector renders as errors (with --ui)"
10442
- ).option(
10443
- "--open",
10444
- "Open Inspector in the system browser before rendering (default with --ui in a TTY)"
10445
- ).option(
10446
- "--no-open",
10447
- "Start/use Inspector without opening a system browser"
10448
- ).option(
10449
- "--attach-only",
10450
- "Require an already-running Inspector browser client; do not start or open Inspector"
10451
- ).option("--inspector-url <url>", "Local Inspector base URL (with --ui)").option(
10452
- "--frontend-url <url>",
10453
- "Inspector frontend URL (with --ui; overrides health-advertised frontend and skips discovery)"
10454
- ).option(
10455
- "--server-name <name>",
10456
- "Server name inside Inspector (with --ui)"
10457
- ).option(
10458
- "--protocol <protocol>",
10459
- 'Render protocol: "mcp-apps" or "openai-sdk" (with --ui)'
10460
- ).option(
10461
- "--device <device>",
10462
- 'Render device: "mobile", "tablet", "desktop", or "custom" (with --ui)'
10463
- ).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)").option(
10464
- "--task",
10465
- "Invite the server to answer with a task instead of a result. Uses whichever tasks wire the connection resolves to."
10466
- ).option(
10467
- "--task-ttl <ms>",
10468
- "Requested task TTL (2025-11-25 wire only; the extension server owns its TTL). Requires --task.",
10469
- (value) => parsePositiveInteger(value, "Task TTL")
10470
- ).option(
10471
- "--task-watch",
10472
- "After creating the task, poll it to a terminal status in the same connection. Requires --task."
10473
- ).option(
10474
- "--wire <wire>",
10475
- "Assert the connection resolves to this tasks wire: legacy or extension (with --task)",
10476
- parseTasksWireOption
10523
+ addConformanceOptions(
10524
+ tools.command("call").description("Call an MCP tool").option("--tool-name <tool>", "Tool name").option("--name <tool>", "Alias for --tool-name").option(
10525
+ "--interactive",
10526
+ "Drive the modern input_required (multi-round-trip) loop: render embedded elicitations to the terminal and collect responses from stdin"
10527
+ ).option(
10528
+ "--yes",
10529
+ "With --interactive, run non-interactively: decline every embedded input request instead of prompting"
10530
+ ).option(
10531
+ "--tool-args <json>",
10532
+ "Tool parameter object as JSON, @path, or - for stdin"
10533
+ ).option("--params <json>", "Alias for --tool-args").option("--tool-args-stdin", "Read tool parameter JSON from stdin").option(
10534
+ "--no-param-headers",
10535
+ "Do NOT mirror x-mcp-header tool arguments into Mcp-Param-* request headers (SEP-2243). Calls the tool as a client that has not implemented the mirroring \u2014 a conforming 2026-07-28 server should answer -32020 HeaderMismatch."
10536
+ ).option(
10537
+ "--mcp-header <Name=Value>",
10538
+ "Send a raw MCP request header on the tools/call. Repeat for several. Use it to reproduce a header mismatch on purpose. Supplying any Mcp-Param-* header turns OFF the automatic mirroring for that call, so the headers you pass are the only Mcp-Param-* ones sent.",
10539
+ (value, previous = []) => [...previous, value],
10540
+ []
10541
+ ).option(
10542
+ "--validate-response",
10543
+ "Validate the MCP tool-call envelope returned by the server"
10544
+ ).option(
10545
+ "--expect-success",
10546
+ "Evaluate the tool-call outcome policy against isError"
10547
+ ).option(
10548
+ "--reporter <reporter>",
10549
+ "Structured reporter output: json-summary or junit-xml"
10550
+ ).option(
10551
+ "--debug-out <path>",
10552
+ "Write a structured debug artifact to a file"
10553
+ ).option(
10554
+ "--ui",
10555
+ "Render the tool result in Inspector Playground; opens a browser by default in a TTY"
10556
+ ).option(
10557
+ "--require-render",
10558
+ "Treat skipped Inspector renders as errors (with --ui)"
10559
+ ).option(
10560
+ "--open",
10561
+ "Open Inspector in the system browser before rendering (default with --ui in a TTY)"
10562
+ ).option(
10563
+ "--no-open",
10564
+ "Start/use Inspector without opening a system browser"
10565
+ ).option(
10566
+ "--attach-only",
10567
+ "Require an already-running Inspector browser client; do not start or open Inspector"
10568
+ ).option("--inspector-url <url>", "Local Inspector base URL (with --ui)").option(
10569
+ "--frontend-url <url>",
10570
+ "Inspector frontend URL (with --ui; overrides health-advertised frontend and skips discovery)"
10571
+ ).option(
10572
+ "--server-name <name>",
10573
+ "Server name inside Inspector (with --ui)"
10574
+ ).option(
10575
+ "--protocol <protocol>",
10576
+ 'Render protocol: "mcp-apps" or "openai-sdk" (with --ui)'
10577
+ ).option(
10578
+ "--device <device>",
10579
+ 'Render device: "mobile", "tablet", "desktop", or "custom" (with --ui)'
10580
+ ).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)").option(
10581
+ "--task",
10582
+ "Invite the server to answer with a task instead of a result. Uses whichever tasks wire the connection resolves to."
10583
+ ).option(
10584
+ "--task-ttl <ms>",
10585
+ "Requested task TTL (2025-11-25 wire only; the extension server owns its TTL). Requires --task.",
10586
+ (value) => parsePositiveInteger(value, "Task TTL")
10587
+ ).option(
10588
+ "--task-watch",
10589
+ "After creating the task, poll it to a terminal status in the same connection. Requires --task."
10590
+ ).option(
10591
+ "--wire <wire>",
10592
+ "Assert the connection resolves to this tasks wire: legacy or extension (with --task)",
10593
+ parseTasksWireOption
10594
+ )
10477
10595
  )
10478
10596
  )
10479
10597
  )
@@ -10483,10 +10601,30 @@ function registerToolsCommands(program) {
10483
10601
  const target = describeTarget(options);
10484
10602
  const primaryCollector = globalOptions.rpc || options.debugOut ? createCliRpcLogCollector({ __cli__: target }) : void 0;
10485
10603
  const snapshotCollector = options.debugOut ? createCliRpcLogCollector({ __cli__: target }) : void 0;
10486
- const config = parseServerConfig({
10604
+ const baseConfig = parseServerConfig({
10487
10605
  ...options,
10488
10606
  timeout: globalOptions.timeout
10489
10607
  });
10608
+ const mcpHeaders = parseMcpHeaderOption(options.mcpHeader);
10609
+ const overridesParamHeader = Object.keys(mcpHeaders ?? {}).some(
10610
+ // The SDK's classifier, not a local prefix literal — "what counts as a
10611
+ // mirrored param header" has one definition and it lives on the wire.
10612
+ (name) => classifyMcpHeader(name) === "param"
10613
+ );
10614
+ const suppressParamHeaders = options.paramHeaders === false || overridesParamHeader;
10615
+ const headerDebugging = suppressParamHeaders || mcpHeaders !== void 0 || globalOptions.rpc;
10616
+ if ((suppressParamHeaders || mcpHeaders) && !("url" in baseConfig)) {
10617
+ throw usageError(
10618
+ "--no-param-headers and --mcp-header apply to HTTP servers only (SEP-2243 mirroring is Streamable HTTP); they cannot be used with --command."
10619
+ );
10620
+ }
10621
+ const paramHeaderProbe = headerDebugging ? createMcpParamHeaderProbe() : void 0;
10622
+ const config = {
10623
+ ...baseConfig,
10624
+ ...suppressParamHeaders ? { mirrorToolParamHeaders: false } : {},
10625
+ ...conformanceConfigFromOptions(options),
10626
+ ...paramHeaderProbe ? { httpLogger: paramHeaderProbe.httpLogger } : {}
10627
+ };
10490
10628
  const reporter = parseReporterFormat(options.reporter);
10491
10629
  const toolName = resolveAliasedStringOption(
10492
10630
  options,
@@ -10534,6 +10672,11 @@ function registerToolsCommands(program) {
10534
10672
  "--reporter requires --validate-response and/or --expect-success."
10535
10673
  );
10536
10674
  }
10675
+ if (options.task && mcpHeaders) {
10676
+ throw usageError(
10677
+ "--mcp-header cannot be used together with --task: the task-augmented call path does not carry per-request headers. Drop --task to reproduce a header mismatch, or drop --mcp-header."
10678
+ );
10679
+ }
10537
10680
  const watchTuningFlags = [
10538
10681
  ["--duration-ms", options.durationMs],
10539
10682
  ["--poll-interval-ms", options.pollIntervalMs],
@@ -10574,17 +10717,23 @@ function registerToolsCommands(program) {
10574
10717
  "--task cannot be used together with --validate-response or --expect-success: a task-creation envelope is not a tool result. Validate the result of `tasks watch` instead."
10575
10718
  );
10576
10719
  }
10577
- await runTaskAugmentedToolCall({
10578
- options,
10579
- globalOptions,
10580
- config,
10581
- host,
10582
- toolName,
10583
- params,
10584
- collector: primaryCollector,
10585
- targetSummary,
10586
- snapshotCollector
10587
- });
10720
+ try {
10721
+ await runTaskAugmentedToolCall({
10722
+ options,
10723
+ globalOptions,
10724
+ // Carries `mirrorToolParamHeaders` and the mirrored-header probe,
10725
+ // both of which live on the config and therefore apply here too.
10726
+ config,
10727
+ host,
10728
+ toolName,
10729
+ params,
10730
+ collector: primaryCollector,
10731
+ targetSummary,
10732
+ snapshotCollector
10733
+ });
10734
+ } finally {
10735
+ reportMirroredParamHeaders(paramHeaderProbe, globalOptions);
10736
+ }
10588
10737
  return;
10589
10738
  }
10590
10739
  const renderContext = options.ui ? {
@@ -10603,7 +10752,16 @@ function registerToolsCommands(program) {
10603
10752
  config,
10604
10753
  async (manager, serverId) => {
10605
10754
  if (host) await assertToolVisibleToHost(manager, serverId, toolName, host);
10606
- return manager.executeTool(serverId, toolName, params);
10755
+ return manager.executeTool(
10756
+ serverId,
10757
+ toolName,
10758
+ params,
10759
+ // Caller-supplied headers WIN over the mirrored ones (the seam in
10760
+ // `MCPClientManager`), which is the whole point of `--mcp-header`:
10761
+ // sending a deliberately wrong value is how you exercise a
10762
+ // server's -32020.
10763
+ mcpHeaders ? { headers: mcpHeaders } : void 0
10764
+ );
10607
10765
  },
10608
10766
  {
10609
10767
  timeout: globalOptions.timeout,
@@ -10641,6 +10799,7 @@ function registerToolsCommands(program) {
10641
10799
  } : void 0,
10642
10800
  collectors: [primaryCollector]
10643
10801
  });
10802
+ reportMirroredParamHeaders(paramHeaderProbe, globalOptions);
10644
10803
  throw commandError;
10645
10804
  }
10646
10805
  const validationResult = shouldValidateResponse || shouldExpectSuccess ? validateToolCallResult(result, {
@@ -10798,6 +10957,7 @@ function registerToolsCommands(program) {
10798
10957
  globalOptions.format
10799
10958
  );
10800
10959
  }
10960
+ reportMirroredParamHeaders(paramHeaderProbe, globalOptions);
10801
10961
  if (validationResult && !validationResult.passed) {
10802
10962
  setProcessExitCode(1);
10803
10963
  }