@plune-ai/cli 0.37.0 → 0.38.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.cjs CHANGED
@@ -45,8 +45,8 @@ function machineless(raw, repoRoot, home) {
45
45
  let text = (0, import_node_util.stripVTControlCharacters)(raw).replaceAll("\x1B", "");
46
46
  const root = repoRoot === void 0 ? void 0 : pathIn(repoRoot);
47
47
  if (root !== void 0) text = text.replace(new RegExp(`${PATH_START}${root.source}[\\\\/]+`, root.flags), "");
48
- const own = pathIn(home);
49
- if (own !== void 0) text = text.replace(new RegExp(`${PATH_START}${own.source}(?![\\w.-])`, own.flags), "~");
48
+ const own2 = pathIn(home);
49
+ if (own2 !== void 0) text = text.replace(new RegExp(`${PATH_START}${own2.source}(?![\\w.-])`, own2.flags), "~");
50
50
  if (repoRoot === void 0) text = text.replace(ANY_HOME, "~");
51
51
  return text;
52
52
  }
@@ -150,8 +150,8 @@ function processTable() {
150
150
  return (0, import_node_fs3.readdirSync)("/proc").flatMap((name) => {
151
151
  if (!/^\d+$/.test(name)) return [];
152
152
  try {
153
- const stat = (0, import_node_fs3.readFileSync)(`/proc/${name}/stat`, "utf8");
154
- const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
153
+ const stat2 = (0, import_node_fs3.readFileSync)(`/proc/${name}/stat`, "utf8");
154
+ const fields = stat2.slice(stat2.lastIndexOf(")") + 2).split(" ");
155
155
  return parseProcessTable(`${name} ${fields[1]} ${fields[19]}`);
156
156
  } catch {
157
157
  return [];
@@ -382,10 +382,33 @@ var init_redact = __esm({
382
382
  var session_exports = {};
383
383
  __export(session_exports, {
384
384
  ConnectError: () => ConnectError,
385
+ STDERR_LINE_LIMIT: () => STDERR_LINE_LIMIT,
385
386
  STDIO_MESSAGE_LIMIT: () => STDIO_MESSAGE_LIMIT,
386
387
  closeAllSessions: () => closeAllSessions,
387
- openSession: () => openSession
388
+ headerValue: () => headerValue,
389
+ openSession: () => openSession,
390
+ readLines: () => readLines
388
391
  });
392
+ function headerValue(value) {
393
+ const plain = /^[\x21-\x7e]([\x20-\x7e]*[\x21-\x7e])?$/.test(value) && !/^=\?base64\?.*\?=$/.test(value);
394
+ return plain ? value : `=?base64?${Buffer.from(value, "utf8").toString("base64")}?=`;
395
+ }
396
+ function modernHeaders(body, version) {
397
+ const m = parsed(body);
398
+ if (m === null || typeof m !== "object" || Array.isArray(m)) return [];
399
+ const { method, params } = m;
400
+ if (typeof method !== "string") return [];
401
+ const meta = params?.["_meta"];
402
+ const v = meta?.["io.modelcontextprotocol/protocolVersion"];
403
+ const headers = [
404
+ ["mcp-protocol-version", typeof v === "string" ? v : version],
405
+ ["mcp-method", method]
406
+ ];
407
+ const name = method === "resources/read" ? params?.["uri"] : params?.["name"];
408
+ if (["tools/call", "resources/read", "prompts/get"].includes(method) && typeof name === "string")
409
+ headers.push(["mcp-name", headerValue(name)]);
410
+ return headers;
411
+ }
389
412
  function answers(frame, id) {
390
413
  if (frame === null || typeof frame !== "object" || Array.isArray(frame)) return false;
391
414
  const f = frame;
@@ -400,6 +423,40 @@ function fromEventStream(text, id) {
400
423
  }
401
424
  return void 0;
402
425
  }
426
+ function readLines(stream, onLine, stats) {
427
+ const decoder = new import_node_string_decoder.StringDecoder("utf8");
428
+ let partial = "";
429
+ const feed = (text) => {
430
+ let from = 0;
431
+ for (let nl = text.indexOf("\n", from); nl >= 0; nl = text.indexOf("\n", from)) {
432
+ const whole = partial + text.slice(from, nl);
433
+ if (stats !== void 0 && whole.length > stats.high) stats.high = whole.length;
434
+ const line = whole.slice(0, STDERR_LINE_LIMIT);
435
+ partial = "";
436
+ onLine(line.endsWith("\r") ? line.slice(0, -1) : line);
437
+ from = nl + 1;
438
+ }
439
+ const rest = partial + text.slice(from);
440
+ if (stats !== void 0 && rest.length > stats.high) stats.high = rest.length;
441
+ partial = rest.slice(0, STDERR_LINE_LIMIT);
442
+ };
443
+ return new Promise((resolve8) => {
444
+ let done = false;
445
+ const finish = () => {
446
+ if (done) return;
447
+ done = true;
448
+ feed(decoder.end());
449
+ if (partial !== "") onLine(partial.endsWith("\r") ? partial.slice(0, -1) : partial);
450
+ resolve8();
451
+ };
452
+ stream.on(
453
+ "data",
454
+ (chunk) => feed(typeof chunk === "string" ? chunk : decoder.write(chunk))
455
+ );
456
+ stream.once("end", finish);
457
+ stream.once("close", finish);
458
+ });
459
+ }
403
460
  function createTransport(target) {
404
461
  if (target.kind === "stdio") {
405
462
  return new import_stdio.StdioClientTransport({
@@ -497,7 +554,7 @@ function kindOf(err, stdio, transportClosed) {
497
554
  return "network";
498
555
  return "protocol";
499
556
  }
500
- async function openSession(config) {
557
+ async function openSession(config, options = {}) {
501
558
  const { target } = config;
502
559
  const stdio = target.kind === "stdio";
503
560
  const redact = redactorFor(target);
@@ -507,10 +564,12 @@ async function openSession(config) {
507
564
  const transport = createTransport(target);
508
565
  let transportClosed = false;
509
566
  let spawnError;
567
+ const stopped = /* @__PURE__ */ new Set();
510
568
  const handshake = {
511
569
  offered: void 0,
512
570
  result: void 0
513
571
  };
572
+ const notifications = /* @__PURE__ */ new Map();
514
573
  tap(transport, journal, {
515
574
  frame: (dir, message) => {
516
575
  const m = message;
@@ -519,11 +578,18 @@ async function openSession(config) {
519
578
  handshake.offered = m.params?.protocolVersion;
520
579
  } else if (dir === "in" && handshake.id !== void 0 && m.id === handshake.id)
521
580
  handshake.result = m.result;
581
+ if (dir === "in" && m.id === void 0 && typeof m.method === "string")
582
+ notifications.set(m.method, (notifications.get(m.method) ?? 0) + 1);
583
+ },
584
+ closed: () => {
585
+ transportClosed = true;
586
+ for (const stop of [...stopped]) stop();
522
587
  },
523
- closed: () => transportClosed = true,
524
588
  error: (err) => {
525
- if (spawnError === void 0 && err.syscall?.startsWith("spawn") === true)
589
+ if (spawnError === void 0 && err.syscall?.startsWith("spawn") === true) {
526
590
  spawnError = err;
591
+ for (const stop of [...stopped]) stop();
592
+ }
527
593
  }
528
594
  });
529
595
  let noted;
@@ -535,23 +601,30 @@ async function openSession(config) {
535
601
  let tooLarge = false;
536
602
  const tail = [];
537
603
  const noise = { count: 0, first: [] };
604
+ const traffic = [];
605
+ const methods = /* @__PURE__ */ new Map();
606
+ const heard = (frame) => {
607
+ if (frame === null || typeof frame !== "object" || Array.isArray(frame)) return;
608
+ const f = frame;
609
+ const method = "method" in f || f["id"] === void 0 ? void 0 : methods.get(f["id"]);
610
+ traffic.push(method === void 0 ? { frame: f } : { frame: f, method });
611
+ };
538
612
  const listeners = /* @__PURE__ */ new Set();
539
613
  const seen = (line, isMessage) => {
540
614
  if (!isMessage) {
541
615
  noise.count++;
542
616
  if (noise.first.length < 3) noise.first.push(clean(line).slice(0, 200));
543
617
  }
618
+ if (isMessage) heard(parsed(line));
544
619
  for (const listener of [...listeners]) listener(line);
545
620
  };
546
621
  let stderrDone = Promise.resolve();
547
622
  if (transport instanceof import_stdio.StdioClientTransport && transport.stderr !== null) {
548
- const lines = (0, import_node_readline.createInterface)({ input: transport.stderr, crlfDelay: Infinity });
549
- lines.on("line", (line) => {
623
+ stderrDone = readLines(transport.stderr, (line) => {
550
624
  journal.write("stderr", { line });
551
625
  tail.push(clean(line));
552
626
  if (tail.length > TAIL_LINES) tail.shift();
553
627
  });
554
- stderrDone = new Promise((resolve8) => lines.once("close", resolve8));
555
628
  watchStdout(transport, journal, seen);
556
629
  watchOverflow(transport, () => {
557
630
  if (tooLarge) return;
@@ -591,10 +664,19 @@ async function openSession(config) {
591
664
  };
592
665
  const untrack = track(closable);
593
666
  const client = new import_client.Client({ name: "plune", version: config.clientVersion ?? "0.0.0" });
667
+ const modern = options.modern;
668
+ if (modern !== void 0) {
669
+ transport.onmessage = () => {
670
+ };
671
+ transport.onerror = () => {
672
+ };
673
+ transport.onclose = () => {
674
+ };
675
+ }
594
676
  let timer;
595
677
  try {
596
678
  await Promise.race([
597
- client.connect(transport, { timeout: config.timeoutMs }),
679
+ modern === void 0 ? client.connect(transport, { timeout: config.timeoutMs }) : transport.start(),
598
680
  new Promise((_, reject) => {
599
681
  timer = setTimeout(
600
682
  () => reject(new import_client.SdkError(import_client.SdkErrorCode.RequestTimeout, "no answer")),
@@ -621,12 +703,12 @@ async function openSession(config) {
621
703
  server: info === void 0 ? void 0 : { name: String(info.name), version: String(info.version) },
622
704
  handshake: { offered: handshake.offered, result: handshake.result },
623
705
  stderrTail: () => [...tail],
624
- async request(method, params, options) {
706
+ async request(method, params, options2) {
625
707
  try {
626
708
  return await client.request(
627
709
  params === void 0 ? { method } : { method, params },
628
710
  AS_SENT,
629
- { timeout: options?.timeoutMs ?? config.timeoutMs }
711
+ { timeout: options2?.timeoutMs ?? config.timeoutMs }
630
712
  );
631
713
  } catch (err) {
632
714
  if (err instanceof import_client.ProtocolError)
@@ -636,7 +718,7 @@ async function openSession(config) {
636
718
  },
637
719
  fetchForOrigin(origin) {
638
720
  const allowed = new URL(origin).origin;
639
- const own = target.kind !== "stdio" && new URL(target.url).origin === allowed;
721
+ const own2 = target.kind !== "stdio" && new URL(target.url).origin === allowed;
640
722
  return async (input, init) => {
641
723
  const url = new URL(input);
642
724
  if (url.origin !== allowed)
@@ -644,36 +726,47 @@ async function openSession(config) {
644
726
  `fetchForOrigin(${allowed}) refuses a request to another origin, ${url.origin}.`
645
727
  );
646
728
  const headers = new Headers(init?.headers);
647
- if (own) {
729
+ if (own2) {
648
730
  for (const [name, value] of Object.entries(target.headers))
649
731
  if (!headers.has(name)) headers.set(name, value);
650
732
  }
651
733
  return fetch(url, { ...init, headers, redirect: "manual" });
652
734
  };
653
735
  },
654
- async raw(body, id, options) {
655
- const ms = options?.timeoutMs ?? config.timeoutMs;
736
+ async raw(body, id, options2) {
737
+ const ms = options2?.timeoutMs ?? config.timeoutMs;
656
738
  if (target.kind === "sse")
657
739
  throw new ConnectError("protocol", "Messages of its own go over stdio and Streamable HTTP only, not HTTP+SSE.", []);
658
740
  journal.write("out", { raw: body });
659
741
  const noAnswer = () => new ConnectError("timeout", `${LEAD.timeout[0]}.`, [...tail]);
742
+ const sent = parsed(body);
743
+ if (typeof sent?.method === "string" && sent.id !== void 0) methods.set(sent.id, sent.method);
660
744
  if (target.kind === "stdio") {
661
745
  const stdin = transport._process?.stdin;
662
746
  if (stdin === null || stdin === void 0 || stdin.writableEnded)
663
- throw new ConnectError("exited-early", `${LEAD["exited-early"][0]}.`, [...tail]);
747
+ throw spawnError !== void 0 ? await toConnectError(spawnError) : new ConnectError("exited-early", `${LEAD["exited-early"][0]}.`, [...tail]);
664
748
  return new Promise((resolve8, reject) => {
665
- const timer2 = setTimeout(() => {
749
+ const done = () => {
750
+ clearTimeout(timer2);
666
751
  listeners.delete(listener);
752
+ stopped.delete(stop);
753
+ };
754
+ const timer2 = setTimeout(() => {
755
+ done();
667
756
  reject(noAnswer());
668
757
  }, ms);
669
758
  const listener = (line) => {
670
759
  const frame2 = parsed(line);
671
760
  if (!answers(frame2, id)) return;
672
- clearTimeout(timer2);
673
- listeners.delete(listener);
761
+ done();
674
762
  resolve8({ frame: frame2, text: clean(line).slice(0, RAW_TEXT) });
675
763
  };
764
+ const stop = () => {
765
+ done();
766
+ void toConnectError(spawnError ?? new Error("closed")).then(reject);
767
+ };
676
768
  listeners.add(listener);
769
+ stopped.add(stop);
677
770
  stdin.write(`${body}
678
771
  `);
679
772
  });
@@ -684,6 +777,11 @@ async function openSession(config) {
684
777
  headers.set("accept", "application/json, text/event-stream");
685
778
  if (state.sessionId !== void 0) headers.set("mcp-session-id", state.sessionId);
686
779
  if (state._protocolVersion !== void 0) headers.set("mcp-protocol-version", state._protocolVersion);
780
+ if (modern !== void 0) for (const [name, value] of modernHeaders(body, modern.version)) headers.set(name, value);
781
+ for (const [name, value] of options2?.headers ?? []) {
782
+ if (value === null) headers.delete(name);
783
+ else headers.set(name, value);
784
+ }
687
785
  const lost = async (err) => err?.name === "TimeoutError" ? noAnswer() : toConnectError(err);
688
786
  let text = "";
689
787
  let frame;
@@ -715,14 +813,28 @@ async function openSession(config) {
715
813
  const whole = parsed(text);
716
814
  if (whole !== null && typeof whole === "object" && !Array.isArray(whole))
717
815
  frame = whole;
718
- }
816
+ heard(frame);
817
+ } else
818
+ for (const line of text.split(/\r?\n/)) if (line.startsWith("data:")) heard(parsed(line.slice(5).trim()));
719
819
  } catch (err) {
720
820
  throw await lost(err);
721
821
  }
722
- journal.write("in", frame !== void 0 ? { frame } : { status, raw: text.slice(0, RAW_TEXT) });
822
+ journal.write("in", frame !== void 0 ? { frame } : { status, raw: clean(text).slice(0, RAW_TEXT) });
723
823
  return { frame, status, text: clean(text).slice(0, RAW_TEXT) };
724
824
  },
825
+ async notify(body) {
826
+ if (target.kind !== "stdio")
827
+ throw new ConnectError("protocol", "notify is for a stdio server.", []);
828
+ const stdin = transport._process?.stdin;
829
+ if (stdin === null || stdin === void 0 || stdin.writableEnded)
830
+ throw spawnError !== void 0 ? await toConnectError(spawnError) : new ConnectError("exited-early", `${LEAD["exited-early"][0]}.`, [...tail]);
831
+ journal.write("out", { raw: body });
832
+ stdin.write(`${body}
833
+ `);
834
+ },
835
+ traffic: () => traffic,
725
836
  stdoutNoise: () => ({ count: noise.count, first: [...noise.first] }),
837
+ notified: (method) => notifications.get(method) ?? 0,
726
838
  async endInput(waitMs) {
727
839
  const proc = transport._process;
728
840
  if (proc === void 0) return true;
@@ -738,12 +850,13 @@ async function openSession(config) {
738
850
  close: closable.close
739
851
  };
740
852
  }
741
- var import_node_os2, import_node_readline, import_client, import_stdio, ConnectError, RAW_TEXT, parsed, TAIL_LINES, STDIO_MESSAGE_LIMIT, AS_SENT, firstLine, LEAD;
853
+ var import_node_os2, import_node_string_decoder, import_node_readline, import_client, import_stdio, ConnectError, RAW_TEXT, parsed, TAIL_LINES, STDERR_LINE_LIMIT, STDIO_MESSAGE_LIMIT, AS_SENT, firstLine, LEAD;
742
854
  var init_session = __esm({
743
855
  "src/mcp-testing/connect/session.ts"() {
744
856
  "use strict";
745
857
  init_cjs_shims();
746
858
  import_node_os2 = require("os");
859
+ import_node_string_decoder = require("string_decoder");
747
860
  import_node_readline = require("readline");
748
861
  import_client = require("@modelcontextprotocol/client");
749
862
  import_stdio = require("@modelcontextprotocol/client/stdio");
@@ -773,6 +886,7 @@ var init_session = __esm({
773
886
  }
774
887
  };
775
888
  TAIL_LINES = 20;
889
+ STDERR_LINE_LIMIT = 64 * 1024;
776
890
  STDIO_MESSAGE_LIMIT = 10 * 1024 * 1024;
777
891
  AS_SENT = {
778
892
  "~standard": { version: 1, vendor: "plune", validate: (value) => ({ value }) }
@@ -852,10 +966,10 @@ async function listAll(session, method, key, opts = {}) {
852
966
  cursor === void 0 ? void 0 : { cursor },
853
967
  opts.timeoutMs === void 0 ? {} : { timeoutMs: opts.timeoutMs }
854
968
  );
855
- const listed = isRecord3(page) ? page[key] : void 0;
969
+ const listed = isRecord5(page) ? page[key] : void 0;
856
970
  if (Array.isArray(listed)) for (const item of listed) items.push(item);
857
971
  else malformed = true;
858
- cursor = isRecord3(page) && typeof page.nextCursor === "string" && page.nextCursor !== "" ? page.nextCursor : void 0;
972
+ cursor = isRecord5(page) && typeof page.nextCursor === "string" && page.nextCursor !== "" ? page.nextCursor : void 0;
859
973
  if (cursor === void 0) return { items, pages, complete: true, malformed };
860
974
  }
861
975
  return { items, pages: MAX_PAGES, complete: false, malformed };
@@ -864,12 +978,12 @@ function asTools(items) {
864
978
  const tools = [];
865
979
  const unnamed = /* @__PURE__ */ new Map();
866
980
  for (const t of items) {
867
- const name = isRecord3(t) ? t.name : void 0;
981
+ const name = isRecord5(t) ? t.name : void 0;
868
982
  if (typeof name === "string" && name !== "") {
869
983
  tools.push(t);
870
984
  continue;
871
985
  }
872
- const tool = { ...isRecord3(t) ? t : {}, name: "" };
986
+ const tool = { ...isRecord5(t) ? t : {}, name: "" };
873
987
  unnamed.set(tool, name === void 0 ? "(no name)" : String(JSON.stringify(name)));
874
988
  tools.push(tool);
875
989
  }
@@ -887,9 +1001,9 @@ function callableTools(tools, unnamed, opts = {}) {
887
1001
  refused.push({ tool: t.name, reason: "duplicate-name" });
888
1002
  else candidates.push(t);
889
1003
  }
890
- const { safe, skipped } = selectSafeTools(candidates, opts);
1004
+ const { safe: safe2, skipped } = selectSafeTools(candidates, opts);
891
1005
  return {
892
- safe,
1006
+ safe: safe2,
893
1007
  skipped: [...refused, ...skipped.map((s) => ({ tool: s.tool.name, reason: s.reason }))]
894
1008
  };
895
1009
  }
@@ -906,7 +1020,7 @@ async function callTool(session, name, timeoutMs, args = {}) {
906
1020
  throw err;
907
1021
  }
908
1022
  }
909
- var import_client2, MAX_PAGES, isRecord3;
1023
+ var import_client2, MAX_PAGES, isRecord5;
910
1024
  var init_tools = __esm({
911
1025
  "src/mcp-testing/connect/tools.ts"() {
912
1026
  "use strict";
@@ -915,7 +1029,7 @@ var init_tools = __esm({
915
1029
  init_safe_tools();
916
1030
  init_session();
917
1031
  MAX_PAGES = 100;
918
- isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
1032
+ isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
919
1033
  }
920
1034
  });
921
1035
 
@@ -959,24 +1073,6 @@ var import_yaml = require("yaml");
959
1073
 
960
1074
  // src/config/env-overrides.ts
961
1075
  init_cjs_shims();
962
- function applyEnvOverrides(config, env) {
963
- const result = structuredClone(config);
964
- if (env["PLUNE_PROVIDER"] !== void 0) {
965
- result.provider.type = env["PLUNE_PROVIDER"];
966
- }
967
- if (env["PLUNE_MODEL"] !== void 0) {
968
- result.provider.model = env["PLUNE_MODEL"];
969
- }
970
- if (env["PLUNE_TIMEOUT"] !== void 0) {
971
- const n = Number(env["PLUNE_TIMEOUT"]);
972
- if (!isNaN(n)) result.provider.timeout = n;
973
- }
974
- if (env["PLUNE_MAX_RETRIES"] !== void 0) {
975
- const n = Number(env["PLUNE_MAX_RETRIES"]);
976
- if (!isNaN(n)) result.provider.max_retries = n;
977
- }
978
- return result;
979
- }
980
1076
 
981
1077
  // src/config/errors.ts
982
1078
  init_cjs_shims();
@@ -1004,6 +1100,34 @@ var ConfigValidationError = class extends Error {
1004
1100
  }
1005
1101
  };
1006
1102
 
1103
+ // src/config/env-overrides.ts
1104
+ function applyEnvOverrides(config, env) {
1105
+ const result = structuredClone(config);
1106
+ const all = result.providers ?? [result.provider];
1107
+ if (result.providers !== void 0) {
1108
+ for (const name of ["PLUNE_PROVIDER", "PLUNE_MODEL"])
1109
+ if (env[name] !== void 0)
1110
+ throw new ConfigValidationError("Config validation failed", [
1111
+ `${name} sets one model, but the config lists ${result.providers.length}: remove it or list a single model`
1112
+ ]);
1113
+ }
1114
+ if (env["PLUNE_PROVIDER"] !== void 0) {
1115
+ result.provider.type = env["PLUNE_PROVIDER"];
1116
+ }
1117
+ if (env["PLUNE_MODEL"] !== void 0) {
1118
+ result.provider.model = env["PLUNE_MODEL"];
1119
+ }
1120
+ if (env["PLUNE_TIMEOUT"] !== void 0) {
1121
+ const n = Number(env["PLUNE_TIMEOUT"]);
1122
+ if (!isNaN(n)) for (const p of all) p.timeout = n;
1123
+ }
1124
+ if (env["PLUNE_MAX_RETRIES"] !== void 0) {
1125
+ const n = Number(env["PLUNE_MAX_RETRIES"]);
1126
+ if (!isNaN(n)) for (const p of all) p.max_retries = n;
1127
+ }
1128
+ return result;
1129
+ }
1130
+
1007
1131
  // src/config/discover.ts
1008
1132
  init_cjs_shims();
1009
1133
  var fs = __toESM(require("fs"), 1);
@@ -1142,6 +1266,13 @@ var providerConfigSchema = import_zod.z.object({
1142
1266
  // The values the OpenAI SDK's Chat Completions `reasoning_effort` accepts; only `openai` sends it.
1143
1267
  reasoning_effort: import_zod.z.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional()
1144
1268
  });
1269
+ var providerListSchema = import_zod.z.array(providerConfigSchema).min(1);
1270
+ var providerField = import_zod.z.any().transform((value, ctx) => {
1271
+ const r = (Array.isArray(value) ? providerListSchema : providerConfigSchema).safeParse(value);
1272
+ if (r.success) return r.data;
1273
+ for (const issue of r.error.issues) ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
1274
+ return import_zod.z.NEVER;
1275
+ });
1145
1276
  var modelPriceSchema = import_zod.z.object({
1146
1277
  input_per_1k_usd: import_zod.z.number().nonnegative(),
1147
1278
  output_per_1k_usd: import_zod.z.number().nonnegative()
@@ -1331,7 +1462,8 @@ var evalConfigSchema = import_zod.z.object({
1331
1462
  );
1332
1463
  var pluneConfigSchema = import_zod.z.object({
1333
1464
  version: import_zod.z.literal(1),
1334
- provider: providerConfigSchema,
1465
+ // One object, or a non-empty list of models to run every eval against (a one-element list is the object).
1466
+ provider: providerField,
1335
1467
  defaults: import_zod.z.object({ assertions: import_zod.z.array(assertionConfigSchema).optional() }).optional(),
1336
1468
  pricing: pricingSchema.optional(),
1337
1469
  ...evalRepeatsShape,
@@ -1339,6 +1471,34 @@ var pluneConfigSchema = import_zod.z.object({
1339
1471
  mcp: mcpRootSchema.optional(),
1340
1472
  evals: import_zod.z.array(evalConfigSchema).min(1)
1341
1473
  }).strict().superRefine((config, ctx) => {
1474
+ if (Array.isArray(config.provider)) {
1475
+ const pairs = /* @__PURE__ */ new Set();
1476
+ const byModel = /* @__PURE__ */ new Map();
1477
+ config.provider.forEach((p, i) => {
1478
+ const pair = `${p.type}/${p.model}`;
1479
+ if (pairs.has(pair))
1480
+ ctx.addIssue({ code: "custom", path: ["provider", i], message: `provider "${pair}" is listed twice` });
1481
+ pairs.add(pair);
1482
+ const other = byModel.get(p.model);
1483
+ if (other !== void 0 && other !== p.type)
1484
+ ctx.addIssue({
1485
+ code: "custom",
1486
+ path: ["provider", i, "model"],
1487
+ message: `model "${p.model}" is listed under ${other} and ${p.type}: cell ids are built from the model name`
1488
+ });
1489
+ byModel.set(p.model, p.type);
1490
+ });
1491
+ if (config.provider.length > 1)
1492
+ config.evals.forEach((ev, i) => {
1493
+ for (const key of ["type", "model"])
1494
+ if (ev.provider?.[key] !== void 0)
1495
+ ctx.addIssue({
1496
+ code: "custom",
1497
+ path: ["evals", i, "provider", key],
1498
+ message: `eval "${ev.id}" sets provider.${key}, but the root provider lists several models: the models come from the root list`
1499
+ });
1500
+ });
1501
+ }
1342
1502
  config.evals.forEach((evalConfig, i) => {
1343
1503
  const server = evalConfig.mcp?.server;
1344
1504
  if (server === void 0) {
@@ -1361,6 +1521,10 @@ var pluneConfigSchema = import_zod.z.object({
1361
1521
  message: `eval "${evalConfig.id}" uses MCP server "${server}", which mcp.servers does not define`
1362
1522
  });
1363
1523
  });
1524
+ }).transform(({ provider, ...rest }) => {
1525
+ if (!Array.isArray(provider)) return { provider, ...rest };
1526
+ const [first, ...others] = provider;
1527
+ return others.length === 0 ? { provider: first, ...rest } : { provider: first, providers: provider, ...rest };
1364
1528
  });
1365
1529
 
1366
1530
  // src/config/loader.ts
@@ -1398,6 +1562,16 @@ async function loadConfig(opts = {}) {
1398
1562
  return applyEnvOverrides(config, env);
1399
1563
  }
1400
1564
 
1565
+ // src/config/model-matrix.ts
1566
+ init_cjs_shims();
1567
+ function selfJudgeWarnings(config) {
1568
+ if ((config.providers?.length ?? 0) < 2) return [];
1569
+ const inherited = (config.defaults?.assertions ?? []).some((a) => a.type === "llm-judge" && a.provider === void 0);
1570
+ return config.evals.filter((ev) => inherited || ev.assertions.some((a) => a.type === "llm-judge" && a.provider === void 0)).map(
1571
+ (ev) => `eval "${ev.id}" has an llm-judge check without a provider: with several models each model judges its own answer, which favours it. Set provider on the check to name one judge for all`
1572
+ );
1573
+ }
1574
+
1401
1575
  // src/providers/index.ts
1402
1576
  init_cjs_shims();
1403
1577
 
@@ -2357,6 +2531,14 @@ init_cjs_shims();
2357
2531
  // src/assertions/interpolate.ts
2358
2532
  init_cjs_shims();
2359
2533
  var PLACEHOLDER = /\{\{\s*([\w.]+)\s*\}\}/g;
2534
+ var EXPECTED = /\{\{\s*expected\s*\}\}/;
2535
+ function usesExpected(params) {
2536
+ if (typeof params === "string") return EXPECTED.test(params);
2537
+ if (Array.isArray(params)) return params.some(usesExpected);
2538
+ if (params !== null && typeof params === "object")
2539
+ return Object.values(params).some(usesExpected);
2540
+ return false;
2541
+ }
2360
2542
  function interpolate(template, ctx) {
2361
2543
  return template.replace(PLACEHOLDER, (match, key) => {
2362
2544
  if (key === "expected") {
@@ -2700,10 +2882,10 @@ function checkNames(type, t, names) {
2700
2882
  const offered = t.tools.filter((x) => x.offered).map((x) => x.name);
2701
2883
  const unknown = names.find((n) => n !== void 0 && !offered.includes(n));
2702
2884
  if (unknown === void 0) return;
2703
- const list = offered.length > 0 ? offered.join(", ") : "(none)";
2885
+ const list2 = offered.length > 0 ? offered.join(", ") : "(none)";
2704
2886
  throw new AssertionRunError(
2705
2887
  "ASSERTION_UNKNOWN_TOOL",
2706
- `${type}: no tool "${unknown}" was offered to the model; offered: ${list}.${AFTER}`
2888
+ `${type}: no tool "${unknown}" was offered to the model; offered: ${list2}.${AFTER}`
2707
2889
  );
2708
2890
  }
2709
2891
  function absence(type, t, what, reads) {
@@ -2798,6 +2980,38 @@ var onlyTools = check((ctx) => {
2798
2980
 
2799
2981
  // src/assertions/tool-calls/order.ts
2800
2982
  init_cjs_shims();
2983
+
2984
+ // src/util/tool-calls.ts
2985
+ init_cjs_shims();
2986
+ var PAGINATION_KEYS = [
2987
+ "cursor",
2988
+ "page",
2989
+ "offset",
2990
+ "limit",
2991
+ "after",
2992
+ "before",
2993
+ "start",
2994
+ "pageToken",
2995
+ "page_token",
2996
+ "nextCursor",
2997
+ "next_cursor"
2998
+ ];
2999
+ var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
3000
+ function sameValue(a, b) {
3001
+ return a !== void 0 && b !== void 0 && canonicalJson(a) === canonicalJson(b);
3002
+ }
3003
+ function withoutPagination(args) {
3004
+ if (!isRecord2(args)) return args;
3005
+ return Object.fromEntries(Object.entries(args).filter(([k]) => !PAGINATION_KEYS.includes(k)));
3006
+ }
3007
+ function isIdenticalCall(a, b) {
3008
+ return a.name === b.name && sameValue(a.args, b.args);
3009
+ }
3010
+ function isPageTurn(a, b) {
3011
+ return a.name === b.name && !isIdenticalCall(a, b) && sameValue(withoutPagination(a.args), withoutPagination(b.args));
3012
+ }
3013
+
3014
+ // src/assertions/tool-calls/order.ts
2801
3015
  function inOrder(names, tools) {
2802
3016
  let next = 0;
2803
3017
  for (const n of names) if (n === tools[next]) next++;
@@ -2835,7 +3049,7 @@ var noRepeatedCall = check((ctx) => {
2835
3049
  for (let i = 1; i < calls.length; i++) {
2836
3050
  const [prev, cur] = [calls[i - 1], calls[i]];
2837
3051
  if (tool !== void 0 && cur.call.name !== tool) continue;
2838
- if (prev.call.name === cur.call.name && sameJson(prev.call.args, cur.call.args))
3052
+ if (isIdenticalCall(prev.call, cur.call))
2839
3053
  return fail(
2840
3054
  `expected no call repeated right after itself; got ${describeCall(prev)} then ${describeCall(cur)}; check whether the first answer told the model what it needed`
2841
3055
  );
@@ -3215,6 +3429,159 @@ function wireNames(names) {
3215
3429
  return { toWire, toServer };
3216
3430
  }
3217
3431
 
3432
+ // src/orchestrator/friction.ts
3433
+ init_cjs_shims();
3434
+ var SCAN_DEPTH = 6;
3435
+ var SCAN_ITEMS = 50;
3436
+ var MAX_PATHS = 10;
3437
+ var MAX_PATH = 120;
3438
+ var MIN_VALUE = 6;
3439
+ var WORDS = "id|ids|key|uuid|slug|number|ref|identifier";
3440
+ var WHOLE = new RegExp(`^(?:${WORDS})$`, "i");
3441
+ var SNAKE = new RegExp(`_(?:${WORDS})$`, "i");
3442
+ var CAMEL = /[a-z0-9](?:Id|Ids|Uuid|Key|Slug|Number|Ref|Identifier)$/;
3443
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3444
+ var isIdKey = (key) => WHOLE.test(key) || SNAKE.test(key) || CAMEL.test(key);
3445
+ var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
3446
+ var isScalar = (v) => typeof v === "string" && v !== "" || typeof v === "number" && Number.isFinite(v);
3447
+ var EMAIL = /@/;
3448
+ function segment(key) {
3449
+ const plain = /^[A-Za-z_][\w-]*$/.test(key) && key.length <= 40 && !UUID.test(key) && !EMAIL.test(key);
3450
+ return plain ? key : "*";
3451
+ }
3452
+ var cap = (path9) => path9.length > MAX_PATH ? path9.slice(0, MAX_PATH) : path9;
3453
+ var hashOf = (v) => sha256(v).slice(0, 16);
3454
+ function noteValue(out, v, at) {
3455
+ if (typeof v !== "string" || v.length < MIN_VALUE) return;
3456
+ const h = hashOf(v);
3457
+ const where = out.values.get(h) ?? /* @__PURE__ */ new Set();
3458
+ where.add(at);
3459
+ out.values.set(h, where);
3460
+ }
3461
+ function walk(value, path9, depth, out) {
3462
+ if (depth > SCAN_DEPTH) return;
3463
+ if (typeof value === "string" && UUID.test(value)) {
3464
+ const at = cap(path9 === "" ? "(root)" : path9);
3465
+ out.paths.add(at);
3466
+ noteValue(out, value, at);
3467
+ }
3468
+ if (Array.isArray(value)) {
3469
+ for (const item of value.slice(0, SCAN_ITEMS)) walk(item, `${path9}[]`, depth + 1, out);
3470
+ return;
3471
+ }
3472
+ if (!isRecord3(value)) return;
3473
+ for (const [key, v] of Object.entries(value)) {
3474
+ const at = cap(path9 === "" ? segment(key) : `${path9}.${segment(key)}`);
3475
+ if (isIdKey(key) && (isScalar(v) || Array.isArray(v) && v.length > 0 && v.every(isScalar))) {
3476
+ out.paths.add(at);
3477
+ for (const x of Array.isArray(v) ? v : [v]) noteValue(out, x, at);
3478
+ }
3479
+ walk(v, at, depth + 1, out);
3480
+ }
3481
+ }
3482
+ function scanIds(result) {
3483
+ const found = { paths: /* @__PURE__ */ new Set(), values: /* @__PURE__ */ new Map() };
3484
+ let readable = false;
3485
+ if (isRecord3(result)) {
3486
+ if (result.structuredContent !== void 0) {
3487
+ readable = true;
3488
+ walk(result.structuredContent, "", 0, found);
3489
+ }
3490
+ if (Array.isArray(result.content))
3491
+ for (const block of result.content) {
3492
+ if (!isRecord3(block) || block.type !== "text" || typeof block.text !== "string") continue;
3493
+ try {
3494
+ walk(JSON.parse(block.text), "", 0, found);
3495
+ readable = true;
3496
+ } catch {
3497
+ }
3498
+ }
3499
+ }
3500
+ if (!readable) return { unreadable: "the answer is not JSON" };
3501
+ return {
3502
+ paths: [...found.paths].sort().slice(0, MAX_PATHS),
3503
+ values: [...found.values].map(([hash, at]) => ({ hash, paths: [...at].sort() }))
3504
+ };
3505
+ }
3506
+ var list = (steps) => steps.join(", ");
3507
+ function frictionAdvice(calls) {
3508
+ const acc = /* @__PURE__ */ new Map();
3509
+ const add = (type, tool, steps, paths = [], note) => {
3510
+ const key = `${type}\0${tool}`;
3511
+ let a = acc.get(key);
3512
+ if (a === void 0) {
3513
+ a = { type, tool, steps: /* @__PURE__ */ new Set(), count: 0, paths: /* @__PURE__ */ new Set(), note };
3514
+ acc.set(key, a);
3515
+ }
3516
+ steps.forEach((s) => a.steps.add(s));
3517
+ paths.forEach((p) => a.paths.add(p));
3518
+ a.count++;
3519
+ };
3520
+ const sent = calls.filter((c) => c.executed);
3521
+ for (let j = 1; j < sent.length; j++) {
3522
+ const [prev, cur] = [sent[j - 1], sent[j]];
3523
+ if (isIdenticalCall(prev, cur)) add("identical-retry", cur.name, [prev.step, cur.step]);
3524
+ else if (isPageTurn(prev, cur)) add("pagination-continuation", cur.name, [prev.step, cur.step]);
3525
+ }
3526
+ for (const [j, cur] of sent.entries()) {
3527
+ if (cur.is_error) continue;
3528
+ const before = sent.slice(0, j).filter(
3529
+ (e) => e.step < cur.step && e.name === cur.name && !e.is_error && // The same arguments, or a page turn, is another signal and not a search after an identifier.
3530
+ !isIdenticalCall(e, cur) && !isPageTurn(e, cur)
3531
+ );
3532
+ if (before.length === 0) continue;
3533
+ const scans = [cur, ...before].map((c) => c.ids);
3534
+ const unread = scans.some((x) => x === void 0 || "unreadable" in x);
3535
+ if (unread || cur.ids === void 0 || "unreadable" in cur.ids) {
3536
+ const named = scans.find((x) => x !== void 0 && "unreadable" in x);
3537
+ const why = named !== void 0 && "unreadable" in named ? named.unreadable : "no answer was kept";
3538
+ add("friction-unmeasured", cur.name, [...before.map((e) => e.step), cur.step], [], why);
3539
+ continue;
3540
+ }
3541
+ const mine = new Map(cur.ids.values.map((v) => [v.hash, v.paths]));
3542
+ const shared = before.filter((e) => {
3543
+ const ids = e.ids;
3544
+ return ids.values.some((v) => mine.has(v.hash));
3545
+ });
3546
+ if (shared.length === 0) continue;
3547
+ const seen = new Set(
3548
+ shared.flatMap((e) => e.ids.values.map((v) => v.hash))
3549
+ );
3550
+ const paths = [...mine].filter(([h]) => seen.has(h)).flatMap(([, p]) => p);
3551
+ add("search-after-id", cur.name, [...shared.map((e) => e.step), cur.step], paths);
3552
+ }
3553
+ return [...acc.values()].map((a) => {
3554
+ const steps = [...a.steps].sort((x, y) => x - y);
3555
+ const paths = [...a.paths].sort();
3556
+ const base = {
3557
+ type: a.type,
3558
+ tool: a.tool,
3559
+ steps,
3560
+ count: a.count,
3561
+ ...paths.length > 0 ? { paths } : {}
3562
+ };
3563
+ if (a.type === "identical-retry")
3564
+ return {
3565
+ ...base,
3566
+ reason: `${a.tool} was called again ${a.count} time(s) with the same arguments right after itself (steps ${list(steps)}); this may be fine if the first call failed or the state changed in between`
3567
+ };
3568
+ if (a.type === "pagination-continuation")
3569
+ return {
3570
+ ...base,
3571
+ reason: `${a.tool} continued through a list with a new page or cursor ${a.count} time(s) (steps ${list(steps)}); this is not a repeat and may be exactly what the task needs`
3572
+ };
3573
+ if (a.type === "search-after-id")
3574
+ return {
3575
+ ...base,
3576
+ reason: `${a.tool} was called again ${a.count} time(s) with other arguments and it returned a record that an earlier step had already returned (identifier at ${paths.join(", ")}; steps ${list(steps)}); this may be fine if the model needed the record again`
3577
+ };
3578
+ return {
3579
+ ...base,
3580
+ reason: `${a.tool}: not measured, ${a.note ?? "the answer could not be read"}, so identifiers were not looked for (steps ${list(steps)}); this is not the same as finding none`
3581
+ };
3582
+ });
3583
+ }
3584
+
3218
3585
  // src/orchestrator/agent.ts
3219
3586
  var EXCERPT_BYTES = 4 * 1024;
3220
3587
  var TRANSCRIPT_BYTES = 256 * 1024;
@@ -3233,14 +3600,14 @@ var AgentError = class extends Error {
3233
3600
  }
3234
3601
  code;
3235
3602
  };
3236
- var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
3603
+ var isRecord4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
3237
3604
  function resultText(result) {
3238
- if (!isRecord2(result)) return JSON.stringify(result) ?? "";
3605
+ if (!isRecord4(result)) return JSON.stringify(result) ?? "";
3239
3606
  const content = Array.isArray(result.content) ? result.content : [];
3240
3607
  if (content.length === 0 && result.structuredContent !== void 0)
3241
3608
  return JSON.stringify(result.structuredContent);
3242
3609
  return content.map(
3243
- (b) => isRecord2(b) && b.type === "text" && typeof b.text === "string" ? b.text : JSON.stringify(b)
3610
+ (b) => isRecord4(b) && b.type === "text" && typeof b.text === "string" ? b.text : JSON.stringify(b)
3244
3611
  ).join("\n");
3245
3612
  }
3246
3613
  function excerpts() {
@@ -3262,7 +3629,7 @@ function excerpts() {
3262
3629
  function listedTools(items) {
3263
3630
  const seen = /* @__PURE__ */ new Set();
3264
3631
  return items.filter((t) => {
3265
- if (!isRecord2(t) || typeof t.name !== "string" || t.name === "" || seen.has(t.name))
3632
+ if (!isRecord4(t) || typeof t.name !== "string" || t.name === "" || seen.has(t.name))
3266
3633
  return false;
3267
3634
  seen.add(t.name);
3268
3635
  return true;
@@ -3280,13 +3647,7 @@ async function runAgentRow(p) {
3280
3647
  input_tokens: one.input_tokens * limits.max_steps,
3281
3648
  output_tokens: one.output_tokens * limits.max_steps
3282
3649
  };
3283
- return {
3284
- vars: p.row.vars,
3285
- output: null,
3286
- cached: false,
3287
- usage: { ...est, ...costFields(p.provider.estimateCost(est)) },
3288
- assertions: []
3289
- };
3650
+ return dryRunRow(p.row.vars, { ...est, ...costFields(p.provider.estimateCost(est)) });
3290
3651
  }
3291
3652
  const respond = p.provider.respond.bind(p.provider);
3292
3653
  const deadline = t0 + limits.timeout_ms;
@@ -3312,6 +3673,9 @@ async function runAgentRow(p) {
3312
3673
  let output = "";
3313
3674
  let error;
3314
3675
  let session;
3676
+ const scanned = /* @__PURE__ */ new Map();
3677
+ const overrides = p.toolDescriptions ?? {};
3678
+ const replaced = /* @__PURE__ */ new Set();
3315
3679
  try {
3316
3680
  const opening = p.connect(p.server, limits.timeout_ms);
3317
3681
  try {
@@ -3329,7 +3693,7 @@ async function runAgentRow(p) {
3329
3693
  let names = wireNames([]);
3330
3694
  let tools = [];
3331
3695
  let offeredNames = [];
3332
- const list = async () => {
3696
+ const list2 = async () => {
3333
3697
  let listed;
3334
3698
  try {
3335
3699
  listed = listedTools(await bounded(open2.listTools(limits.tool_timeout_ms)));
@@ -3348,7 +3712,7 @@ async function runAgentRow(p) {
3348
3712
  transcript.tools.push({
3349
3713
  name: t.name,
3350
3714
  offered: isOffered,
3351
- ...isRecord2(t.annotations) ? { annotations: t.annotations } : {}
3715
+ ...isRecord4(t.annotations) ? { annotations: t.annotations } : {}
3352
3716
  });
3353
3717
  }
3354
3718
  const now = offered.map((t) => t.name);
@@ -3356,14 +3720,19 @@ async function runAgentRow(p) {
3356
3720
  const removed = offeredNames.filter((n) => !now.includes(n));
3357
3721
  offeredNames = now;
3358
3722
  names = wireNames(now);
3359
- tools = offered.map((t) => ({
3360
- name: names.toWire.get(t.name),
3361
- ...typeof t.description === "string" ? { description: t.description } : {},
3362
- input_schema: isRecord2(t.inputSchema) ? t.inputSchema : { type: "object" }
3363
- }));
3723
+ tools = offered.map((t) => {
3724
+ const swap = overrides[t.name];
3725
+ if (swap !== void 0) replaced.add(t.name);
3726
+ const description = swap ?? (typeof t.description === "string" ? t.description : void 0);
3727
+ return {
3728
+ name: names.toWire.get(t.name),
3729
+ ...description !== void 0 ? { description } : {},
3730
+ input_schema: isRecord4(t.inputSchema) ? t.inputSchema : { type: "object" }
3731
+ };
3732
+ });
3364
3733
  return added.length + removed.length > 0 ? { added, removed } : void 0;
3365
3734
  };
3366
- await list();
3735
+ await list2();
3367
3736
  const messages = [{ role: "user", content: prompt5 }];
3368
3737
  let calls = 0;
3369
3738
  let tokens = 0;
@@ -3429,7 +3798,7 @@ async function runAgentRow(p) {
3429
3798
  answer(rec, c, `Tool "${c.name}" is not available.`);
3430
3799
  continue;
3431
3800
  }
3432
- if (c.args_invalid === true || !isRecord2(c.args)) {
3801
+ if (c.args_invalid === true || !isRecord4(c.args)) {
3433
3802
  Object.assign(rec, { is_error: true, error_kind: "bad-arguments" });
3434
3803
  answer(rec, c, "The arguments are not a JSON object.");
3435
3804
  continue;
@@ -3445,9 +3814,10 @@ async function runAgentRow(p) {
3445
3814
  if (got.kind === "lost") throw new AgentError("MCP_SERVER_LOST", got.message);
3446
3815
  const text = got.kind === "error" ? got.message : resultText(got.result);
3447
3816
  if (got.kind === "error") Object.assign(rec, { is_error: true, error_kind: "protocol" });
3448
- else if (isRecord2(got.result) && got.result.isError === true)
3817
+ else if (isRecord4(got.result) && got.result.isError === true)
3449
3818
  Object.assign(rec, { is_error: true, error_kind: "content" });
3450
3819
  succeeded ||= !rec.is_error;
3820
+ if (got.kind === "result" && !rec.is_error) scanned.set(rec, scanIds(got.result));
3451
3821
  rec.result = kept.cut(text);
3452
3822
  answer(rec, c, text);
3453
3823
  }
@@ -3455,7 +3825,7 @@ async function runAgentRow(p) {
3455
3825
  { role: "assistant", text: res.text, tool_calls: res.tool_calls },
3456
3826
  { role: "tool", results }
3457
3827
  );
3458
- if (succeeded) changed = await list();
3828
+ if (succeeded) changed = await list2();
3459
3829
  }
3460
3830
  } catch (err) {
3461
3831
  if (err instanceof LimitStop) transcript.stop = { reason: "limit", limit: err.limit };
@@ -3468,8 +3838,27 @@ async function runAgentRow(p) {
3468
3838
  });
3469
3839
  }
3470
3840
  if (transcript.stop.reason !== "complete" || kept.any) transcript.collection = "partial";
3841
+ const friction = error === void 0 ? frictionAdvice(
3842
+ transcript.steps.flatMap(
3843
+ (s) => s.calls.map(
3844
+ (c) => ({
3845
+ step: s.index,
3846
+ name: c.name,
3847
+ args: c.args,
3848
+ executed: c.executed,
3849
+ is_error: c.is_error,
3850
+ ...scanned.has(c) ? { ids: scanned.get(c) } : {}
3851
+ })
3852
+ )
3853
+ )
3854
+ ) : [];
3471
3855
  const mask = session?.redact;
3472
3856
  const agent = mask?.value(transcript) ?? transcript;
3857
+ if (replaced.size > 0)
3858
+ agent.description_overrides = [...replaced].sort().map((tool) => ({
3859
+ tool,
3860
+ sha256: sha256(overrides[tool])
3861
+ }));
3473
3862
  const spent = usages.length > 0 ? { usage: sumUsage(usages) } : {};
3474
3863
  if (error !== void 0) {
3475
3864
  return {
@@ -3488,7 +3877,12 @@ async function runAgentRow(p) {
3488
3877
  output,
3489
3878
  agent
3490
3879
  );
3491
- if (advice.length > 0) agent.advice = advice;
3880
+ const covered = p.assertions.filter((x) => x.type === "no-repeated-call");
3881
+ const signals = (mask?.value(friction) ?? friction).filter(
3882
+ (f) => !(f.type === "identical-retry" && covered.some((c) => c.tool === void 0 || c.tool === f.tool))
3883
+ );
3884
+ const findings = [...advice, ...signals];
3885
+ if (findings.length > 0) agent.advice = findings;
3492
3886
  const usage = sumUsage(usages);
3493
3887
  return {
3494
3888
  vars: p.row.vars,
@@ -3545,6 +3939,9 @@ function pricedField(priced) {
3545
3939
  function costFields(c) {
3546
3940
  return { cost_usd: c.cost_usd, ...pricedField(c.priced) };
3547
3941
  }
3942
+ function dryRunRow(vars, usage) {
3943
+ return { vars, output: null, cached: false, usage, inconclusive: "skipped", assertions: [] };
3944
+ }
3548
3945
  async function assess(p, output, transcript) {
3549
3946
  let judgeCost = 0;
3550
3947
  let judgeUnpriced = false;
@@ -3557,7 +3954,10 @@ async function assess(p, output, transcript) {
3557
3954
  const advice = [];
3558
3955
  let assertionError;
3559
3956
  for (const assertion of p.assertions) {
3560
- const run = () => getAssertion(assertion.type).run({
3957
+ const run = () => usesExpected(assertion) && (p.row.expected === void 0 || p.row.expected === "") ? Promise.resolve({
3958
+ passed: false,
3959
+ reason: "the row has no expected value, and this check compares against {{expected}}"
3960
+ }) : getAssertion(assertion.type).run({
3561
3961
  output,
3562
3962
  vars: p.row.vars,
3563
3963
  row: p.row,
@@ -3597,8 +3997,7 @@ async function runRow(p) {
3597
3997
  if (p.dryRun) {
3598
3998
  const est = estimateUsage(prompt5, maxTokens);
3599
3999
  const cost = p.provider.estimateCost(est);
3600
- const usage2 = { ...est, ...costFields(cost) };
3601
- return { vars: p.row.vars, output: null, cached: false, usage: usage2, assertions: [] };
4000
+ return dryRunRow(p.row.vars, { ...est, ...costFields(cost) });
3602
4001
  }
3603
4002
  const key = cacheKey(
3604
4003
  {
@@ -3821,12 +4220,11 @@ function summarize(evals, durationMs) {
3821
4220
  }
3822
4221
  return { ...summary, cache };
3823
4222
  }
3824
- function agenticProvider(config, ev, deps, cacheStrict) {
4223
+ function agenticProvider(ev, providerConfig, deps, cacheStrict) {
3825
4224
  if (cacheStrict)
3826
4225
  throw new RunConfigError(
3827
4226
  `Eval "${ev.id}" uses MCP server "${ev.mcp.server}": its tool loop is never cached, so --cache-strict cannot answer it`
3828
4227
  );
3829
- const providerConfig = { ...config.provider, ...ev.provider };
3830
4228
  const provider = deps.resolveProvider(providerConfig);
3831
4229
  if (provider.respond === void 0)
3832
4230
  throw new RunConfigError(
@@ -3853,51 +4251,77 @@ async function runOrchestration(config, options, deps) {
3853
4251
  const started = deps.now();
3854
4252
  const dryRun = options.dryRun ?? false;
3855
4253
  const evalResults = [];
4254
+ const models = config.providers ?? [config.provider];
3856
4255
  const prepared = selectEvals(config.evals, options.only).map((ev) => {
3857
4256
  const template = resolveTemplate(ev, deps.baseDir);
3858
4257
  const rows = deps.loadDataset(ev.dataset, deps.baseDir);
3859
4258
  for (const row of rows) {
3860
4259
  resolvePrompt(template, row.vars);
3861
4260
  }
3862
- const agentic = ev.mcp === void 0 || dryRun ? void 0 : agenticProvider(config, ev, deps, cacheStrict);
3863
- return { ev, template, rows, agentic };
4261
+ const cells = models.map((model) => {
4262
+ const providerConfig = { ...model, ...ev.provider };
4263
+ const agentic = ev.mcp === void 0 || dryRun ? void 0 : agenticProvider(ev, providerConfig, deps, cacheStrict);
4264
+ return { providerConfig, agentic };
4265
+ });
4266
+ return { ev, template, rows, cells };
3864
4267
  });
3865
- for (const { ev, template, rows, agentic } of prepared) {
3866
- const providerConfig = { ...config.provider, ...ev.provider };
3867
- const provider = agentic ?? deps.resolveProvider(providerConfig);
3868
- const limit2 = options.concurrency ?? providerConfig.concurrency ?? (ev.mcp !== void 0 ? 1 : 4);
3869
- const runs = options.runs ?? ev.runs ?? config.runs ?? 1;
3870
- const passThreshold = ev.pass_threshold ?? config.pass_threshold ?? 1;
3871
- const rowResults = await mapLimit(rows, limit2, (row) => {
3872
- const params = {
3873
- template,
3874
- // `defaults.assertions` apply to every eval, ahead of its own.
3875
- assertions: [...config.defaults?.assertions ?? [], ...ev.assertions],
3876
- row,
3877
- providerConfig,
3878
- provider,
3879
- embedder: deps.embedder,
3880
- cache: deps.cache,
3881
- now: deps.now,
3882
- dryRun,
3883
- noCache,
3884
- cacheStrict,
3885
- ...options.cacheMaxAgeMs !== void 0 ? { cacheMaxAgeMs: options.cacheMaxAgeMs } : {}
3886
- };
3887
- if (ev.mcp === void 0) return runRepeats(params, runs, passThreshold);
3888
- const agentParams = {
3889
- ...params,
3890
- server: ev.mcp.server,
3891
- ...ev.mcp.allowed_tools !== void 0 ? { allowedTools: ev.mcp.allowed_tools } : {},
3892
- limits: mcpLimits(config, ev),
3893
- // A dry run connects nowhere; the loop never calls this then.
3894
- connect: deps.connectMcp ?? (() => Promise.reject(new Error("no MCP connection")))
4268
+ const swapped = Object.keys(options.toolDescriptions ?? {}).length > 0;
4269
+ if (swapped && !prepared.some((x) => x.ev.mcp !== void 0))
4270
+ throw new RunConfigError(
4271
+ "--tool-description needs an eval with mcp in this run: no tool is offered otherwise"
4272
+ );
4273
+ cellLoop: for (const { ev, template, rows, cells } of prepared) {
4274
+ for (const { providerConfig, agentic } of cells) {
4275
+ const provider = agentic ?? deps.resolveProvider(providerConfig);
4276
+ const limit2 = options.concurrency ?? providerConfig.concurrency ?? (ev.mcp !== void 0 ? 1 : 4);
4277
+ const runs = options.runs ?? ev.runs ?? config.runs ?? 1;
4278
+ const passThreshold = ev.pass_threshold ?? config.pass_threshold ?? 1;
4279
+ const assertions = [...config.defaults?.assertions ?? [], ...ev.assertions];
4280
+ const rowResults = await mapLimit(rows, limit2, (row) => {
4281
+ const params = {
4282
+ template,
4283
+ assertions,
4284
+ row,
4285
+ providerConfig,
4286
+ provider,
4287
+ embedder: deps.embedder,
4288
+ cache: deps.cache,
4289
+ now: deps.now,
4290
+ dryRun,
4291
+ noCache,
4292
+ cacheStrict,
4293
+ ...options.cacheMaxAgeMs !== void 0 ? { cacheMaxAgeMs: options.cacheMaxAgeMs } : {}
4294
+ };
4295
+ if (ev.mcp === void 0) return runRepeats(params, runs, passThreshold);
4296
+ const agentParams = {
4297
+ ...params,
4298
+ server: ev.mcp.server,
4299
+ ...ev.mcp.allowed_tools !== void 0 ? { allowedTools: ev.mcp.allowed_tools } : {},
4300
+ limits: mcpLimits(config, ev),
4301
+ ...options.toolDescriptions !== void 0 ? { toolDescriptions: options.toolDescriptions } : {},
4302
+ // A dry run connects nowhere; the loop never calls this then.
4303
+ connect: deps.connectMcp ?? (() => Promise.reject(new Error("no MCP connection")))
4304
+ };
4305
+ return runRepeats(agentParams, runs, passThreshold, runAgentRow);
4306
+ });
4307
+ const passed = !dryRun && rowResults.every((r) => rowStatus(r) === "passed");
4308
+ const measured = {
4309
+ runs,
4310
+ rows: rows.length,
4311
+ rows_hash: sha256(canonicalJson(rows.map((r) => canonicalJson(r.vars)).sort())),
4312
+ assertions_hash: sha256(canonicalJson(assertions)),
4313
+ model: `${providerConfig.type}/${providerConfig.model}`
3895
4314
  };
3896
- return runRepeats(agentParams, runs, passThreshold, runAgentRow);
3897
- });
3898
- const passed = rowResults.every((r) => rowStatus(r) === "passed");
3899
- evalResults.push({ id: ev.id, tags: ev.tags ?? [], rows: rowResults, passed });
3900
- if (options.bail === true && !passed) break;
4315
+ evalResults.push({
4316
+ id: models.length > 1 ? `${ev.id}@${providerConfig.model}` : ev.id,
4317
+ tags: ev.tags ?? [],
4318
+ rows: rowResults,
4319
+ passed,
4320
+ measured,
4321
+ ...models.length > 1 ? { provider: { type: providerConfig.type, model: providerConfig.model } } : {}
4322
+ });
4323
+ if (options.bail === true && !dryRun && !passed) break cellLoop;
4324
+ }
3901
4325
  }
3902
4326
  const finished = deps.now();
3903
4327
  const summary = summarize(evalResults, finished - started);
@@ -3907,6 +4331,8 @@ async function runOrchestration(config, options, deps) {
3907
4331
  started_at: new Date(started).toISOString(),
3908
4332
  finished_at: new Date(finished).toISOString(),
3909
4333
  config_hash: configHash(config),
4334
+ // The one fact every reader of the result asks: was anything measured (plune-ai/cli#244).
4335
+ ...dryRun ? { dry_run: true } : {},
3910
4336
  summary,
3911
4337
  evals: evalResults
3912
4338
  };
@@ -3919,11 +4345,19 @@ init_cjs_shims();
3919
4345
  init_cjs_shims();
3920
4346
  var fs4 = __toESM(require("fs"), 1);
3921
4347
  var path4 = __toESM(require("path"), 1);
3922
- function loadDataset(ref, baseDir) {
3923
- if (typeof ref !== "string") {
3924
- return ref.examples;
4348
+ function loadDataset(ref5, baseDir) {
4349
+ if (typeof ref5 !== "string") {
4350
+ return ref5.examples;
4351
+ }
4352
+ const file = path4.resolve(baseDir, ref5);
4353
+ let content;
4354
+ try {
4355
+ content = fs4.readFileSync(file, "utf8");
4356
+ } catch (err) {
4357
+ throw new RunConfigError(
4358
+ err.code === "ENOENT" ? `${ref5}: dataset file not found (looked for ${file})` : `${ref5}: cannot read the dataset file (${err.message})`
4359
+ );
3925
4360
  }
3926
- const content = fs4.readFileSync(path4.resolve(baseDir, ref), "utf8");
3927
4361
  const rows = [];
3928
4362
  content.split(/\r?\n/).forEach((line, i) => {
3929
4363
  if (line.trim().length === 0) return;
@@ -3931,13 +4365,13 @@ function loadDataset(ref, baseDir) {
3931
4365
  try {
3932
4366
  row = JSON.parse(line.trim());
3933
4367
  } catch (err) {
3934
- throw new RunConfigError(`${ref}:${i + 1}: not valid JSON (${err.message})`);
4368
+ throw new RunConfigError(`${ref5}:${i + 1}: not valid JSON (${err.message})`);
3935
4369
  }
3936
4370
  const vars = isObject2(row) ? row["vars"] : void 0;
3937
4371
  if (!isObject2(vars)) {
3938
4372
  const why = isObject2(row) && "vars" in row ? `vars: Invalid input: expected record, received ${typeName(vars)}` : 'this row has no "vars"';
3939
4373
  throw new RunConfigError(
3940
- `${ref}:${i + 1}: a dataset row must be { "vars": { ... } }; ${why}`
4374
+ `${ref5}:${i + 1}: a dataset row must be { "vars": { ... } }; ${why}`
3941
4375
  );
3942
4376
  }
3943
4377
  rows.push(row);
@@ -3960,6 +4394,41 @@ var NOOP_CACHE = { get: () => void 0, set: () => {
3960
4394
  function isMockMode(env) {
3961
4395
  return env["PLUNE_MOCK_PROVIDER"] === "1";
3962
4396
  }
4397
+ var MAX_DESCRIPTION_BYTES = 64 * 1024;
4398
+ function parseToolDescriptions(values) {
4399
+ const out = {};
4400
+ for (const v of values) {
4401
+ const eq = v.indexOf("=");
4402
+ const tool = eq < 0 ? "" : v.slice(0, eq).trim();
4403
+ let text = eq < 0 ? "" : v.slice(eq + 1);
4404
+ if (tool === "" || text === "")
4405
+ throw new RunConfigError(
4406
+ `--tool-description must be <tool>=<text> or <tool>=@<file> (got "${tool === "" ? v : tool + "="}")`
4407
+ );
4408
+ if (Object.hasOwn(out, tool))
4409
+ throw new RunConfigError(`--tool-description names "${tool}" twice`);
4410
+ if (text.startsWith("@")) {
4411
+ const file = text.slice(1);
4412
+ try {
4413
+ const full = path5.resolve(file);
4414
+ const stat2 = fs5.statSync(full);
4415
+ if (!stat2.isFile())
4416
+ throw new RunConfigError(`--tool-description ${tool}: ${file} is not a file`);
4417
+ if (stat2.size > MAX_DESCRIPTION_BYTES)
4418
+ throw new RunConfigError(`--tool-description ${tool}: ${file} is over 64 KB`);
4419
+ text = fs5.readFileSync(full, "utf8").replace(/\r?\n$/, "");
4420
+ } catch (err) {
4421
+ if (err instanceof RunConfigError) throw err;
4422
+ throw new RunConfigError(`--tool-description ${tool}: cannot read ${file}`);
4423
+ }
4424
+ if (text === "") throw new RunConfigError(`--tool-description ${tool}: ${file} is empty`);
4425
+ }
4426
+ if (Buffer.byteLength(text, "utf8") > MAX_DESCRIPTION_BYTES)
4427
+ throw new RunConfigError(`--tool-description ${tool}: the text is over 64 KB`);
4428
+ out[tool] = text;
4429
+ }
4430
+ return out;
4431
+ }
3963
4432
  function mockScript(env) {
3964
4433
  const file = env["PLUNE_MOCK_SCRIPT"];
3965
4434
  if (file === void 0 || file === "") return void 0;
@@ -4024,8 +4493,10 @@ async function handleRun(options, depsFactory) {
4024
4493
  options.configPath !== void 0 ? { configPath: options.configPath } : {}
4025
4494
  );
4026
4495
  const baseDir = options.configPath !== void 0 ? path5.dirname(path5.resolve(options.configPath)) : process.cwd();
4027
- for (const warning of mcpSecretWarnings(config)) process.stderr.write(`warning: ${warning}
4496
+ for (const warning of [...mcpSecretWarnings(config), ...selfJudgeWarnings(config)])
4497
+ process.stderr.write(`warning: ${warning}
4028
4498
  `);
4499
+ const toolDescriptions = options.toolDescription !== void 0 && options.toolDescription.length > 0 ? parseToolDescriptions(options.toolDescription) : void 0;
4029
4500
  const factory = depsFactory ?? ((c, d) => buildRealDeps(c, d, options.dryRun));
4030
4501
  const deps = factory(config, baseDir);
4031
4502
  try {
@@ -4044,10 +4515,25 @@ async function handleRun(options, depsFactory) {
4044
4515
  ...options.bail !== void 0 ? { bail: options.bail } : {},
4045
4516
  ...options.cacheStrict === true ? { cacheStrict: true } : {},
4046
4517
  ...options.cacheMaxAgeMs !== void 0 ? { cacheMaxAgeMs: options.cacheMaxAgeMs } : {},
4047
- ...options.runs !== void 0 ? { runs: options.runs } : {}
4518
+ ...options.runs !== void 0 ? { runs: options.runs } : {},
4519
+ ...toolDescriptions !== void 0 ? { toolDescriptions } : {}
4048
4520
  },
4049
4521
  deps
4050
4522
  );
4523
+ for (const tool of Object.keys(toolDescriptions ?? {})) {
4524
+ const used = result.evals.some(
4525
+ (ev) => ev.rows.some(
4526
+ (r) => (r.agent?.description_overrides ?? []).some(
4527
+ (o) => o.tool === tool
4528
+ )
4529
+ )
4530
+ );
4531
+ if (!used && !options.dryRun)
4532
+ process.stderr.write(
4533
+ `warning: --tool-description ${tool}: no row offered a tool of that name, nothing was replaced
4534
+ `
4535
+ );
4536
+ }
4051
4537
  if (options.dryRun) {
4052
4538
  const agentic = new Set(config.evals.filter((ev) => ev.mcp !== void 0).map((ev) => ev.id));
4053
4539
  if (result.evals.some((ev) => agentic.has(ev.id)))
@@ -4055,7 +4541,7 @@ async function handleRun(options, depsFactory) {
4055
4541
  "dry run: an eval with mcp is priced as max_steps model calls of its prompt; tool schemas and tool results are not counted\n"
4056
4542
  );
4057
4543
  }
4058
- persist(result, baseDir);
4544
+ if (result.dry_run !== true) persist(result, baseDir);
4059
4545
  return result;
4060
4546
  } finally {
4061
4547
  deps.cache.close();
@@ -4167,7 +4653,17 @@ var rowResultSchema = import_zod3.z.object({
4167
4653
  }),
4168
4654
  collection: import_zod3.z.enum(["complete", "partial"]),
4169
4655
  /** Heuristic findings, never a verdict. Optional and additive. */
4170
- advice: import_zod3.z.array(import_zod3.z.object({ type: import_zod3.z.string(), reason: import_zod3.z.string() })).optional()
4656
+ advice: import_zod3.z.array(
4657
+ import_zod3.z.object({
4658
+ type: import_zod3.z.string(),
4659
+ reason: import_zod3.z.string(),
4660
+ tool: import_zod3.z.string().optional(),
4661
+ steps: import_zod3.z.array(import_zod3.z.number()).optional(),
4662
+ count: import_zod3.z.number().optional(),
4663
+ paths: import_zod3.z.array(import_zod3.z.string()).optional()
4664
+ })
4665
+ ).optional(),
4666
+ description_overrides: import_zod3.z.array(import_zod3.z.object({ tool: import_zod3.z.string(), sha256: import_zod3.z.string() })).optional()
4171
4667
  }).optional()
4172
4668
  });
4173
4669
  var summarySchema = import_zod3.z.object({
@@ -4192,7 +4688,17 @@ var evalResultSchema = import_zod3.z.object({
4192
4688
  id: import_zod3.z.string(),
4193
4689
  tags: import_zod3.z.array(import_zod3.z.string()),
4194
4690
  rows: import_zod3.z.array(rowResultSchema),
4195
- passed: import_zod3.z.boolean()
4691
+ passed: import_zod3.z.boolean(),
4692
+ /** What the eval measured, for the pass-rate gate of `plune diff`. Optional and additive. */
4693
+ measured: import_zod3.z.object({
4694
+ runs: import_zod3.z.number(),
4695
+ rows: import_zod3.z.number(),
4696
+ rows_hash: import_zod3.z.string(),
4697
+ assertions_hash: import_zod3.z.string(),
4698
+ model: import_zod3.z.string().optional()
4699
+ }).optional(),
4700
+ /** The type and model of a cell of a multi-model run. Optional and additive. */
4701
+ provider: import_zod3.z.object({ type: import_zod3.z.string(), model: import_zod3.z.string() }).optional()
4196
4702
  });
4197
4703
  var runResultSchema = import_zod3.z.object({
4198
4704
  schemaVersion: import_zod3.z.literal(RUN_RESULT_SCHEMA_VERSION),
@@ -4200,6 +4706,8 @@ var runResultSchema = import_zod3.z.object({
4200
4706
  started_at: import_zod3.z.string(),
4201
4707
  finished_at: import_zod3.z.string(),
4202
4708
  config_hash: import_zod3.z.string(),
4709
+ /** cli#244. The result of `--dry-run`. Optional and additive — a RunResult without it validates unchanged. */
4710
+ dry_run: import_zod3.z.boolean().optional(),
4203
4711
  summary: summarySchema,
4204
4712
  evals: import_zod3.z.array(evalResultSchema)
4205
4713
  });
@@ -4473,6 +4981,1539 @@ var path8 = __toESM(require("path"), 1);
4473
4981
  init_cjs_shims();
4474
4982
  var fs7 = __toESM(require("fs/promises"), 1);
4475
4983
  var path7 = __toESM(require("path"), 1);
4984
+
4985
+ // src/mcp-testing/scan/config/config.ts
4986
+ init_cjs_shims();
4987
+
4988
+ // src/mcp-testing/report/human.ts
4989
+ init_cjs_shims();
4990
+ init_failure_detail();
4991
+
4992
+ // src/mcp-testing/conformance/score.ts
4993
+ init_cjs_shims();
4994
+ init_exit_codes();
4995
+
4996
+ // src/mcp-testing/conformance/catalog.ts
4997
+ init_cjs_shims();
4998
+
4999
+ // src/mcp-testing/conformance/apps-catalog.ts
5000
+ init_cjs_shims();
5001
+ var BOTH = ["legacy", "modern"];
5002
+ var APPS_SPEC_URL = "https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx";
5003
+ var ref = (section) => ({
5004
+ revision: "2026-01-26",
5005
+ page: "apps.mdx",
5006
+ section,
5007
+ url: APPS_SPEC_URL
5008
+ });
5009
+ var FORMAT = "UI Resource Format";
5010
+ var DISCOVERY = "Resource Discovery";
5011
+ var apps = (s) => ({
5012
+ ...s,
5013
+ suite: "apps",
5014
+ kind: "check",
5015
+ derived: s.derived ?? false,
5016
+ needsFixture: s.needsFixture ?? false,
5017
+ transports: ["stdio", "http"],
5018
+ eras: BOTH
5019
+ });
5020
+ var APPS_CATALOG = [
5021
+ apps({
5022
+ id: "apps-ui-resource-uri-scheme",
5023
+ title: "The address of a UI resource starts with ui://",
5024
+ description: "Every _meta.ui.resourceUri a tool names is a string that starts with ui://, and so is the address of every listed resource of the MCP Apps media type.",
5025
+ level: "MUST",
5026
+ derived: true,
5027
+ derivation: 'UIResource.uri: "MUST use the `ui://` URI scheme to distinguish UI resources from other MCP resource types."; Content Requirements: "URI MUST start with `ui://` scheme". Both sentences are about the address of a UI resource; that the address a tool names in _meta.ui.resourceUri ("URI of UI resource for rendering tool results") is one, and that a listed resource of the MCP Apps media type is one, is read from the text.',
5028
+ specRefs: [ref(FORMAT), ref(DISCOVERY)]
5029
+ }),
5030
+ apps({
5031
+ id: "apps-ui-resource-exists",
5032
+ title: "The resource a tool names can be read",
5033
+ description: "resources/read of each ui:// resource a tool names in _meta.ui.resourceUri answers a result with contents. The error of the revision of the session for a resource that does not exist (-32002 up to 2025-11-25, -32602 from 2026-07-28) is a failure; any other error, and an empty contents list, say nothing of whether the resource exists and are could-not-run. Over 32 addresses, the rest are not read and the verdict is could-not-run.",
5034
+ level: "MUST",
5035
+ derived: true,
5036
+ derivation: `Resource Discovery, Behavior: "Resource MUST exist on the server". The extension text names no error for a missing resource, so which answer says it is missing is taken from the core protocol's answer to resources/read of a resource that does not exist in the revision of the session: -32002 up to 2025-11-25 (resources-read-not-found), -32602 from 2026-07-28 (mod-resource-not-found). Any other error says nothing of whether the resource exists.`,
5037
+ specRefs: [ref(DISCOVERY)]
5038
+ }),
5039
+ apps({
5040
+ id: "apps-ui-mime-type",
5041
+ title: "The content of a UI resource is text/html;profile=mcp-app",
5042
+ description: 'Each content that resources/read answers for a UI resource has the mimeType text/html;profile=mcp-app (compared as a media type: letter case and spaces around ";" do not matter).',
5043
+ level: "MUST",
5044
+ derivation: 'Content Requirements: "`mimeType` MUST be `text/html;profile=mcp-app` (other types reserved for future extensions)"',
5045
+ specRefs: [ref(FORMAT)]
5046
+ }),
5047
+ apps({
5048
+ id: "apps-ui-content-payload",
5049
+ title: "The content is one of text and blob, and is an HTML5 document",
5050
+ description: "Each content of a UI resource has exactly one of text (a string) and blob (base64), and the HTML it holds opens with an HTML5 doctype. A resource over 4 MiB, or with comments or white space past the first 2048 characters before the doctype, is not judged: could-not-run.",
5051
+ level: "MUST",
5052
+ derived: true,
5053
+ derivation: 'Content Requirements: "Content MUST be provided via either `text` (string) or `blob` (base64-encoded)" and "Content MUST be valid HTML5 document". The text gives no criterion for a valid HTML5 document (its example is `<!DOCTYPE html><html>...</html>`); this checker judges the least: the document opens with the HTML5 doctype (after a byte order mark, white space and comments). It never parses, opens or runs the HTML. "either ... or" is read as exactly one of the two.',
5054
+ specRefs: [ref(FORMAT)]
5055
+ }),
5056
+ apps({
5057
+ id: "apps-ui-listed-mime",
5058
+ title: "A listed UI resource has the mimeType text/html;profile=mcp-app",
5059
+ description: "Every ui:// resource in resources/list that has a mimeType has text/html;profile=mcp-app; a listed resource without one is not judged (the field is optional, and the sentence is about its value). A server may leave UI-only resources out of the list; then there is nothing to read.",
5060
+ level: "SHOULD",
5061
+ derivation: 'UIResource.mimeType: "SHOULD be `text/html;profile=mcp-app` for HTML-based UIs in the initial MVP."',
5062
+ specRefs: [ref(FORMAT)]
5063
+ }),
5064
+ apps({
5065
+ id: "apps-ui-visibility-values",
5066
+ title: "visibility holds only model and app",
5067
+ description: 'Where a tool sets _meta.ui.visibility, it is an array whose every element is "model" or "app".',
5068
+ level: "SHOULD",
5069
+ derived: true,
5070
+ derivation: 'No sentence says MUST or SHOULD about the values: McpUiToolMeta types visibility as `Array<"model" | "app">` and lists the two values ("`"model"`: Tool is visible to and callable by the agent", "`"app"`: Tool is callable by the app from the same server connection only"); Visibility: "`visibility` defaults to `["model", "app"]` if omitted". A requirement the text states only as a type has no keyword, so the level is SHOULD.',
5071
+ specRefs: [ref(DISCOVERY)]
5072
+ }),
5073
+ apps({
5074
+ id: "apps-ui-tool-text-fallback",
5075
+ title: "A tool with a UI also returns content",
5076
+ description: "A tool that has _meta.ui and that --fixture names is called, and its result has a content array with at least one block that says something: a text that is not blank, an image, audio, a resource or a resource link. Only the tools the fixture names are called; without one the check is could-not-run (needs-input).",
5077
+ level: "MUST",
5078
+ needsFixture: true,
5079
+ derivation: 'Graceful Degradation: "Tools MUST return meaningful content array even when UI is available". The text does not say what is meaningful; only an absent, empty or blank content is judged. A result with isError is not judged.',
5080
+ specRefs: [ref("Client<>Server Capability Negotiation")]
5081
+ }),
5082
+ apps({
5083
+ id: "apps-ui-meta-shapes",
5084
+ title: "csp, permissions, domain and prefersBorder have the shapes of the text",
5085
+ description: "In _meta.ui of a listed or read UI resource: csp is an object whose connectDomains, resourceDomains, frameDomains and baseUriDomains are arrays of strings; permissions is an object whose camera, microphone, geolocation and clipboardWrite are objects; domain is a string; prefersBorder is a boolean. A tool's _meta.ui is an object. Other members are not judged, and neither is the format of a domain (it depends on the host).",
5086
+ level: "SHOULD",
5087
+ derived: true,
5088
+ derivation: 'The shapes are those of the interfaces UIResourceMeta and McpUiResourceCsp; no sentence says MUST or SHOULD about them. For domain the text says "Servers MUST consult host-specific documentation for the expected domain format", which no check can read. A requirement the text states only as a type has no keyword, so the level is SHOULD.',
5089
+ specRefs: [ref(FORMAT)]
5090
+ })
5091
+ ];
5092
+
5093
+ // src/mcp-testing/conformance/auth-catalog.ts
5094
+ init_cjs_shims();
5095
+ var L = "2025-11-25";
5096
+ var M = "2026-07-28";
5097
+ var BOTH2 = ["legacy", "modern"];
5098
+ var MODERN = ["modern"];
5099
+ var ref2 = (revision, page, section) => ({
5100
+ revision,
5101
+ page,
5102
+ section
5103
+ });
5104
+ var AUTH = "basic/authorization";
5105
+ var DISCOVERY2 = "basic/authorization/authorization-server-discovery";
5106
+ var SECURITY = "basic/authorization/security-considerations";
5107
+ var REGISTRATION = "basic/authorization/client-registration";
5108
+ var oauth = (s) => ({
5109
+ ...s,
5110
+ suite: "oauth",
5111
+ kind: "check",
5112
+ derived: s.derived ?? false,
5113
+ needsFixture: s.needsFixture ?? false,
5114
+ transports: ["http"]
5115
+ });
5116
+ var OAUTH_CATALOG = [
5117
+ oauth({
5118
+ id: "oauth-requires-auth",
5119
+ title: "A request without a token gets 401",
5120
+ description: "The MCP endpoint, asked without a token, answers 401 Unauthorized. A 2xx answer means the server is public: every check of the suite is then not-applicable (no-auth).",
5121
+ level: "MUST",
5122
+ specRefs: [ref2(L, AUTH, "Error Handling"), ref2(M, AUTH, "Error Handling")],
5123
+ eras: BOTH2
5124
+ }),
5125
+ oauth({
5126
+ id: "oauth-challenge-bearer",
5127
+ title: "The 401 carries a Bearer challenge",
5128
+ description: "The 401 answer has a WWW-Authenticate header with the scheme Bearer.",
5129
+ level: "MUST",
5130
+ derived: true,
5131
+ derivation: `RFC 6750 section 3: "All challenges defined by this specification MUST use the auth-scheme value Bearer"; basic/authorization, Protected Resource Metadata Discovery Requirements: clients MUST be able to parse WWW-Authenticate headers of 401 answers. No MCP sentence says MUST about the scheme of the server's challenge.`,
5132
+ specRefs: [
5133
+ ref2(L, AUTH, "Protected Resource Metadata Discovery Requirements"),
5134
+ ref2(M, DISCOVERY2, "Protected Resource Metadata Discovery Requirements")
5135
+ ],
5136
+ eras: BOTH2
5137
+ }),
5138
+ oauth({
5139
+ id: "oauth-prm-reachable",
5140
+ title: "The protected resource metadata can be found",
5141
+ description: "The server implements at least one of the two mechanisms: resource_metadata in WWW-Authenticate, or a document at the RFC 9728 well-known URI (with the path of the endpoint, or at the root). At least one of them serves a JSON document.",
5142
+ level: "MUST",
5143
+ specRefs: [
5144
+ ref2(L, AUTH, "Protected Resource Metadata Discovery Requirements"),
5145
+ ref2(M, DISCOVERY2, "Protected Resource Metadata Discovery Requirements")
5146
+ ],
5147
+ eras: BOTH2
5148
+ }),
5149
+ oauth({
5150
+ id: "oauth-challenge-metadata-url",
5151
+ title: "resource_metadata names a URL that serves the document",
5152
+ description: "When WWW-Authenticate has resource_metadata, it is an absolute URL and it answers 200 with a JSON object. A challenge without the parameter is not a violation: the well-known URI is the other mechanism.",
5153
+ level: "MUST",
5154
+ derived: true,
5155
+ derivation: 'RFC 9728 section 5.1 defines resource_metadata as "the URL of the protected resource metadata". The MCP text makes the parameter one of two mechanisms, so only a parameter that is present is judged.',
5156
+ specRefs: [
5157
+ ref2(L, AUTH, "Protected Resource Metadata Discovery Requirements"),
5158
+ ref2(M, DISCOVERY2, "Protected Resource Metadata Discovery Requirements")
5159
+ ],
5160
+ eras: BOTH2
5161
+ }),
5162
+ oauth({
5163
+ id: "oauth-prm-valid",
5164
+ title: "The protected resource metadata names an authorization server",
5165
+ description: "The document is a JSON object whose authorization_servers lists at least one URL, and whose resource is the URL of the server under test (or the resource named in the configuration).",
5166
+ level: "MUST",
5167
+ derived: true,
5168
+ derivation: `authorization_servers: quoted ("MUST include the authorization_servers field containing at least one authorization server"). resource: RFC 9728 section 3.3 ("The resource value returned MUST be identical to the protected resource's resource identifier"), read from the RFC, not from the MCP text.`,
5169
+ specRefs: [
5170
+ ref2(L, AUTH, "Authorization Server Location"),
5171
+ ref2(M, DISCOVERY2, "Authorization Server Location")
5172
+ ],
5173
+ eras: BOTH2
5174
+ }),
5175
+ oauth({
5176
+ id: "oauth-challenge-scope",
5177
+ title: "The 401 names the scope it needs",
5178
+ description: "WWW-Authenticate has a scope parameter.",
5179
+ level: "SHOULD",
5180
+ specRefs: [
5181
+ ref2(L, AUTH, "Protected Resource Metadata Discovery Requirements"),
5182
+ ref2(M, AUTH, "Scope Selection Strategy")
5183
+ ],
5184
+ eras: BOTH2
5185
+ }),
5186
+ oauth({
5187
+ id: "oauth-as-metadata-discoverable",
5188
+ title: "The authorization server publishes metadata",
5189
+ description: "For the first authorization_servers entry, a JSON document is served at one of the well-known locations in the order of the specification: RFC 8414 and OpenID Connect Discovery with the path inserted, OpenID Connect Discovery with the path appended (an issuer with a path), or RFC 8414 and OpenID Connect Discovery at the root (an issuer without one).",
5190
+ level: "MUST",
5191
+ specRefs: [
5192
+ ref2(L, AUTH, "Authorization Server Metadata Discovery"),
5193
+ ref2(M, DISCOVERY2, "Authorization Server Metadata Discovery")
5194
+ ],
5195
+ eras: BOTH2
5196
+ }),
5197
+ oauth({
5198
+ id: "oauth-as-issuer-matches",
5199
+ title: "The issuer of the metadata is the issuer it was found by",
5200
+ description: "The issuer member of the metadata document is identical, character for character, to the issuer identifier the well-known URL was built from.",
5201
+ level: "MUST",
5202
+ derived: true,
5203
+ derivation: '2026-07-28 authorization-server-discovery quotes the rule as a duty of the client ("the issuer value in the document MUST be identical to the issuer identifier used to construct the well-known URL"), from RFC 8414 section 3.3; that the server serves such a document is derived. 2025-11-25 has no such sentence, so the check is for the modern era only.',
5204
+ specRefs: [ref2(M, DISCOVERY2, "Authorization Server Metadata Discovery")],
5205
+ eras: MODERN
5206
+ }),
5207
+ oauth({
5208
+ id: "oauth-as-https",
5209
+ title: "The authorization endpoints are HTTPS",
5210
+ description: "The authorization, token and registration endpoints in the metadata are https URLs. An authorization server on a loopback name is not-applicable: the test setup of a local server.",
5211
+ level: "MUST",
5212
+ specRefs: [ref2(L, AUTH, "Communication Security"), ref2(M, SECURITY, "Communication Security")],
5213
+ eras: BOTH2
5214
+ }),
5215
+ oauth({
5216
+ id: "oauth-as-pkce-advertised",
5217
+ title: "The authorization server advertises PKCE",
5218
+ description: "The metadata has code_challenge_methods_supported.",
5219
+ level: "MUST",
5220
+ derived: true,
5221
+ derivation: 'Authorization Code Protection: "If code_challenge_methods_supported is absent, the authorization server does not support PKCE and MCP clients MUST refuse to proceed" (a duty of the client); "Authorization servers providing OpenID Connect Discovery MUST include code_challenge_methods_supported in their metadata" (quoted, for those servers only).',
5222
+ specRefs: [
5223
+ ref2(L, AUTH, "Authorization Code Protection"),
5224
+ ref2(M, SECURITY, "Authorization Code Protection")
5225
+ ],
5226
+ eras: BOTH2
5227
+ }),
5228
+ oauth({
5229
+ id: "oauth-as-pkce-s256",
5230
+ title: "PKCE with S256 is advertised",
5231
+ description: "code_challenge_methods_supported lists S256.",
5232
+ level: "SHOULD",
5233
+ derived: true,
5234
+ derivation: "The text says clients MUST use S256 when technically capable; that the server lists it is derived. The specification checks only that the field is present.",
5235
+ specRefs: [
5236
+ ref2(L, AUTH, "Authorization Code Protection"),
5237
+ ref2(M, SECURITY, "Authorization Code Protection")
5238
+ ],
5239
+ eras: BOTH2
5240
+ }),
5241
+ oauth({
5242
+ id: "oauth-as-iss-advertised",
5243
+ title: "The authorization server advertises the iss parameter",
5244
+ description: "The metadata has authorization_response_iss_parameter_supported: true.",
5245
+ level: "SHOULD",
5246
+ specRefs: [ref2(M, AUTH, "Authorization Response Validation")],
5247
+ eras: MODERN
5248
+ }),
5249
+ oauth({
5250
+ id: "oauth-as-cimd-advertised",
5251
+ title: "The authorization server advertises Client ID Metadata Documents",
5252
+ description: "The metadata has client_id_metadata_document_supported: true.",
5253
+ level: "SHOULD",
5254
+ specRefs: [
5255
+ ref2(L, AUTH, "Client ID Metadata Documents"),
5256
+ ref2(M, REGISTRATION, "Client ID Metadata Documents")
5257
+ ],
5258
+ eras: BOTH2
5259
+ }),
5260
+ oauth({
5261
+ id: "oauth-neg-invalid-token-401",
5262
+ title: "A token that is not valid gets 401",
5263
+ description: "A request with a bearer token the authorization server never issued answers 401.",
5264
+ level: "MUST",
5265
+ specRefs: [ref2(L, AUTH, "Token Handling"), ref2(M, AUTH, "Token Handling")],
5266
+ eras: BOTH2
5267
+ }),
5268
+ oauth({
5269
+ id: "oauth-neg-wrong-audience",
5270
+ title: "A token issued for another resource is refused",
5271
+ description: "A token the authorization server issued for another resource (the resource parameter names a different URL) gets 401 from the server under test, while a token issued for the server itself is accepted (the control: a server that refuses every token proves nothing). Needs credentials the authorization server accepts for the client-credentials grant, given in --config.",
5272
+ level: "MUST",
5273
+ specRefs: [
5274
+ ref2(L, AUTH, "Token Handling"),
5275
+ ref2(L, AUTH, "Access Token Privilege Restriction"),
5276
+ ref2(M, AUTH, "Token Handling"),
5277
+ ref2(M, SECURITY, "Token Audience Binding and Validation")
5278
+ ],
5279
+ eras: BOTH2,
5280
+ needsFixture: true
5281
+ }),
5282
+ oauth({
5283
+ id: "oauth-e2e-token-works",
5284
+ title: "A token issued for the server is accepted",
5285
+ description: "With the client-credentials grant given in --config, the client asks the token endpoint of the authorization server for a token for the server (the resource parameter), and makes the one request the suite uses to tell a protected server from an open one with it. The request that got 401 without a token must now succeed. A 2xx is a pass. A 401 is a failure only when the token is of type Bearer, is a JWT whose aud holds the resource asked for, and the challenge does not name insufficient_scope; in every other case (another token type, an opaque token or an aud that does not show the audience, insufficient_scope, a token endpoint that refuses the client, 403 or another answer) the check is could-not-run. The token is masked in every output and is not revoked.",
5286
+ level: "MUST",
5287
+ derived: true,
5288
+ derivation: 'Token Handling quotes "MCP servers MUST only accept tokens that are valid for use with their own resources" and "Invalid or expired tokens MUST receive a HTTP 401 response". That a token is valid for the server is not a given: the check verifies from the token what it can (a Bearer token type, and a JWT aud that holds the resource asked for) and, when it cannot, the verdict is could-not-run. A 401 to a token so shown is the converse of what is quoted: derived, and not higher than the quoted MUST. Assumption stated: clock skew between the authorization server and the server cannot be told apart from a refusal.',
5289
+ specRefs: [ref2(L, AUTH, "Token Handling"), ref2(M, AUTH, "Token Handling")],
5290
+ eras: BOTH2,
5291
+ needsFixture: true
5292
+ }),
5293
+ oauth({
5294
+ id: "oauth-neg-insufficient-scope",
5295
+ title: "A token with too narrow a scope gets 403 with insufficient_scope",
5296
+ description: 'With the client-credentials grant and narrowScopes given in --config, a token with the full scopes is asked for first and must be accepted by the one request the suite uses to tell a protected server from an open one (the control). A token with narrowScopes, which the operator says is not enough for the endpoint, is then asked for and sent with the same request: 403 with a Bearer challenge that names error="insufficient_scope" is a pass; 401, or 403 without that error, is a failure of a SHOULD. A 2xx cannot be judged, because the request the suite makes may not need the wider scope: it is could-not-run, as is a token endpoint that does not issue a narrower token. Both tokens are masked in every output and are not revoked.',
5297
+ level: "SHOULD",
5298
+ derived: true,
5299
+ derivation: `Runtime Insufficient Scope Errors says: "When a client makes a request with an access token with insufficient scope during runtime operations, the server SHOULD respond with: HTTP 403 Forbidden status code (per RFC 6750 Section 3.1)" and a WWW-Authenticate header with the Bearer scheme and the parameter error="insufficient_scope". The wording is the same in both revisions. That a token is insufficient is not known from outside: it is what narrowScopes says in --config, so the check asks for the narrow token only when the full-scope token is accepted and the authorization server has issued a narrower one, and takes the operator's word that the endpoint needs the wider scope. The level is that of the quoted SHOULD.`,
5300
+ specRefs: [
5301
+ ref2(L, AUTH, "Runtime Insufficient Scope Errors"),
5302
+ ref2(M, AUTH, "Runtime Insufficient Scope Errors")
5303
+ ],
5304
+ eras: BOTH2,
5305
+ needsFixture: true
5306
+ }),
5307
+ oauth({
5308
+ id: "oauth-authz-response-iss",
5309
+ title: "iss in the authorization response is the issuer, and is advertised",
5310
+ description: 'With auth "headless" and a pre-registered client in --config, one authorization request is made. Where the test environment answers with a redirect that carries a code, the iss of that redirect is read: if present it must be the issuer of the metadata, exactly, and the metadata must advertise authorization_response_iss_parameter_supported: true; if the metadata advertises it, iss must be present. Where the endpoint shows a sign-in, the check is could-not-run (needs-input). The code is not exchanged; it expires on the server.',
5311
+ level: "MUST",
5312
+ derived: true,
5313
+ derivation: 'Authorization Response Validation says: "Authorization servers that include the iss parameter MUST advertise this by setting authorization_response_iss_parameter_supported to true in their metadata (RFC9207 Section 2.3)", and gives the rows a client applies: advertised and iss absent is rejected, and a present iss is compared with the recorded issuer by simple string comparison. That a server sends an iss equal to its issuer, and sends one when it advertises, is the converse of those client rules and of RFC 9207 section 2, which is not in the saved text: derived. The level is that of the quoted MUST; the text also says "MCP authorization servers SHOULD include the iss parameter in authorization responses", which is why a server that sends none and advertises none is not-applicable, not failed.',
5314
+ specRefs: [ref2(M, AUTH, "Authorization Response Validation")],
5315
+ eras: MODERN,
5316
+ needsFixture: true
5317
+ }),
5318
+ oauth({
5319
+ id: "oauth-neg-pkce-wrong-verifier",
5320
+ title: "A code exchanged with a wrong code_verifier is refused",
5321
+ description: 'With auth "headless" and a pre-registered client, a correct exchange (the control) must give a token; then a fresh code, sent with a code_verifier that does not match its code_challenge, must be refused. A token for the wrong verifier is a failure. Where the endpoint shows a sign-in, the check is could-not-run (needs-input). Every token issued is reported as issued and not revoked.',
5322
+ level: "MUST",
5323
+ derived: true,
5324
+ derivation: 'Authorization Code Protection says "MCP clients MUST implement PKCE according to OAuth 2.1 Section 7.5.2" and that PKCE ensures "that only the original requestor can exchange an authorization code for tokens". Those sentences are about the client and the purpose; that a server checks the verifier is RFC 7636 section 4.6, which is not in the saved text: derived. The level is not higher than the quoted MUST.',
5325
+ specRefs: [
5326
+ ref2(L, AUTH, "Authorization Code Protection"),
5327
+ ref2(M, SECURITY, "Authorization Code Protection")
5328
+ ],
5329
+ eras: BOTH2,
5330
+ needsFixture: true
5331
+ }),
5332
+ oauth({
5333
+ id: "oauth-neg-token-redirect-mismatch",
5334
+ title: "A code exchanged with another redirect_uri is refused as such",
5335
+ description: 'With auth "headless" and a pre-registered client, after the control exchange a fresh code is sent to the token endpoint with a redirect_uri other than the one of the authorization request. A token is a failure. A refusal whose answer names the redirect_uri is a pass; a bare invalid_grant does not show that the redirect_uri was compared and is could-not-run, not passed. Where the endpoint shows a sign-in, the check is could-not-run (needs-input).',
5336
+ level: "MUST",
5337
+ derived: true,
5338
+ derivation: 'Open Redirection says "Authorization servers MUST validate exact redirect URIs against pre-registered values to prevent redirection attacks" about the authorization request. That the token endpoint compares the redirect_uri of the exchange with the one of the authorization request is RFC 6749 section 4.1.3, which is not in the saved text: derived. The level is not higher than the quoted MUST.',
5339
+ specRefs: [ref2(L, AUTH, "Open Redirection"), ref2(M, SECURITY, "Open Redirection")],
5340
+ eras: BOTH2,
5341
+ needsFixture: true
5342
+ }),
5343
+ oauth({
5344
+ id: "oauth-reg-prereg",
5345
+ title: "A pre-registered client is accepted",
5346
+ description: "The client_id of a pre-registered client (from --config) is accepted at the authorization endpoint: the request is answered with a redirect that carries no error, not with invalid_client. Only the client_id and the redirect URI are sent; no secret goes to the authorization endpoint. A page that shows a sign-in cannot be told from one that shows an error, and is could-not-run.",
5347
+ level: "SHOULD",
5348
+ derived: true,
5349
+ derivation: 'The text says "MCP clients SHOULD support an option for static client credentials such as those supplied by a pre-registration flow", a duty of the client. That a server accepts such a client is derived, and its level is not higher than the quoted SHOULD.',
5350
+ specRefs: [ref2(L, AUTH, "Preregistration"), ref2(M, REGISTRATION, "Pre-registration")],
5351
+ eras: BOTH2
5352
+ }),
5353
+ oauth({
5354
+ id: "oauth-reg-dcr",
5355
+ title: "Dynamic client registration works",
5356
+ description: "When the metadata names a registration_endpoint and --config allows a client to be created, a registration (RFC 7591) with a correct body (application_type native, a loopback redirect URI) answers 201 with a client_id. The client is deleted afterwards (RFC 7592) when the server gave the means; otherwise the report names the client that remains on the authorization server. In 2026-07-28 the method is deprecated in favour of Client ID Metadata Documents.",
5357
+ level: "MAY",
5358
+ specRefs: [
5359
+ ref2(L, AUTH, "Dynamic Client Registration"),
5360
+ ref2(M, REGISTRATION, "Dynamic Client Registration")
5361
+ ],
5362
+ eras: BOTH2
5363
+ }),
5364
+ oauth({
5365
+ id: "oauth-reg-dcr-http-redirect-rejected",
5366
+ title: "A redirect over http outside loopback is not registered",
5367
+ description: "A registration whose redirect URI is http on a name that is not loopback is refused, while the same registration with a loopback redirect URI (the control) is accepted. A client made by a server that accepts the fault is deleted, or named in the report when it cannot be.",
5368
+ level: "MUST",
5369
+ derived: true,
5370
+ derivation: 'Communication Security: "All redirect URIs MUST be either localhost or use HTTPS." The sentence is about redirect URIs; that an authorization server refuses to register one is derived.',
5371
+ specRefs: [
5372
+ ref2(L, AUTH, "Communication Security"),
5373
+ ref2(L, AUTH, "Open Redirection"),
5374
+ ref2(M, SECURITY, "Communication Security"),
5375
+ ref2(M, SECURITY, "Open Redirection")
5376
+ ],
5377
+ eras: BOTH2
5378
+ }),
5379
+ oauth({
5380
+ id: "oauth-reg-cimd",
5381
+ title: "A client_id that is a URL is read as a document",
5382
+ description: "When the metadata advertises client_id_metadata_document_supported, the client_id URL of a document the user hosts (--config registration.clientIdMetadataUrl) is accepted at the authorization endpoint, and the URL of a document whose client_id does not match it (clientIdMetadataMismatchUrl) is refused. Without the second URL only the first half is seen, and the check is could-not-run.",
5383
+ level: "MUST",
5384
+ derived: true,
5385
+ derivation: 'Authorization servers "MUST validate that the fetched document\u2019s client_id matches the URL exactly" (quoted). That a server takes a good document and completes the authorization is derived.',
5386
+ specRefs: [
5387
+ ref2(L, AUTH, "Client ID Metadata Documents"),
5388
+ ref2(M, REGISTRATION, "Client ID Metadata Documents")
5389
+ ],
5390
+ eras: BOTH2,
5391
+ needsFixture: true
5392
+ }),
5393
+ oauth({
5394
+ id: "oauth-token-format",
5395
+ title: "The token response has access_token and token_type Bearer",
5396
+ description: "The answer of the token endpoint (client-credentials, from --config) is a JSON object with access_token and token_type Bearer (the value is case insensitive). An absent expires_in is said in the result but does not fail the check: RFC 6749 only recommends it. A token_type other than Bearer (for example DPoP) fails the check: the text of MCP has the token sent as Authorization: Bearer.",
5397
+ level: "MUST",
5398
+ derived: true,
5399
+ derivation: 'RFC 6749 section 5.1: access_token and token_type are REQUIRED, expires_in is RECOMMENDED; the Token Requirements of the specification use the token as "Authorization: Bearer". No MCP sentence says MUST about the response of the token endpoint.',
5400
+ specRefs: [ref2(L, AUTH, "Token Requirements"), ref2(M, AUTH, "Token Requirements")],
5401
+ eras: BOTH2,
5402
+ needsFixture: true
5403
+ }),
5404
+ oauth({
5405
+ id: "oauth-neg-invalid-client",
5406
+ title: "A client that does not exist is not accepted",
5407
+ description: "A made-up client_id is not accepted at the authorization endpoint (it is not redirected to the redirect URI, with a code or with an error) and, when --config has client credentials, a made-up client is not given a token at the token endpoint (HTTP 400 or 401). The pre-registered client is the control for each half: it must not be refused. A server that sends every client to a sign-in page cannot be judged. The made-up client sends made-up credentials, never the real ones.",
5408
+ level: "MUST",
5409
+ derived: true,
5410
+ derivation: 'RFC 6749 section 4.1.2.1: if "the client identifier is missing or invalid, the authorization server SHOULD inform the resource owner of the error and MUST NOT automatically redirect the user-agent to the invalid redirection URI" (the authorization half); section 5.2: invalid_client is "Client authentication failed (e.g., unknown client...)" (the token half, which has no MUST of its own). The MCP text says only that authorization servers "MUST validate exact redirect URIs against pre-registered values" (Open Redirection).',
5411
+ specRefs: [ref2(L, AUTH, "Open Redirection"), ref2(M, SECURITY, "Open Redirection")],
5412
+ eras: BOTH2,
5413
+ needsFixture: true
5414
+ }),
5415
+ oauth({
5416
+ id: "oauth-neg-authorize-redirect-mismatch",
5417
+ title: "A redirect URI that is not registered is not redirected to",
5418
+ description: "An authorization request with the pre-registered client and a redirect URI that is not registered (https://plune-conformance-other.invalid/callback, never a real host and never followed) is not answered with a redirect to that URI, neither with a code nor with an error. The same request with the registered redirect URI is the control: it must not be refused. A redirect to a sign-in page of the server that only carries the other URI in a parameter is not a violation, and cannot be judged either.",
5419
+ level: "MUST",
5420
+ derived: false,
5421
+ derivation: 'Open Redirection: "Authorization servers MUST validate exact redirect URIs against pre-registered values to prevent redirection attacks." RFC 6749 section 4.1.2.1: if the request fails due to a missing, invalid, or mismatching redirection URI, the server "MUST NOT automatically redirect the user-agent to the invalid redirection URI."',
5422
+ specRefs: [ref2(L, AUTH, "Open Redirection"), ref2(M, SECURITY, "Open Redirection")],
5423
+ eras: BOTH2,
5424
+ needsFixture: true
5425
+ })
5426
+ ];
5427
+
5428
+ // src/mcp-testing/conformance/tasks-catalog.ts
5429
+ init_cjs_shims();
5430
+ var TASKS_SPEC_URL = "https://github.com/modelcontextprotocol/ext-tasks/blob/main/specification/2026-07-28/tasks.md";
5431
+ var MODERN2 = ["modern"];
5432
+ var ref3 = (section) => ({
5433
+ revision: "2026-07-28",
5434
+ page: "tasks.md",
5435
+ section,
5436
+ url: TASKS_SPEC_URL
5437
+ });
5438
+ var tasks = (s) => ({
5439
+ ...s,
5440
+ suite: "tasks",
5441
+ kind: "check",
5442
+ derived: s.derived ?? false,
5443
+ // Every check reads a task, and a task comes from a tool the user names in --fixture.
5444
+ needsFixture: s.needsFixture ?? true,
5445
+ transports: s.transports ?? ["stdio", "http"],
5446
+ eras: MODERN2
5447
+ });
5448
+ var TASKS_CATALOG = [
5449
+ tasks({
5450
+ id: "tasks-result-type",
5451
+ title: 'A task handle has resultType "task", and no other result has it',
5452
+ description: 'The result of the --fixture call that made a task has resultType "task", a string taskId and a status of the specification. A result that carries a task handle (a string taskId and a status) without resultType "task" fails; so does any other result the run got (server/discover, tools/list, tasks/get, a call that made no task) that has resultType "task".',
5453
+ level: "MUST",
5454
+ derivation: 'Polymorphic Results: "Servers **MUST** set `resultType` to `"task"` when returning a `CreateTaskResult` so that clients can distinguish it from a standard result. Servers **MUST NOT** set `resultType` to `"task"` on result types other than `CreateTaskResult`."',
5455
+ specRefs: [ref3("Polymorphic Results"), ref3("Task Creation")]
5456
+ }),
5457
+ tasks({
5458
+ id: "tasks-undeclared-no-task",
5459
+ title: "A client that did not declare the extension is given no task",
5460
+ description: "The --fixture call that made a task for a client that declared the extension is sent once more without the declaration. The answer is not a task handle (a result of another kind, or an error, is not judged further). The first call, the control, has to have made a task: otherwise the check is could-not-run.",
5461
+ level: "MUST",
5462
+ derivation: 'Capability Negotiation: "A server **MUST NOT** return `CreateTaskResult` to a client that did not include the extension capability on its request, regardless of prior declarations."',
5463
+ specRefs: [ref3("Capability Negotiation")]
5464
+ }),
5465
+ tasks({
5466
+ id: "tasks-undeclared-capability-error",
5467
+ title: "tasks/get, tasks/update and tasks/cancel without the declaration are -32021",
5468
+ description: "Each of the three methods, sent for the task the run made but without the extension in the client capabilities, is answered with the error -32021 whose data.requiredCapabilities.extensions names io.modelcontextprotocol/tasks. The same tasks/get with the declaration has to be accepted (the control). The run may cancel its own task this way if the server accepts the request.",
5469
+ level: "MUST",
5470
+ derivation: 'Protocol Errors: "Servers **MUST** return this error for non-declaring clients issuing `tasks/get`, `tasks/update`, and `tasks/cancel` requests." with "Missing required client capabilities: `-32021` (Missing Required Client Capability)". The error shape (data.requiredCapabilities) is the example of Capability Negotiation: no sentence says MUST about data.',
5471
+ specRefs: [ref3("Protocol Errors"), ref3("Capability Negotiation")]
5472
+ }),
5473
+ tasks({
5474
+ id: "tasks-get-status-shape",
5475
+ title: 'tasks/get answers a task with resultType "complete" and the fields of a task',
5476
+ description: 'Each tasks/get answer of the run is a result with resultType "complete", the taskId asked for, one of the five statuses (working, input_required, completed, failed, cancelled), createdAt and lastUpdatedAt as ISO 8601 date-times, and a ttlMs member. At most 6 polls of one task, within 5 seconds, by the pollIntervalMs the server gives kept between 20 and 1000 ms.',
5477
+ level: "MUST",
5478
+ derived: true,
5479
+ derivation: 'Response: "The `resultType` field **MUST** be set to `"complete"` on this object as it is the standard result shape for the `tasks/get` request." and "the server **MUST** return a a `Task` object with status `working`". The required fields (taskId, status, createdAt, lastUpdatedAt, ttlMs) are those of the interface Task, which no sentence with a keyword repeats; the set of statuses is that of "Tasks can be in one of the following states".',
5480
+ specRefs: [ref3("Task Polling"), ref3("Tasks")]
5481
+ }),
5482
+ tasks({
5483
+ id: "tasks-status-payload",
5484
+ title: "completed has a result, failed an error, input_required inputRequests",
5485
+ description: "Of the tasks/get answers the run got: one with status completed has a result object, one with failed has an error object, one with input_required has an inputRequests object. A status the run never saw is not judged; if it saw none of the three, the check is not-applicable (not-offered).",
5486
+ level: "MUST",
5487
+ derivation: 'Response: "If the status is `input_required`, the server **MUST** return a `Task` object with status `input_required` and an `inputRequests` field"; "If the status is `completed`, the server **MUST** return a `Task` object with status `completed` and a `result` field containing the final result of the task."; "If the status is `failed`, the server **MUST** return a `Task` object with status `failed` and the error that occurred during execution."',
5488
+ specRefs: [ref3("Task Polling")]
5489
+ }),
5490
+ tasks({
5491
+ id: "tasks-ttl-poll-integers",
5492
+ title: "ttlMs is an integer or null, pollIntervalMs an integer",
5493
+ description: "In the task handle and in each tasks/get answer, ttlMs is an integer (milliseconds) or null, and pollIntervalMs, when present, is an integer. A fraction, a string or a missing ttlMs fails.",
5494
+ level: "SHOULD",
5495
+ derived: true,
5496
+ derivation: 'No sentence says MUST or SHOULD about the types: the interface Task has "ttlMs: number | null;" with "Time-to-live duration from creation in integer milliseconds, null for unlimited." and "pollIntervalMs?: number;" with "Suggested polling interval in integer milliseconds." (schema.ts adds `@format int`). A requirement the text states only as a type has no keyword, so the level is SHOULD.',
5497
+ specRefs: [ref3("Tasks")]
5498
+ }),
5499
+ tasks({
5500
+ id: "tasks-unknown-id-get",
5501
+ title: "tasks/get for an unknown taskId is -32602",
5502
+ description: "tasks/get for a taskId the server never made answers the error -32602. The same request for the task the run made has to be accepted (the control).",
5503
+ level: "MUST",
5504
+ derivation: 'Protocol Errors: "Invalid or nonexistent `taskId`: `-32602` (Invalid params)" and "Servers **MUST** return this error for `tasks/get`."',
5505
+ specRefs: [ref3("Protocol Errors")]
5506
+ }),
5507
+ tasks({
5508
+ id: "tasks-unknown-id-update-cancel",
5509
+ title: "tasks/update and tasks/cancel for an unknown taskId are -32602",
5510
+ description: "tasks/update and tasks/cancel for a taskId the server never made answer the error -32602. The same requests for a task the run made have to be accepted (the controls: tasks-update-ack and tasks-cancel-ack).",
5511
+ level: "SHOULD",
5512
+ derivation: 'Protocol Errors: "Servers **SHOULD** return this error for `tasks/update` and `tasks/cancel`."',
5513
+ specRefs: [ref3("Protocol Errors")]
5514
+ }),
5515
+ tasks({
5516
+ id: "tasks-cancel-ack",
5517
+ title: "tasks/cancel is acknowledged with an empty result",
5518
+ description: 'tasks/cancel for a task the run made (a second one, not polled before) answers a result with resultType "complete" and nothing else but _meta. An error is a failure only when tasks/get shows the task still working or input_required; for a task that already ended it says nothing and is could-not-run.',
5519
+ level: "MUST",
5520
+ derivation: 'Task Cancellation: "On success, the server **MUST** acknowledge the request with an empty result." and "The `resultType` field **MUST** be set to `"complete"` on `CancelTaskResult` as it is the standard result shape for the `tasks/cancel` request."',
5521
+ specRefs: [ref3("Task Cancellation")]
5522
+ }),
5523
+ tasks({
5524
+ id: "tasks-update-ack",
5525
+ title: "tasks/update is acknowledged with an empty result",
5526
+ description: 'tasks/update with an empty inputResponses map for a task the run made answers a result with resultType "complete" and nothing else but _meta. An error says nothing about the acknowledgement (no key is outstanding, which the text says a server SHOULD ignore): could-not-run.',
5527
+ level: "MUST",
5528
+ derivation: 'Task Update Requests: "On success, the server **MUST** acknowledge the request with an empty result." and "The `resultType` field **MUST** be set to `"complete"` on `UpdateTaskResult` as it is the standard result shape for the `tasks/update` request."',
5529
+ specRefs: [ref3("Task Update Requests")]
5530
+ }),
5531
+ tasks({
5532
+ id: "tasks-failed-status-message",
5533
+ title: "A failed task has a statusMessage",
5534
+ description: "A tasks/get answer with status failed has a statusMessage string. If the run saw no failed task, the check is not-applicable (not-offered).",
5535
+ level: "SHOULD",
5536
+ derivation: 'Task Execution Errors: "The `tasks/get` response **SHOULD** include a `statusMessage` field with diagnostic information about the failure, and **MUST** include the `error` field with the JSON-RPC error."',
5537
+ specRefs: [ref3("Task Execution Errors")]
5538
+ }),
5539
+ tasks({
5540
+ id: "tasks-http-name-header",
5541
+ title: "tasks/get with Mcp-Name set to the taskId is accepted",
5542
+ description: "Over Streamable HTTP, tasks/get sent with Mcp-Name equal to params.taskId and Mcp-Method equal to tasks/get is answered with a result, not with the HeaderMismatch error (-32020).",
5543
+ level: "SHOULD",
5544
+ derived: true,
5545
+ derivation: 'Streamable HTTP: Routing Headers: "the client **MUST** set the `Mcp-Name` header to the value of `params.taskId`." The sentence is about the client; that a server accepts a request that does it is read from it, and no sentence says MUST or SHOULD about the server, so the level is SHOULD.',
5546
+ specRefs: [ref3("Streamable HTTP: Routing Headers")],
5547
+ transports: ["http"]
5548
+ }),
5549
+ tasks({
5550
+ id: "tasks-input-request-keys-unique",
5551
+ title: "An inputRequests key never names two different requests",
5552
+ description: "Across the tasks/get answers of one task, a key of inputRequests that appears again holds the same request. At least two answers with inputRequests are needed, otherwise the check is not-applicable (not-offered). That a key is not reused after its response was delivered is not judged: the run never answers a request.",
5553
+ level: "MUST",
5554
+ derived: true,
5555
+ derivation: 'Task Update Requests: "Each request key in `inputRequests` **MUST** be unique over the lifetime of a single task. A server **MUST NOT** reuse a key for a subsequent server-to-client request after a response for that key has been delivered, and **MUST NOT** use the same key to refer to two distinct requests over a task\'s lifetime." The check judges the second half only, which is the part a client that never answers can see.',
5556
+ specRefs: [ref3("Task Update Requests")]
5557
+ })
5558
+ ];
5559
+
5560
+ // src/mcp-testing/conformance/catalog.ts
5561
+ var L2 = "2025-11-25";
5562
+ var M2 = "2026-07-28";
5563
+ var BOTH3 = ["legacy", "modern"];
5564
+ var MODERN3 = ["modern"];
5565
+ var ANY = ["stdio", "http"];
5566
+ var check2 = (s) => ({
5567
+ ...s,
5568
+ suite: "protocol",
5569
+ kind: "check",
5570
+ derived: s.derived ?? false,
5571
+ needsFixture: s.needsFixture ?? false
5572
+ });
5573
+ var ref4 = (revision, page, section) => ({ revision, page, section });
5574
+ var unscored = (kind, s) => ({
5575
+ ...check2({ ...s, level: null }),
5576
+ kind
5577
+ });
5578
+ var HTTP = ["http"];
5579
+ var LT = "basic/transports";
5580
+ var MT = "basic/transports/streamable-http";
5581
+ var CATALOG = [
5582
+ // Lifecycle
5583
+ check2({
5584
+ id: "life-initialize-result",
5585
+ title: "initialize answers with protocolVersion, capabilities and serverInfo",
5586
+ description: "The result of initialize holds the protocol version the server chose, its capabilities and its serverInfo.",
5587
+ level: "MUST",
5588
+ specRefs: [ref4(L2, "basic/lifecycle", "Initialization")],
5589
+ eras: ["legacy"],
5590
+ transports: ANY
5591
+ }),
5592
+ check2({
5593
+ id: "life-version-negotiation",
5594
+ title: "The protocol version is negotiated",
5595
+ description: "Asked for a version it supports, the server answers with that version; asked for one it does not, with another version it supports.",
5596
+ level: "MUST",
5597
+ specRefs: [ref4(L2, "basic/lifecycle", "Version Negotiation")],
5598
+ eras: ["legacy"],
5599
+ transports: ANY
5600
+ }),
5601
+ check2({
5602
+ id: "life-capabilities-declared-served",
5603
+ title: "Every declared capability is served",
5604
+ description: "For each capability declared (tools, resources, prompts, logging, completions), the matching request does not answer Method not found (-32601).",
5605
+ level: "MUST",
5606
+ derived: true,
5607
+ derivation: "basic/lifecycle, Operation: only negotiated capabilities are used; the server pages: a server that supports a feature MUST declare its capability.",
5608
+ specRefs: [ref4(L2, "basic/lifecycle", "Operation")],
5609
+ eras: BOTH3,
5610
+ transports: ANY
5611
+ }),
5612
+ check2({
5613
+ id: "life-capabilities-served-declared",
5614
+ title: "Every served list is declared",
5615
+ description: "When tools/list, resources/list or prompts/list answers, the matching capability is declared.",
5616
+ level: "MUST",
5617
+ specRefs: [
5618
+ ref4(L2, "server/tools", "Capabilities"),
5619
+ ref4(L2, "server/resources", "Capabilities"),
5620
+ ref4(L2, "server/prompts", "Capabilities")
5621
+ ],
5622
+ eras: BOTH3,
5623
+ transports: ANY
5624
+ }),
5625
+ check2({
5626
+ id: "life-ping-empty-result",
5627
+ title: "ping answers with an empty result",
5628
+ description: "ping is answered promptly with result: {}.",
5629
+ level: "MUST",
5630
+ specRefs: [ref4(L2, "basic/utilities/ping", "Behavior Requirements")],
5631
+ eras: ["legacy"],
5632
+ transports: ANY
5633
+ }),
5634
+ // The 2026-07-28 revision: server/discover and the per-request metadata, run first (the rest stands on discover).
5635
+ check2({
5636
+ id: "mod-discover-result",
5637
+ title: "server/discover answers a complete DiscoverResult",
5638
+ description: 'server/discover answers resultType "complete", supportedVersions (a non-empty list of strings that names the revision of the run) and capabilities (an object). Without it every other modern check is could-not-run (prerequisite-failed).',
5639
+ level: "MUST",
5640
+ specRefs: [ref4(M2, "server/discover", "Discovery"), ref4(M2, "basic/versioning", "Protocol Version Negotiation")],
5641
+ eras: MODERN3,
5642
+ transports: ANY
5643
+ }),
5644
+ check2({
5645
+ id: "mod-discover-server-info",
5646
+ title: "server/discover names the server in _meta",
5647
+ description: 'The DiscoverResult has _meta["io.modelcontextprotocol/serverInfo"] with a name and a version.',
5648
+ level: "SHOULD",
5649
+ specRefs: [ref4(M2, "server/discover", "DiscoverResult"), ref4(M2, "basic/index", "_meta")],
5650
+ eras: MODERN3,
5651
+ transports: ANY
5652
+ }),
5653
+ check2({
5654
+ id: "mod-meta-required-fields",
5655
+ title: "A request without a required _meta field is Invalid params",
5656
+ description: "server/discover without io.modelcontextprotocol/protocolVersion, and again without io.modelcontextprotocol/clientCapabilities, each gets -32602, over HTTP with status 400. Ambiguous in the text: over HTTP a body without the version also differs from its MCP-Protocol-Version header, so -32020 (HeaderMismatch) is taken for that probe as well.",
5657
+ level: "MUST",
5658
+ specRefs: [ref4(M2, "basic/index", "_meta"), ref4(M2, MT, "Server Validation")],
5659
+ eras: MODERN3,
5660
+ transports: ANY
5661
+ }),
5662
+ check2({
5663
+ id: "mod-unsupported-version",
5664
+ title: "An unsupported protocol version is UnsupportedProtocolVersion",
5665
+ description: "server/discover for revision 1900-01-01 gets -32022 with data.supported, a non-empty list; over HTTP with status 400.",
5666
+ level: "MUST",
5667
+ specRefs: [ref4(M2, "basic/versioning", "Protocol Version Negotiation"), ref4(M2, MT, "Protocol Version Header")],
5668
+ eras: MODERN3,
5669
+ transports: ANY
5670
+ }),
5671
+ // Base protocol
5672
+ check2({
5673
+ id: "base-jsonrpc-parse-error",
5674
+ title: "Invalid JSON is a parse error",
5675
+ description: "A message that is not valid JSON gets the error -32700 with id: null.",
5676
+ level: "MUST",
5677
+ derived: true,
5678
+ derivation: "basic/index, Messages: MCP messages MUST follow JSON-RPC 2.0; JSON-RPC 2.0 section 5 gives -32700 and a null id to a parse error.",
5679
+ specRefs: [ref4(L2, "basic/index", "Messages")],
5680
+ eras: BOTH3,
5681
+ transports: ANY
5682
+ }),
5683
+ check2({
5684
+ id: "base-unknown-method-error",
5685
+ title: "An unknown method is Method not found",
5686
+ description: "A request for a method the server does not have gets the error -32601.",
5687
+ level: "MUST",
5688
+ derived: true,
5689
+ derivation: "basic/index, Messages: MCP messages MUST follow JSON-RPC 2.0; JSON-RPC 2.0 section 5.1 names -32601 for a method that does not exist.",
5690
+ specRefs: [ref4(L2, "basic/index", "Messages")],
5691
+ eras: BOTH3,
5692
+ transports: ANY
5693
+ }),
5694
+ check2({
5695
+ id: "base-response-id-matches",
5696
+ title: "A response carries the id of its request",
5697
+ description: "The id of a response is the id of the request; it holds exactly one of result and error; the id is not null for a valid request.",
5698
+ level: "MUST",
5699
+ specRefs: [ref4(L2, "basic/index", "Responses"), ref4(M2, "basic/index", "Responses")],
5700
+ eras: BOTH3,
5701
+ transports: ANY
5702
+ }),
5703
+ check2({
5704
+ id: "base-invalid-params-error",
5705
+ title: "Plainly wrong parameters are Invalid params",
5706
+ description: "A request with plainly wrong parameters (tools/call without name) gets -32602, not -32603 and not a result.",
5707
+ level: "SHOULD",
5708
+ specRefs: [ref4(L2, "server/tools", "Error Handling")],
5709
+ eras: BOTH3,
5710
+ transports: ANY
5711
+ }),
5712
+ // Tools
5713
+ check2({
5714
+ id: "tools-list-shape",
5715
+ title: "Every listed tool has a name and an inputSchema object",
5716
+ description: "Each entry of tools/list has a string name and an inputSchema that is an object, not null.",
5717
+ level: "MUST",
5718
+ specRefs: [ref4(L2, "server/tools", "Tool")],
5719
+ eras: BOTH3,
5720
+ transports: ANY
5721
+ }),
5722
+ check2({
5723
+ id: "tools-input-schema-valid",
5724
+ title: "Every inputSchema is a valid object schema",
5725
+ description: 'Each inputSchema has type: "object" and is valid in its declared ($schema) or default (2020-12) dialect; an unknown dialect is reported, not a crash.',
5726
+ level: "MUST",
5727
+ specRefs: [ref4(L2, "basic/index", "JSON Schema Usage")],
5728
+ eras: BOTH3,
5729
+ transports: ANY
5730
+ }),
5731
+ check2({
5732
+ id: "tools-output-schema-valid",
5733
+ title: "Every outputSchema is a valid schema",
5734
+ description: "An outputSchema, when given, is valid in its dialect; before 2026-07-28 its root is an object, from then on any type.",
5735
+ level: "MUST",
5736
+ specRefs: [ref4(L2, "server/tools", "Output Schema"), ref4(M2, "changelog", "Minor changes")],
5737
+ eras: BOTH3,
5738
+ transports: ANY
5739
+ }),
5740
+ check2({
5741
+ id: "tools-structured-conformant",
5742
+ title: "structuredContent conforms to the outputSchema",
5743
+ description: "The structuredContent of a call (from the fixture) conforms to the tool's outputSchema.",
5744
+ level: "MUST",
5745
+ specRefs: [ref4(L2, "server/tools", "Output Schema")],
5746
+ eras: BOTH3,
5747
+ transports: ANY,
5748
+ needsFixture: true
5749
+ }),
5750
+ check2({
5751
+ id: "tools-structured-has-text",
5752
+ title: "structuredContent is also given as text",
5753
+ description: "A result with structuredContent also has a text block with the serialized JSON.",
5754
+ level: "SHOULD",
5755
+ specRefs: [ref4(L2, "server/tools", "Structured Content")],
5756
+ eras: BOTH3,
5757
+ transports: ANY,
5758
+ needsFixture: true
5759
+ }),
5760
+ check2({
5761
+ id: "tools-name-format",
5762
+ title: "Tool names use the allowed characters",
5763
+ description: "Each tool name is 1 to 128 characters of A-Z, a-z, 0-9, _, - and ., without spaces or commas.",
5764
+ level: "SHOULD",
5765
+ specRefs: [ref4(L2, "server/tools", "Tool Names")],
5766
+ eras: BOTH3,
5767
+ transports: ANY
5768
+ }),
5769
+ check2({
5770
+ id: "tools-name-unique",
5771
+ title: "Tool names are unique",
5772
+ description: "No two tools of the server share a name, across every page of tools/list.",
5773
+ level: "SHOULD",
5774
+ specRefs: [ref4(L2, "server/tools", "Tool Names")],
5775
+ eras: BOTH3,
5776
+ transports: ANY
5777
+ }),
5778
+ check2({
5779
+ id: "tools-call-unknown-error",
5780
+ title: "Calling an unknown tool is a protocol error",
5781
+ description: "tools/call for a tool that does not exist gets a JSON-RPC error, not a result with isError.",
5782
+ level: "SHOULD",
5783
+ specRefs: [ref4(L2, "server/tools", "Error Handling")],
5784
+ eras: BOTH3,
5785
+ transports: ANY
5786
+ }),
5787
+ check2({
5788
+ id: "tools-list-order-stable",
5789
+ title: "tools/list keeps its order",
5790
+ description: "Two calls of tools/list give the tools in the same order.",
5791
+ level: "SHOULD",
5792
+ specRefs: [ref4(M2, "server/tools", "Capabilities")],
5793
+ eras: ["modern"],
5794
+ transports: ANY
5795
+ }),
5796
+ // Resources
5797
+ check2({
5798
+ id: "resources-list-shape",
5799
+ title: "Every listed resource has a uri and a name",
5800
+ description: "Each entry of resources/list has uri and name.",
5801
+ level: "MUST",
5802
+ derived: true,
5803
+ derivation: 'server/resources, Resource: uri and name are listed without "Optional"; no keyword.',
5804
+ specRefs: [ref4(L2, "server/resources", "Resource")],
5805
+ eras: BOTH3,
5806
+ transports: ANY
5807
+ }),
5808
+ check2({
5809
+ id: "resources-read-listed",
5810
+ title: "A listed resource can be read",
5811
+ description: "resources/read of the first listed resource answers with contents, each with a uri and exactly one of text and blob.",
5812
+ level: "MUST",
5813
+ derived: true,
5814
+ derivation: "server/resources, Resource Contents: a content is text or binary data under its uri; no keyword.",
5815
+ specRefs: [ref4(L2, "server/resources", "Resource Contents")],
5816
+ eras: BOTH3,
5817
+ transports: ANY
5818
+ }),
5819
+ check2({
5820
+ id: "resources-read-not-found",
5821
+ title: "Reading an unknown resource is an error",
5822
+ description: "resources/read of a uri that does not exist gets -32002, not empty contents.",
5823
+ level: "SHOULD",
5824
+ specRefs: [ref4(L2, "server/resources", "Error Handling")],
5825
+ eras: ["legacy"],
5826
+ transports: ANY
5827
+ }),
5828
+ check2({
5829
+ id: "resources-templates-shape",
5830
+ title: "Every resource template has a uriTemplate and a name",
5831
+ description: "Each entry of resources/templates/list has uriTemplate and name.",
5832
+ level: "MUST",
5833
+ derived: true,
5834
+ derivation: "server/resources, Resource Templates: every example template has uriTemplate and name; no keyword.",
5835
+ specRefs: [ref4(L2, "server/resources", "Resource Templates")],
5836
+ eras: BOTH3,
5837
+ transports: ANY
5838
+ }),
5839
+ // Prompts
5840
+ check2({
5841
+ id: "prompts-list-shape",
5842
+ title: "Every listed prompt has a name",
5843
+ description: "Each entry of prompts/list has name; arguments, when given, is a list of objects with name.",
5844
+ level: "MUST",
5845
+ derived: true,
5846
+ derivation: 'server/prompts, Prompt: name is listed without "Optional", arguments is optional; no keyword.',
5847
+ specRefs: [ref4(L2, "server/prompts", "Prompt")],
5848
+ eras: BOTH3,
5849
+ transports: ANY
5850
+ }),
5851
+ check2({
5852
+ id: "prompts-get-unknown-error",
5853
+ title: "Getting an unknown prompt is an error",
5854
+ description: "prompts/get with a name that does not exist gets a JSON-RPC error.",
5855
+ level: "SHOULD",
5856
+ specRefs: [ref4(L2, "server/prompts", "Error Handling")],
5857
+ eras: BOTH3,
5858
+ transports: ANY
5859
+ }),
5860
+ // Pagination
5861
+ check2({
5862
+ id: "pagination-walk-complete",
5863
+ title: "Paging through a list ends, without repeats",
5864
+ description: "Following nextCursor ends within the page limit and no entry comes back on a later page.",
5865
+ level: "SHOULD",
5866
+ specRefs: [ref4(L2, "server/utilities/pagination", "Implementation Guidelines")],
5867
+ eras: BOTH3,
5868
+ transports: ANY
5869
+ }),
5870
+ check2({
5871
+ id: "pagination-invalid-cursor",
5872
+ title: "An invalid cursor is Invalid params",
5873
+ description: "A list request with a cursor the server never gave gets -32602.",
5874
+ level: "SHOULD",
5875
+ specRefs: [ref4(L2, "server/utilities/pagination", "Error Handling")],
5876
+ eras: BOTH3,
5877
+ transports: ANY
5878
+ }),
5879
+ // Utilities
5880
+ check2({
5881
+ id: "logging-set-level",
5882
+ title: "logging/setLevel is accepted when logging is declared",
5883
+ description: "A server that declares logging accepts logging/setLevel.",
5884
+ level: "SHOULD",
5885
+ derived: true,
5886
+ derivation: "server/utilities/logging: the MUST is on declaring the capability, not on handling logging/setLevel, so handling it is a SHOULD.",
5887
+ specRefs: [ref4(L2, "server/utilities/logging", "Capabilities")],
5888
+ eras: ["legacy"],
5889
+ transports: ANY
5890
+ }),
5891
+ check2({
5892
+ id: "completion-complete",
5893
+ title: "completion/complete answers when completions is declared",
5894
+ description: "A server that declares completions answers completion/complete with a valid result.",
5895
+ level: "SHOULD",
5896
+ derived: true,
5897
+ derivation: "server/utilities/completion, Capabilities: the MUST is on declaring the capability, not on the answer to completion/complete, so the answer is a SHOULD.",
5898
+ specRefs: [ref4(L2, "server/utilities/completion", "Capabilities")],
5899
+ eras: BOTH3,
5900
+ transports: ANY
5901
+ }),
5902
+ // The 2026-07-28 revision: what changed for every transport.
5903
+ check2({
5904
+ id: "mod-removed-methods",
5905
+ title: "The methods the revision removed are Method not found",
5906
+ description: "ping, logging/setLevel, resources/subscribe, resources/unsubscribe and initialize, each sent with the modern _meta, get -32601, over HTTP with status 404. initialize goes on a connection of its own; a dual-era server that answers it with an initialize result is not counted for it, since the text lets initialize select the legacy era (basic/versioning, Backward Compatibility) while a request with modern _meta is served in the modern one: the two rules meet there.",
5907
+ level: "MUST",
5908
+ derived: true,
5909
+ derivation: "changelog, Major changes 2, 4 and 5 remove these methods; streamable-http, Protocol Version Header: a method the server does not implement MUST get 404 and -32601. No sentence names the answer to a removed method itself.",
5910
+ specRefs: [ref4(M2, "changelog", "Major changes"), ref4(M2, MT, "Protocol Version Header")],
5911
+ eras: MODERN3,
5912
+ transports: ANY
5913
+ }),
5914
+ check2({
5915
+ id: "mod-stateless-no-prior-context",
5916
+ title: "A list answers on a fresh connection with no request before it",
5917
+ description: "On a new connection the first request is tools/list (else prompts/list, else resources/list, whichever is declared), not server/discover, and it answers a result.",
5918
+ level: "MUST",
5919
+ specRefs: [ref4(M2, "basic/index", "Statelessness")],
5920
+ eras: MODERN3,
5921
+ transports: ANY
5922
+ }),
5923
+ check2({
5924
+ id: "mod-list-stable-across-connections",
5925
+ title: "The lists do not vary per connection",
5926
+ description: "tools/list, prompts/list and resources/list (those declared) hold the same entries on the run's connection, after all its other requests, and on a new connection with the same credentials.",
5927
+ level: "MUST",
5928
+ specRefs: [
5929
+ ref4(M2, "server/tools", "Capabilities"),
5930
+ ref4(M2, "server/prompts", "Capabilities"),
5931
+ ref4(M2, "server/resources", "Capabilities")
5932
+ ],
5933
+ eras: MODERN3,
5934
+ transports: ANY
5935
+ }),
5936
+ check2({
5937
+ id: "mod-resource-not-found",
5938
+ title: "Reading an unknown resource is Invalid params",
5939
+ description: "resources/read of a uri that does not exist gets -32602; -32002, the code of earlier revisions, fails.",
5940
+ level: "MUST",
5941
+ specRefs: [ref4(M2, "server/resources", "Error Handling"), ref4(M2, "basic/index", "Error Codes")],
5942
+ eras: MODERN3,
5943
+ transports: ANY
5944
+ }),
5945
+ check2({
5946
+ id: "mod-resource-no-empty-contents",
5947
+ title: "An unknown resource is not empty contents",
5948
+ description: "resources/read of a uri that does not exist does not answer a result with an empty contents list.",
5949
+ level: "MUST",
5950
+ specRefs: [ref4(M2, "server/resources", "Error Handling")],
5951
+ eras: MODERN3,
5952
+ transports: ANY
5953
+ }),
5954
+ check2({
5955
+ id: "mod-cache-hints-coverage",
5956
+ title: "Every cacheable result has ttlMs and cacheScope",
5957
+ description: "Each complete result of server/discover, tools/list, prompts/list, resources/list, resources/templates/list (every page) and resources/read (the first listed resource) has ttlMs and cacheScope; the lists only when their capability is declared.",
5958
+ level: "MUST",
5959
+ specRefs: [ref4(M2, "server/utilities/caching", "Cacheable Results")],
5960
+ eras: MODERN3,
5961
+ transports: ANY
5962
+ }),
5963
+ check2({
5964
+ id: "mod-cache-ttl-valid",
5965
+ title: "ttlMs is an integer of at least 0",
5966
+ description: "Every ttlMs on those results is an integer number of milliseconds, 0 or more.",
5967
+ level: "MUST",
5968
+ specRefs: [ref4(M2, "server/utilities/caching", "Time-to-Live (TTL) Field")],
5969
+ eras: MODERN3,
5970
+ transports: ANY
5971
+ }),
5972
+ check2({
5973
+ id: "mod-cache-scope-valid",
5974
+ title: 'cacheScope is "public" or "private"',
5975
+ description: 'Every cacheScope on those results is exactly "public" or "private".',
5976
+ level: "MUST",
5977
+ derived: true,
5978
+ derivation: 'server/utilities/caching, Cache Scope Field: the field "indicates ... either "public" or "private"" and its table has these two values, with no keyword on the value itself; the schema of the revision (schema.json, CacheableResult) makes it an enum of the two.',
5979
+ specRefs: [ref4(M2, "server/utilities/caching", "Cache Scope Field")],
5980
+ eras: MODERN3,
5981
+ transports: ANY
5982
+ }),
5983
+ check2({
5984
+ id: "mod-cache-scope-stable-pages",
5985
+ title: "All pages of a list have the same cacheScope",
5986
+ description: "Every page of a paginated list carries the cacheScope of its first page. Without a list of two pages, not-applicable.",
5987
+ level: "MUST",
5988
+ specRefs: [ref4(M2, "server/utilities/caching", "Interaction with Pagination")],
5989
+ eras: MODERN3,
5990
+ transports: ANY
5991
+ }),
5992
+ check2({
5993
+ id: "mod-undeclared-capability",
5994
+ title: "A capability the client did not declare is asked for with -32021",
5995
+ description: 'This checker declares no client capability. A --fixture call the server cannot serve without one gets -32021 with data.requiredCapabilities naming it (over HTTP, status 400), never an input request for sampling, elicitation or roots. The schema makes requiredCapabilities a ClientCapabilities object while the text says it "lists" them: an object with at least one capability is taken. Without --fixture, could-not-run (needs-input).',
5996
+ level: "MUST",
5997
+ specRefs: [ref4(M2, "basic/index", "_meta")],
5998
+ eras: MODERN3,
5999
+ transports: ANY,
6000
+ needsFixture: true
6001
+ }),
6002
+ // Subscriptions: one subscriptions/listen per run, watched for a short time and then cancelled.
6003
+ check2({
6004
+ id: "mod-sub-ack-first",
6005
+ title: "A subscription is acknowledged first",
6006
+ description: "The first message of subscriptions/listen with its subscription id is notifications/subscriptions/acknowledged, carrying that id in _meta. Without a subscribable capability (tools, prompts or resources listChanged, resources subscribe), not-applicable.",
6007
+ level: "MUST",
6008
+ specRefs: [ref4(M2, "basic/patterns/subscriptions", "Acknowledgment")],
6009
+ eras: MODERN3,
6010
+ transports: ANY
6011
+ }),
6012
+ check2({
6013
+ id: "mod-sub-filter-and-tag",
6014
+ title: "A subscription gets only what it asked for, each tagged",
6015
+ description: "The subscription asks for one kind of notification; every notification after the acknowledgment is of that kind and carries io.modelcontextprotocol/subscriptionId. When nothing changed while it was watched, there is no notification to judge: not-applicable (not-offered).",
6016
+ level: "MUST",
6017
+ specRefs: [ref4(M2, "basic/patterns/subscriptions", "Opening a Stream"), ref4(M2, "basic/index", "_meta")],
6018
+ eras: MODERN3,
6019
+ transports: ANY
6020
+ }),
6021
+ check2({
6022
+ id: "mod-sub-graceful-close",
6023
+ title: "A subscription the server ends gets a successful response",
6024
+ description: "When the server ends the subscription while it is watched, it first answers subscriptions/listen with a result. The text asks this when the server ends a subscription on its own initiative; a cancel of the client asks for no response, so a subscription the server keeps open is not-applicable (not-offered).",
6025
+ level: "SHOULD",
6026
+ specRefs: [ref4(M2, "basic/patterns/subscriptions", "Graceful Closure")],
6027
+ eras: MODERN3,
6028
+ transports: ANY
6029
+ }),
6030
+ // Streamable HTTP on the wire: raw requests, never an MCP client (../raw-http.ts).
6031
+ check2({
6032
+ id: "http-notification-202",
6033
+ title: "A notification POST is 202 with no body, or an error status",
6034
+ description: "A POST holding only a notification the server accepts gets 202 Accepted and an empty body; one it does not accept gets an HTTP error status. Another 2xx, or a 202 with a body, fails.",
6035
+ level: "MUST",
6036
+ specRefs: [ref4(L2, LT, "Sending Messages to the Server"), ref4(M2, MT, "Sending Messages")],
6037
+ eras: BOTH3,
6038
+ transports: HTTP
6039
+ }),
6040
+ check2({
6041
+ id: "http-request-content-type",
6042
+ title: "A request is answered as application/json or text/event-stream",
6043
+ description: "The answer to a JSON-RPC request has Content-Type application/json or text/event-stream.",
6044
+ level: "MUST",
6045
+ specRefs: [ref4(L2, LT, "Sending Messages to the Server"), ref4(M2, MT, "Sending Messages")],
6046
+ eras: BOTH3,
6047
+ transports: HTTP
6048
+ }),
6049
+ check2({
6050
+ id: "http-response-utf8",
6051
+ title: "The answer is UTF-8 JSON",
6052
+ description: "The body of the answer to a request is valid UTF-8, and its message (or the data of each SSE event) is JSON.",
6053
+ level: "MUST",
6054
+ specRefs: [ref4(L2, LT, "Transports")],
6055
+ eras: BOTH3,
6056
+ transports: HTTP
6057
+ }),
6058
+ check2({
6059
+ id: "http-single-endpoint",
6060
+ title: "The MCP endpoint takes POST",
6061
+ description: "The URL under test takes a valid JSON-RPC request by POST: not 404 (other than a JSON-RPC -32601) and not 405.",
6062
+ level: "MUST",
6063
+ specRefs: [ref4(L2, LT, "Streamable HTTP"), ref4(M2, MT, "Streamable HTTP")],
6064
+ eras: BOTH3,
6065
+ transports: HTTP
6066
+ }),
6067
+ check2({
6068
+ id: "http-get-stream-or-405",
6069
+ title: "GET opens an SSE stream or is 405",
6070
+ description: "A GET with Accept: text/event-stream gets Content-Type text/event-stream or 405 Method Not Allowed.",
6071
+ level: "MUST",
6072
+ specRefs: [ref4(L2, LT, "Listening for Messages from the Server")],
6073
+ eras: ["legacy"],
6074
+ transports: HTTP
6075
+ }),
6076
+ check2({
6077
+ id: "http-modern-get-delete-405",
6078
+ title: "A modern-only server answers GET and DELETE with 405",
6079
+ description: "A server of the 2026-07-28 revision only answers GET and DELETE on its endpoint with 405 Method Not Allowed. A server that also answers initialize (dual-era) is not-applicable.",
6080
+ level: "SHOULD",
6081
+ specRefs: [ref4(M2, MT, "Earlier Streamable HTTP Revisions")],
6082
+ eras: ["modern"],
6083
+ transports: HTTP
6084
+ }),
6085
+ check2({
6086
+ id: "http-session-id-visible-ascii",
6087
+ title: "A session id is visible ASCII",
6088
+ description: "An MCP-Session-Id the server assigns holds only characters 0x21 to 0x7E. Without one, not-applicable.",
6089
+ level: "MUST",
6090
+ specRefs: [ref4(L2, LT, "Session Management")],
6091
+ eras: ["legacy"],
6092
+ transports: HTTP
6093
+ }),
6094
+ check2({
6095
+ id: "http-session-required-400",
6096
+ title: "A request without the session id is 400",
6097
+ description: "When the server assigned a session id, a request other than initialize without MCP-Session-Id gets 400 Bad Request.",
6098
+ level: "SHOULD",
6099
+ specRefs: [ref4(L2, LT, "Session Management")],
6100
+ eras: ["legacy"],
6101
+ transports: HTTP
6102
+ }),
6103
+ check2({
6104
+ id: "http-protocol-version-header-invalid-400",
6105
+ title: "An invalid MCP-Protocol-Version is 400",
6106
+ description: "A request after initialize with an MCP-Protocol-Version that is not a revision gets 400 Bad Request.",
6107
+ level: "MUST",
6108
+ specRefs: [ref4(L2, LT, "Protocol Version Header")],
6109
+ eras: ["legacy"],
6110
+ transports: HTTP
6111
+ }),
6112
+ check2({
6113
+ id: "http-concurrent-posts-matched",
6114
+ title: "Concurrent POSTs each get their own answer",
6115
+ description: "Several POSTs sent at once, each with its own id, are each answered with the id of their request.",
6116
+ level: "MUST",
6117
+ derived: true,
6118
+ derivation: "basic/transports: every JSON-RPC message MUST be a new HTTP POST request; basic/index, Responses: a response carries the id of its request. Nothing is said of concurrency itself.",
6119
+ specRefs: [ref4(L2, LT, "Sending Messages to the Server"), ref4(M2, "basic/index", "Responses")],
6120
+ eras: BOTH3,
6121
+ transports: HTTP
6122
+ }),
6123
+ check2({
6124
+ id: "http-sse-event-ids-unique",
6125
+ title: "SSE event ids are unique in the session",
6126
+ description: "When the server gives SSE events an id, no id comes back twice across the streams of the session. Without ids, not-applicable.",
6127
+ level: "MUST",
6128
+ specRefs: [ref4(L2, LT, "Resumability and Redelivery")],
6129
+ eras: ["legacy"],
6130
+ transports: HTTP
6131
+ }),
6132
+ check2({
6133
+ id: "http-sse-stream-closes",
6134
+ title: "The SSE stream of a request ends after its response",
6135
+ description: "When a request is answered over SSE, the server closes the stream once the response is sent.",
6136
+ level: "SHOULD",
6137
+ specRefs: [ref4(L2, LT, "Sending Messages to the Server"), ref4(M2, MT, "Receiving Messages")],
6138
+ eras: BOTH3,
6139
+ transports: HTTP
6140
+ }),
6141
+ check2({
6142
+ id: "http-sse-no-server-requests",
6143
+ title: "The SSE stream of a request holds no request of the server",
6144
+ description: "The SSE answer to a request holds its response and notifications, never a JSON-RPC request of the server.",
6145
+ level: "MUST",
6146
+ specRefs: [ref4(M2, MT, "Receiving Messages")],
6147
+ eras: ["modern"],
6148
+ transports: HTTP
6149
+ }),
6150
+ check2({
6151
+ id: "http-accel-buffering-header",
6152
+ title: "An SSE answer sends X-Accel-Buffering: no",
6153
+ description: "A response that opens an SSE stream has the header X-Accel-Buffering: no.",
6154
+ level: "SHOULD",
6155
+ specRefs: [ref4(M2, MT, "Receiving Messages")],
6156
+ eras: ["modern"],
6157
+ transports: HTTP
6158
+ }),
6159
+ check2({
6160
+ id: "http-close-cancels",
6161
+ title: "Closing the SSE stream cancels the request",
6162
+ description: "Closing the SSE answer of a long call is taken as its cancellation: the server sends nothing more for it. It shows only in the effects of a tool, so this run cannot see it yet: could-not-run (needs-input).",
6163
+ level: "MUST",
6164
+ specRefs: [ref4(M2, MT, "Cancellation")],
6165
+ eras: ["modern"],
6166
+ transports: HTTP,
6167
+ needsFixture: true
6168
+ }),
6169
+ // The request headers of the 2026-07-28 revision, each probe a POST of its own.
6170
+ check2({
6171
+ id: "mod-unimplemented-method",
6172
+ title: "An unknown method over HTTP is 404 with -32601",
6173
+ description: "A POST of a method the server does not implement gets 404 Not Found and the JSON-RPC error -32601.",
6174
+ level: "MUST",
6175
+ specRefs: [ref4(M2, MT, "Protocol Version Header")],
6176
+ eras: MODERN3,
6177
+ transports: HTTP
6178
+ }),
6179
+ check2({
6180
+ id: "mod-header-protocol-version-mismatch",
6181
+ title: "An MCP-Protocol-Version unlike the body is HeaderMismatch",
6182
+ description: "server/discover with MCP-Protocol-Version: 2025-11-25 and 2026-07-28 in _meta gets 400 and -32020.",
6183
+ level: "MUST",
6184
+ specRefs: [ref4(M2, MT, "Protocol Version Header"), ref4(M2, MT, "Server Validation")],
6185
+ eras: MODERN3,
6186
+ transports: HTTP
6187
+ }),
6188
+ check2({
6189
+ id: "mod-header-method-mismatch",
6190
+ title: "An Mcp-Method unlike the body is HeaderMismatch",
6191
+ description: "server/discover sent with Mcp-Method: tools/list gets 400 and -32020.",
6192
+ level: "MUST",
6193
+ specRefs: [ref4(M2, MT, "Server Validation")],
6194
+ eras: MODERN3,
6195
+ transports: HTTP
6196
+ }),
6197
+ check2({
6198
+ id: "mod-header-name-mismatch",
6199
+ title: "An Mcp-Name unlike the body is HeaderMismatch",
6200
+ description: "resources/read of the first listed resource (else prompts/get of the first prompt, else tools/call of the first --fixture tool) with Mcp-Name in another case gets 400 and -32020: header values are case-sensitive. A tool outside --fixture is never the target. Without a target, not-applicable.",
6201
+ level: "MUST",
6202
+ specRefs: [ref4(M2, MT, "Standard Request Headers"), ref4(M2, MT, "Server Validation"), ref4(M2, MT, "Case Sensitivity")],
6203
+ eras: MODERN3,
6204
+ transports: HTTP
6205
+ }),
6206
+ check2({
6207
+ id: "mod-header-missing-rejected",
6208
+ title: "A request without a required header is HeaderMismatch",
6209
+ description: "server/discover without MCP-Protocol-Version, server/discover without Mcp-Method, and the Mcp-Name target without Mcp-Name, each get 400 and -32020. The first is not counted for a server whose supportedVersions names a revision before 2025-06-18: it MAY take a request without the header as 2025-03-26.",
6210
+ level: "MUST",
6211
+ specRefs: [ref4(M2, MT, "Server Validation"), ref4(M2, MT, "Standard Request Headers"), ref4(M2, MT, "Protocol Version Header")],
6212
+ eras: MODERN3,
6213
+ transports: HTTP
6214
+ }),
6215
+ check2({
6216
+ id: "mod-header-names-case-insensitive",
6217
+ title: "Header names are read in any case",
6218
+ description: "server/discover with its standard headers named in lower case, and again in upper case, answers a result both times. The names go out as written (node:http), not as fetch would normalise them.",
6219
+ level: "MUST",
6220
+ specRefs: [ref4(M2, MT, "Case Sensitivity")],
6221
+ eras: MODERN3,
6222
+ transports: HTTP
6223
+ }),
6224
+ check2({
6225
+ id: "mod-header-name-base64-decoded",
6226
+ title: "A Base64 Mcp-Name is decoded before it is compared",
6227
+ description: "The Mcp-Name target (a name or uri that is not plain ASCII when there is one) sent as =?base64?\u2026?= is not refused with -32020. The text obliges clients to encode only values that are not plain ASCII, and servers to decode any encoded value; when every name is plain ASCII, one is encoded all the same.",
6228
+ level: "MUST",
6229
+ specRefs: [ref4(M2, MT, "Value Encoding")],
6230
+ eras: MODERN3,
6231
+ transports: HTTP
6232
+ }),
6233
+ check2({
6234
+ id: "mod-param-header-mismatch",
6235
+ title: "An Mcp-Param header unlike the body, or missing, is HeaderMismatch",
6236
+ description: "For a --fixture tool whose inputSchema marks a property with x-mcp-header and whose arguments give it a value: a wrong Mcp-Param-{Name}, and no Mcp-Param-{Name} at all, each get 400 and -32020. Only a --fixture tool is the target. Without such a tool, not-applicable.",
6237
+ level: "MUST",
6238
+ specRefs: [ref4(M2, MT, "Server Behavior for Custom Headers")],
6239
+ eras: MODERN3,
6240
+ transports: HTTP,
6241
+ needsFixture: true
6242
+ }),
6243
+ check2({
6244
+ id: "mod-x-mcp-header-declarations",
6245
+ title: "Every x-mcp-header declaration is valid",
6246
+ description: "Each x-mcp-header in an inputSchema is a non-empty HTTP token, unique without regard to case in its schema, on a string, integer or boolean property reached only through properties (not items, a composition, a condition or $ref). Over stdio a client MAY ignore the annotation, so the check is for HTTP only.",
6247
+ level: "MUST",
6248
+ specRefs: [ref4(M2, "server/tools", "x-mcp-header"), ref4(M2, MT, "Schema Extension")],
6249
+ eras: MODERN3,
6250
+ transports: HTTP
6251
+ }),
6252
+ check2({
6253
+ id: "mod-no-session-id",
6254
+ title: "A modern-only server neither mints nor echoes a session id",
6255
+ description: "server/discover sent with an Mcp-Session-Id gets an answer without Mcp-Session-Id. A dual-era server (supportedVersions names a revision before 2026-07-28) is not-applicable.",
6256
+ level: "SHOULD",
6257
+ specRefs: [ref4(M2, MT, "Earlier Streamable HTTP Revisions")],
6258
+ eras: MODERN3,
6259
+ transports: HTTP
6260
+ }),
6261
+ // These two change the server's state, each in a session of its own made for it, so they come last.
6262
+ check2({
6263
+ id: "http-session-terminated-404",
6264
+ title: "A terminated session is 404",
6265
+ description: "After a DELETE with MCP-Session-Id that the server takes (not 405), a request with that session id gets 404 Not Found. Only a session this run made is deleted.",
6266
+ level: "MUST",
6267
+ specRefs: [ref4(L2, LT, "Session Management")],
6268
+ eras: ["legacy"],
6269
+ transports: HTTP
6270
+ }),
6271
+ check2({
6272
+ id: "http-sse-no-broadcast",
6273
+ title: "A message goes to one SSE stream, not to each",
6274
+ description: "With two GET streams open, a message of the server (made by the first --fixture call) arrives on one of them only.",
6275
+ level: "MUST",
6276
+ specRefs: [ref4(L2, LT, "Multiple Connections")],
6277
+ eras: ["legacy"],
6278
+ transports: HTTP,
6279
+ needsFixture: true
6280
+ }),
6281
+ // A local server against DNS rebinding: only for localhost, 127.0.0.1, [::1] and *.localhost.
6282
+ check2({
6283
+ id: "http-origin-invalid-403",
6284
+ title: "A foreign Origin is refused with 403",
6285
+ description: "A request with Origin: https://evil.example gets 403 Forbidden. It proves nothing when the control with a localhost Origin is refused as well: then could-not-run (prerequisite-failed).",
6286
+ level: "MUST",
6287
+ specRefs: [ref4(L2, LT, "Security Warning"), ref4(M2, MT, "Security & Endpoint")],
6288
+ eras: BOTH3,
6289
+ transports: HTTP
6290
+ }),
6291
+ unscored("control", {
6292
+ id: "http-origin-localhost-accepted",
6293
+ title: "An Origin of localhost is accepted",
6294
+ description: "A request with Origin: http://localhost:<port> is accepted. Not a requirement: without it, a 403 to a foreign Origin shows a server that refuses everything, not a protection.",
6295
+ specRefs: [ref4(L2, LT, "Security Warning"), ref4(M2, MT, "Security & Endpoint")],
6296
+ eras: BOTH3,
6297
+ transports: HTTP
6298
+ }),
6299
+ unscored("control", {
6300
+ id: "http-origin-absent-accepted",
6301
+ title: "A request without Origin is accepted",
6302
+ description: "A request with no Origin (not from a browser) is accepted: the specification speaks only of an Origin that is present and invalid.",
6303
+ specRefs: [ref4(L2, LT, "Security Warning"), ref4(M2, MT, "Security & Endpoint")],
6304
+ eras: BOTH3,
6305
+ transports: HTTP
6306
+ }),
6307
+ check2({
6308
+ id: "http-bind-loopback",
6309
+ title: "A local server listens on loopback only",
6310
+ description: "The port of a local server cannot be reached at an outside address of this machine. Without an outside address to try, could-not-run (needs-input).",
6311
+ level: "SHOULD",
6312
+ specRefs: [ref4(L2, LT, "Security Warning"), ref4(M2, MT, "Security & Endpoint")],
6313
+ eras: BOTH3,
6314
+ transports: HTTP
6315
+ }),
6316
+ unscored("advice", {
6317
+ id: "http-host-rebinding-advice",
6318
+ title: "A foreign Host is refused (advice outside the specification)",
6319
+ description: "Not a requirement of the specification, practical advice: a local server that accepts a request with Host: evil.example relies on the Origin check alone against DNS rebinding.",
6320
+ specRefs: [ref4(L2, LT, "Security Warning"), ref4(M2, MT, "Security & Endpoint")],
6321
+ eras: BOTH3,
6322
+ transports: HTTP
6323
+ }),
6324
+ // The 2026-07-28 revision over the whole run: these read every message the run got back, so they come after the rest.
6325
+ check2({
6326
+ id: "mod-result-type-present",
6327
+ title: "Every result has a known resultType",
6328
+ description: 'Every result the run got has resultType "complete" or "input_required". Extensions MAY add values, which the text does not let a client name in advance: another value passes only when the server declares capabilities.extensions, and is said so.',
6329
+ level: "MUST",
6330
+ specRefs: [ref4(M2, "basic/index", "ResultType")],
6331
+ eras: MODERN3,
6332
+ transports: ANY
6333
+ }),
6334
+ check2({
6335
+ id: "mod-error-code-range",
6336
+ title: "No error code of the reserved range is invented",
6337
+ description: "No error the run got has a code from -32099 to -32020 other than -32020, -32021 and -32022, nor -32002 or -32042, which the revision retired. Whether a defined code is used for its meaning is not judged here.",
6338
+ level: "MUST",
6339
+ specRefs: [ref4(M2, "basic/index", "Error Codes")],
6340
+ eras: MODERN3,
6341
+ transports: ANY
6342
+ }),
6343
+ check2({
6344
+ id: "mod-logs-need-log-level",
6345
+ title: "No log message for a request without logLevel",
6346
+ description: "No request of the run set io.modelcontextprotocol/logLevel, so no notifications/message came back. Logging is deprecated in this revision: a server that does not declare logging is not-applicable.",
6347
+ level: "MUST",
6348
+ specRefs: [ref4(M2, "server/utilities/logging", "Per-request log level")],
6349
+ eras: MODERN3,
6350
+ transports: ANY
6351
+ }),
6352
+ check2({
6353
+ id: "mod-wire-schema-valid",
6354
+ title: "Every message conforms to the schema of the revision",
6355
+ description: "Every message the run got validates against schema.json of 2026-07-28: a response against the result of the method it answers (InputRequiredResult for input_required), an error against JSONRPCErrorResponse, a notification of a known method against its definition. The schema file is shipped with the checker, its SHA-256 in the result. The schema gives an error no null id, while JSON-RPC 2.0 answers a message whose id could not be read with id: null: that null is taken as the absent id.",
6356
+ level: "MUST",
6357
+ derived: true,
6358
+ derivation: "basic/index, Messages: every message MUST follow JSON-RPC 2.0; basic/index, Schema: the TypeScript schema is the source of truth for all protocol messages and structures, and schema.json is generated from it. No sentence says MUST about conforming to the schema itself.",
6359
+ specRefs: [ref4(M2, "basic/index", "Schema")],
6360
+ eras: MODERN3,
6361
+ transports: ANY
6362
+ }),
6363
+ // stdio
6364
+ check2({
6365
+ id: "stdio-stdout-clean",
6366
+ title: "stdout holds only MCP messages",
6367
+ description: "Every line the server writes to stdout is one whole JSON-RPC message, with no newline inside it.",
6368
+ level: "MUST",
6369
+ specRefs: [ref4(L2, "basic/transports", "stdio"), ref4(M2, "basic/transports/stdio", "stdio")],
6370
+ eras: BOTH3,
6371
+ transports: ["stdio"]
6372
+ }),
6373
+ check2({
6374
+ id: "stdio-exit-on-eof",
6375
+ title: "The server exits when stdin closes",
6376
+ description: "After its stdin is closed the server process ends within a short time.",
6377
+ level: "SHOULD",
6378
+ specRefs: [ref4(M2, "basic/transports/stdio", "Shutdown")],
6379
+ eras: BOTH3,
6380
+ transports: ["stdio"]
6381
+ }),
6382
+ // The oauth suite (auth-catalog.ts)
6383
+ ...OAUTH_CATALOG,
6384
+ // The apps suite (apps-catalog.ts)
6385
+ ...APPS_CATALOG,
6386
+ // The tasks suite (tasks-catalog.ts)
6387
+ ...TASKS_CATALOG
6388
+ ];
6389
+ var BY_ID = new Map(CATALOG.map((e) => [e.id, e]));
6390
+
6391
+ // src/mcp-testing/conformance/profile.ts
6392
+ init_cjs_shims();
6393
+ var import_node_crypto3 = require("crypto");
6394
+
6395
+ // src/mcp-testing/report/human.ts
6396
+ init_exit_codes();
6397
+
6398
+ // src/mcp-testing/snapshot/index.ts
6399
+ init_cjs_shims();
6400
+
6401
+ // src/mcp-testing/snapshot/snapshot.ts
6402
+ init_cjs_shims();
6403
+
6404
+ // src/mcp-testing/snapshot/diff.ts
6405
+ init_cjs_shims();
6406
+
6407
+ // src/mcp-testing/report/human.ts
6408
+ var noCommands = (text) => text.replace(/^([\s\u0085]*)::/gm, "$1?::").replaceAll("##[", "##?[");
6409
+
6410
+ // src/mcp-testing/scan/descriptions.ts
6411
+ init_cjs_shims();
6412
+
6413
+ // src/mcp-testing/scan/phrases.ts
6414
+ init_cjs_shims();
6415
+ var DESCRIPTION_PHRASES = {
6416
+ version: 1,
6417
+ rules: {
6418
+ "scan/desc/override-instruction": [
6419
+ "\\b(?:ignore|disregard|forget|override) (?:all |any )?(?:of )?(?:the |your |my )?(?:previous|prior|above|earlier|preceding|other|system) (?:instructions?|prompts?|messages?|rules?|context)",
6420
+ "\\b(?:ignore|disregard) (?:all |any )?(?:of )?(?:the |your )?(?:previous|prior|above|earlier|preceding)\\b",
6421
+ "\\bnew (?:system )?instructions:",
6422
+ "\\byou are now (?:a|an|in)\\b"
6423
+ ],
6424
+ "scan/desc/sensitive-path": [
6425
+ "(?<![\\w.~])(?:~/)?\\.ssh\\b",
6426
+ "\\bid_(?:rsa|dsa|ecdsa|ed25519)\\b",
6427
+ "(?<![\\w.~])(?:~/)?\\.aws/(?:credentials|config)\\b",
6428
+ "(?<![\\w.~])(?:~/)?\\.env\\b",
6429
+ "(?<![\\w.~])(?:~/)?\\.(?:npmrc|pypirc|netrc|pgpass|git-credentials)\\b",
6430
+ "(?<![\\w.~])(?:~/)?\\.(?:docker/config\\.json|kube/config|gnupg|config/gcloud)\\b",
6431
+ "/etc/(?:shadow|passwd)\\b",
6432
+ "\\bcredentials\\.json\\b",
6433
+ "\\bread (?:the )?(?:contents? of )?(?:the |any |a )?(?:file|files)\\b"
6434
+ ],
6435
+ "scan/desc/conceal-from-user": [
6436
+ "\\b(?:do not|don't|dont|never) (?:tell|inform|notify|alert|mention (?:this |it )?to|reveal (?:this |it )?to|show (?:this |it )?to) (?:the )?user",
6437
+ "\\bwithout (?:telling|informing|notifying|alerting) (?:the )?user",
6438
+ "\\b(?:hide|conceal|keep) (?:this |it |that )?(?:secret |hidden )?from (?:the )?user",
6439
+ "\\bthe user (?:must|should) not (?:know|see|be told)"
6440
+ ],
6441
+ "scan/desc/call-other-tool-first": [
6442
+ "\\b(?:before|prior to) (?:using|calling|invoking|running) this tool,? (?:you )?(?:must |should |always )?(?:first )?(?:call|use|invoke|run)\\b",
6443
+ "\\b(?:always |must )?(?:first )?(?:call|invoke|run) (?:the )?[\\w.-]+ (?:tool )?(?:first|beforehand|before (?:this|using this|calling this))\\b",
6444
+ "\\binstead of (?:this tool|calling this tool|using this tool),? (?:call|use|invoke)\\b"
6445
+ ],
6446
+ "scan/desc/param-asks-for-context": [
6447
+ "\\b(?:the )?(?:entire|full|whole|complete) (?:conversation|chat|dialog(?:ue)?|history|context|transcript)",
6448
+ "\\bconversation history\\b",
6449
+ "\\b(?:all |the )?(?:previous|prior|earlier) messages\\b",
6450
+ "\\bsystem prompt\\b",
6451
+ "\\b(?:contents?|text) of (?:the |any |a )?(?:file|files|document)\\b",
6452
+ "\\b(?:output|result|response) (?:of|from) (?:the |another |other |any )?(?:tools?)\\b"
6453
+ ]
6454
+ }
6455
+ };
6456
+
6457
+ // src/mcp-testing/scan/descriptions.ts
6458
+ var MAX_TEXT_BYTES = 1024 * 1024;
6459
+ var EXCERPT = 80;
6460
+ var U = (cp) => `U+${cp.toString(16).toUpperCase().padStart(4, "0")}`;
6461
+ var SHOWN = /^[\p{L}\p{N}\p{P}\p{S} ]$/u;
6462
+ function visible(s, max = EXCERPT) {
6463
+ const pieces = [];
6464
+ let len = 0;
6465
+ for (const ch of s) {
6466
+ const piece = SHOWN.test(ch) ? ch : `[${U(ch.codePointAt(0))}]`;
6467
+ pieces.push(piece);
6468
+ len += [...piece].length;
6469
+ if (len > max) {
6470
+ while (len > max - 3) len -= [...pieces.pop()].length;
6471
+ return `${pieces.join("")}...`;
6472
+ }
6473
+ }
6474
+ return pieces.join("");
6475
+ }
6476
+ var EMOJI = new RegExp("\\p{Extended_Pictographic}", "u");
6477
+ var PHRASES = Object.fromEntries(
6478
+ Object.entries(DESCRIPTION_PHRASES.rules).map(([id, list2]) => [id, new RegExp(list2.map((p) => `(?:${p.replace(/ /g, "\\s+")})`).join("|"), "giu")])
6479
+ );
6480
+
6481
+ // src/mcp-testing/scan/config/json-tree.ts
6482
+ init_cjs_shims();
6483
+
6484
+ // src/mcp-testing/scan/config/config.ts
6485
+ var MAX_FILE_BYTES = 8 * 1024 * 1024;
6486
+ var MAX_VALUE = 64 * 1024;
6487
+ var SHOWN_NAME = 64;
6488
+ var KNOWN_FORMATS = [
6489
+ ["github-token", /(?<![A-Za-z0-9])(?:gh[pousr]_|github_pat_)[A-Za-z0-9_]{36,}/],
6490
+ ["aws-access-key-id", /(?<![A-Za-z0-9])(?:AKIA|ASIA|AGPA|AIDA|AROA)[A-Z2-7]{16}(?![A-Za-z0-9])/],
6491
+ ["slack-token", /(?<![A-Za-z0-9])xox[abprs]-[A-Za-z0-9-]{10,}/],
6492
+ ["stripe-key", /(?<![A-Za-z0-9])[rs]k_live_[A-Za-z0-9]{16,}/],
6493
+ ["anthropic-key", /(?<![A-Za-z0-9])sk-ant-[A-Za-z0-9_-]{20,}/],
6494
+ ["openai-key", /(?<![A-Za-z0-9])sk-(?:proj|svcacct)-[A-Za-z0-9_-]{32,}/],
6495
+ ["google-api-key", /(?<![A-Za-z0-9])AIza[0-9A-Za-z_-]{35}/],
6496
+ ["npm-token", /(?<![A-Za-z0-9])npm_[A-Za-z0-9]{36}(?![A-Za-z0-9])/],
6497
+ ["gitlab-token", /(?<![A-Za-z0-9])glpat-[A-Za-z0-9_-]{20}/],
6498
+ ["private-key", /-----BEGIN (?:[A-Z]+ )*PRIVATE KEY-----/]
6499
+ ];
6500
+ var KEY_PREFIX = /^\s*(?:gh[pousr]_|github_pat_|AKIA|ASIA|AGPA|AIDA|AROA|xox[abprs]-|[rs]k_live_|sk-ant-|AIza|npm_|glpat-|-----BEGIN )/;
6501
+ var NAME_FORMATS = KNOWN_FORMATS.map(
6502
+ ([, re]) => new RegExp(re.source.replace("(?<![A-Za-z0-9])", "").replace("(?![A-Za-z0-9])", ""), re.flags)
6503
+ );
6504
+ var tokenish = (name) => {
6505
+ const head = name.slice(0, 256);
6506
+ return KEY_PREFIX.test(head) || NAME_FORMATS.some((re) => re.test(head));
6507
+ };
6508
+ var safe = (name) => noCommands(visible(tokenish(name) ? "[key]" : name, SHOWN_NAME));
6509
+ var safeText = (text) => noCommands(
6510
+ visible(
6511
+ text.slice(0, 1024).replace(/[^\\/]+/g, (seg) => tokenish(seg) ? "[key]" : seg),
6512
+ 400
6513
+ )
6514
+ );
6515
+
6516
+ // src/cli/commands/cairn-artifact.ts
4476
6517
  var SUPPORTED_ARTIFACT_VERSION = 1;
4477
6518
  var INGEST_SCHEMA_VERSION = 1;
4478
6519
  var NoCairnRunsError = class extends Error {
@@ -4522,6 +6563,14 @@ var CairnRunPartialError = class extends Error {
4522
6563
  this.name = "CairnRunPartialError";
4523
6564
  }
4524
6565
  };
6566
+ var CairnArtifactShapeError = class extends Error {
6567
+ constructor(file, field, problem) {
6568
+ super(
6569
+ `Cannot read this Cairn run: ${file}${field === "" ? "" : field.startsWith("[") ? field : ` ${field}`} ${problem}. Nothing was uploaded.`
6570
+ );
6571
+ this.name = "CairnArtifactShapeError";
6572
+ }
6573
+ };
4525
6574
  var CairnEvidenceAmbiguousError = class extends Error {
4526
6575
  constructor(name) {
4527
6576
  super(
@@ -4532,6 +6581,28 @@ var CairnEvidenceAmbiguousError = class extends Error {
4532
6581
  };
4533
6582
  var asRecord = (v) => typeof v === "object" && v !== null ? v : {};
4534
6583
  var str = (v, fallback = "") => typeof v === "string" && v !== "" ? v : fallback;
6584
+ var own = (rec, key) => Object.hasOwn(rec, key) ? rec[key] : void 0;
6585
+ var MAX_ARTIFACT_BYTES = 32 * 1024 * 1024;
6586
+ var MAX_MCP_CASES = 5e3;
6587
+ async function checkSize(dir, file) {
6588
+ let size;
6589
+ try {
6590
+ const st = await fs7.stat(path7.join(dir, file));
6591
+ if (!st.isFile()) throw new CairnArtifactShapeError(file, "", "is not a regular file");
6592
+ size = st.size;
6593
+ } catch (e) {
6594
+ if (e instanceof CairnArtifactShapeError) throw e;
6595
+ return false;
6596
+ }
6597
+ if (size > MAX_ARTIFACT_BYTES) {
6598
+ throw new CairnArtifactShapeError(
6599
+ file,
6600
+ "",
6601
+ `is larger than ${MAX_ARTIFACT_BYTES / (1024 * 1024)} MiB`
6602
+ );
6603
+ }
6604
+ return true;
6605
+ }
4535
6606
  async function readJson(file) {
4536
6607
  try {
4537
6608
  return JSON.parse(await fs7.readFile(file, "utf8"));
@@ -4539,6 +6610,170 @@ async function readJson(file) {
4539
6610
  return void 0;
4540
6611
  }
4541
6612
  }
6613
+ var ARGS_CHARS2 = 200;
6614
+ var SECRET_NAME = /key|token|secret|password|passwd|auth|cookie|credential/i;
6615
+ var maskNamed = (v, depth = 0) => {
6616
+ if (depth > 16) return "[deep]";
6617
+ if (Array.isArray(v)) return v.slice(0, 50).map((x) => maskNamed(x, depth + 1));
6618
+ if (typeof v === "object" && v !== null) {
6619
+ const out = {};
6620
+ for (const [k, x] of Object.entries(v).slice(0, 50)) {
6621
+ out[k] = SECRET_NAME.test(k) ? "***" : maskNamed(x, depth + 1);
6622
+ }
6623
+ return out;
6624
+ }
6625
+ return v;
6626
+ };
6627
+ function describeMcpArgs(request) {
6628
+ let text = request.slice(0, 4096);
6629
+ try {
6630
+ text = JSON.stringify(maskNamed(JSON.parse(text)));
6631
+ } catch {
6632
+ }
6633
+ const masked = safeText(redactSecrets(text));
6634
+ return masked.length > ARGS_CHARS2 ? `${masked.slice(0, ARGS_CHARS2)} (cut)` : masked;
6635
+ }
6636
+ var MCP_STATES = /* @__PURE__ */ new Set([
6637
+ "passed",
6638
+ "failed",
6639
+ "not-sent",
6640
+ "could-not-run",
6641
+ "needs-review"
6642
+ ]);
6643
+ async function readMcpEvidence(dir, states) {
6644
+ const file = "mcp-evidence.json";
6645
+ if (!await checkSize(dir, file)) return void 0;
6646
+ let raw;
6647
+ try {
6648
+ raw = JSON.parse(await fs7.readFile(path7.join(dir, file), "utf8"));
6649
+ } catch {
6650
+ throw new CairnArtifactShapeError(file, "", "is not valid JSON");
6651
+ }
6652
+ if (!Array.isArray(raw)) throw new CairnArtifactShapeError(file, "", "must be a list");
6653
+ if (raw.length > MAX_MCP_CASES) {
6654
+ throw new CairnArtifactShapeError(file, "", `lists more than ${MAX_MCP_CASES} entries`);
6655
+ }
6656
+ const byId = /* @__PURE__ */ new Map();
6657
+ raw.forEach((item, i) => {
6658
+ if (typeof item !== "object" || item === null || Array.isArray(item)) {
6659
+ throw new CairnArtifactShapeError(file, `[${i}]`, "must be an object");
6660
+ }
6661
+ const rec = item;
6662
+ const id = own(rec, "stableId");
6663
+ if (typeof id !== "string" || !states.has(id)) {
6664
+ throw new CairnArtifactShapeError(
6665
+ file,
6666
+ `[${i}].stableId`,
6667
+ "does not name a case of report.json"
6668
+ );
6669
+ }
6670
+ if (byId.has(id)) {
6671
+ throw new CairnArtifactShapeError(file, `[${i}].stableId`, "appears more than once");
6672
+ }
6673
+ if (own(rec, "state") !== states.get(id)) {
6674
+ throw new CairnArtifactShapeError(
6675
+ file,
6676
+ `[${i}].state`,
6677
+ "does not agree with the state in report.json"
6678
+ );
6679
+ }
6680
+ const request = own(rec, "request");
6681
+ if (request !== void 0 && typeof request !== "string") {
6682
+ throw new CairnArtifactShapeError(file, `[${i}].request`, "must be text");
6683
+ }
6684
+ const durationMs = own(rec, "durationMs");
6685
+ if (durationMs !== void 0 && typeof durationMs !== "number") {
6686
+ throw new CairnArtifactShapeError(file, `[${i}].durationMs`, "must be a number");
6687
+ }
6688
+ byId.set(id, {
6689
+ sent: typeof durationMs === "number",
6690
+ ...request !== void 0 ? { request } : {}
6691
+ });
6692
+ });
6693
+ return byId;
6694
+ }
6695
+ function expectedOfMcp(type, adversarial) {
6696
+ if (type === "Positive") {
6697
+ return "The call finishes without an error, and the answer fits the tool's outputSchema when it has one.";
6698
+ }
6699
+ return adversarial ? "The server rejects the call, or handles the value without harm." : "The server rejects the call: it does not act on a value the tool's inputSchema forbids.";
6700
+ }
6701
+ async function casesFromMcp(dir, report) {
6702
+ const list2 = own(report, "cases");
6703
+ if (!Array.isArray(list2))
6704
+ throw new CairnArtifactShapeError("report.json", "cases", "must be a list");
6705
+ if (list2.length > MAX_MCP_CASES) {
6706
+ throw new CairnArtifactShapeError(
6707
+ "report.json",
6708
+ "cases",
6709
+ `lists more than ${MAX_MCP_CASES} cases`
6710
+ );
6711
+ }
6712
+ const states = /* @__PURE__ */ new Map();
6713
+ const parsed2 = list2.map((raw, i) => {
6714
+ const at = `cases[${i}]`;
6715
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
6716
+ throw new CairnArtifactShapeError("report.json", at, "must be an object");
6717
+ }
6718
+ const c = raw;
6719
+ const text = (key) => {
6720
+ const v = own(c, key);
6721
+ if (typeof v !== "string" || v === "") {
6722
+ throw new CairnArtifactShapeError("report.json", `${at}.${key}`, "must be text");
6723
+ }
6724
+ return v;
6725
+ };
6726
+ const stableId = text("stableId");
6727
+ const name = text("name");
6728
+ const tool = text("tool");
6729
+ const type = text("type");
6730
+ const state = text("state");
6731
+ if (type !== "Positive" && type !== "Negative") {
6732
+ throw new CairnArtifactShapeError(
6733
+ "report.json",
6734
+ `${at}.type`,
6735
+ `is "${safe(type)}", not Positive or Negative`
6736
+ );
6737
+ }
6738
+ if (!MCP_STATES.has(state)) {
6739
+ throw new CairnArtifactShapeError(
6740
+ "report.json",
6741
+ `${at}.state`,
6742
+ `is "${safe(state)}", a state this CLI does not know`
6743
+ );
6744
+ }
6745
+ if (states.has(stableId)) {
6746
+ throw new CairnArtifactShapeError("report.json", `${at}.stableId`, "appears more than once");
6747
+ }
6748
+ states.set(stableId, state);
6749
+ const kind = type;
6750
+ const technique = own(c, "technique");
6751
+ return {
6752
+ stableId,
6753
+ name,
6754
+ tool,
6755
+ type: kind,
6756
+ state,
6757
+ adversarial: own(c, "adversarialStyle") !== void 0,
6758
+ ...typeof technique === "string" ? { technique } : {}
6759
+ };
6760
+ });
6761
+ const evidence = await readMcpEvidence(dir, states);
6762
+ return parsed2.map((c) => {
6763
+ const e = evidence?.get(c.stableId);
6764
+ const verdict = c.state === "passed" ? "passed" : c.state === "failed" ? "failed" : c.state === "could-not-run" && e?.sent === true ? "blocked" : void 0;
6765
+ const args = e?.request !== void 0 ? ` ${describeMcpArgs(e.request)}` : "";
6766
+ return {
6767
+ stableId: c.stableId,
6768
+ title: safeText(c.name),
6769
+ execution: "auto",
6770
+ steps: [`tools/call ${safe(c.tool)}${args}`],
6771
+ expected: expectedOfMcp(c.type, c.adversarial),
6772
+ ...verdict !== void 0 ? { verdict } : {},
6773
+ ...c.technique !== void 0 ? { technique: safeText(c.technique) } : {}
6774
+ };
6775
+ });
6776
+ }
4542
6777
  async function defaultReadEvidence(dir) {
4543
6778
  const raw = await readJson(path7.join(dir, "api-evidence.json"));
4544
6779
  if (!Array.isArray(raw)) return void 0;
@@ -4549,8 +6784,8 @@ async function defaultReadEvidence(dir) {
4549
6784
  });
4550
6785
  }
4551
6786
  function casesFromDesign(report) {
4552
- const list = Array.isArray(report["testCases"]) ? report["testCases"] : [];
4553
- return list.map((raw) => {
6787
+ const list2 = Array.isArray(report["testCases"]) ? report["testCases"] : [];
6788
+ return list2.map((raw) => {
4554
6789
  const c = asRecord(raw);
4555
6790
  const steps = (Array.isArray(c["steps"]) ? c["steps"] : []).map((s) => str(s)).filter((s) => s !== "");
4556
6791
  return {
@@ -4565,8 +6800,8 @@ function casesFromDesign(report) {
4565
6800
  });
4566
6801
  }
4567
6802
  function casesFromApi(report, verdicts) {
4568
- const list = Array.isArray(report["cases"]) ? report["cases"] : [];
4569
- return list.map((raw) => {
6803
+ const list2 = Array.isArray(report["cases"]) ? report["cases"] : [];
6804
+ return list2.map((raw) => {
4570
6805
  const c = asRecord(raw);
4571
6806
  const name = str(c["name"], "unnamed operation");
4572
6807
  const request = `${str(c["method"], "GET")} ${str(c["path"], "/")}`;
@@ -4583,6 +6818,7 @@ function casesFromApi(report, verdicts) {
4583
6818
  });
4584
6819
  }
4585
6820
  async function readCairnRun(dir, deps = {}) {
6821
+ await checkSize(dir, "report.json");
4586
6822
  const raw = await readJson(path7.join(dir, "report.json"));
4587
6823
  if (raw === void 0) throw new CairnRunNotFoundError(dir);
4588
6824
  const report = asRecord(raw);
@@ -4593,7 +6829,7 @@ async function readCairnRun(dir, deps = {}) {
4593
6829
  throw new CairnRunPartialError(str(report["error"], "no reason recorded"));
4594
6830
  }
4595
6831
  const mode = report["mode"];
4596
- if (mode !== "design" && mode !== "explore" && mode !== "api") {
6832
+ if (mode !== "design" && mode !== "explore" && mode !== "api" && mode !== "mcp") {
4597
6833
  throw new CairnRunVersionError(
4598
6834
  `${SUPPORTED_ARTIFACT_VERSION} (unknown run mode ${String(mode)})`
4599
6835
  );
@@ -4607,6 +6843,8 @@ async function readCairnRun(dir, deps = {}) {
4607
6843
  verdicts.set(e.name, e.error !== void 0 ? "blocked" : e.passed ? "passed" : "failed");
4608
6844
  }
4609
6845
  cases = casesFromApi(report, verdicts);
6846
+ } else if (mode === "mcp") {
6847
+ cases = await casesFromMcp(dir, report);
4610
6848
  } else {
4611
6849
  cases = casesFromDesign(report);
4612
6850
  }
@@ -4702,7 +6940,7 @@ async function handleIngest(deps) {
4702
6940
  }
4703
6941
  }
4704
6942
  function reportIngestFailure(err, write) {
4705
- if (err instanceof IngestNotLoggedInError || err instanceof IngestTokenRejectedError || err instanceof CairnRunNotFoundError || err instanceof NoCairnRunsError || err instanceof CairnRunVersionError || err instanceof CairnRunPartialError || err instanceof CairnEvidenceAmbiguousError) {
6943
+ if (err instanceof IngestNotLoggedInError || err instanceof IngestTokenRejectedError || err instanceof CairnRunNotFoundError || err instanceof NoCairnRunsError || err instanceof CairnRunVersionError || err instanceof CairnRunPartialError || err instanceof CairnEvidenceAmbiguousError || err instanceof CairnArtifactShapeError) {
4706
6944
  write(`${err.message}
4707
6945
  `);
4708
6946
  return 2;