@plune-ai/cli 0.36.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/README.md +54 -3
- package/THIRD_PARTY_NOTICES +229 -0
- package/dist/cli.cjs +28789 -10649
- package/dist/index.cjs +2484 -168
- package/dist/index.d.cts +79 -4
- package/dist/index.d.ts +79 -4
- package/dist/index.js +2484 -168
- package/dist/mcp-tools.cjs +50 -12
- package/dist/mcp-tools.d.cts +9 -0
- package/dist/mcp-tools.d.ts +9 -0
- package/dist/mcp-tools.js +50 -12
- package/package.json +2 -1
- package/skills/qa-mission/SKILL.md +243 -0
- package/skills/qa-mission/references/tool-calls.md +157 -0
package/dist/index.js
CHANGED
|
@@ -26,8 +26,8 @@ function machineless(raw, repoRoot, home) {
|
|
|
26
26
|
let text = stripVTControlCharacters(raw).replaceAll("\x1B", "");
|
|
27
27
|
const root = repoRoot === void 0 ? void 0 : pathIn(repoRoot);
|
|
28
28
|
if (root !== void 0) text = text.replace(new RegExp(`${PATH_START}${root.source}[\\\\/]+`, root.flags), "");
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
29
|
+
const own2 = pathIn(home);
|
|
30
|
+
if (own2 !== void 0) text = text.replace(new RegExp(`${PATH_START}${own2.source}(?![\\w.-])`, own2.flags), "~");
|
|
31
31
|
if (repoRoot === void 0) text = text.replace(ANY_HOME, "~");
|
|
32
32
|
return text;
|
|
33
33
|
}
|
|
@@ -129,8 +129,8 @@ function processTable() {
|
|
|
129
129
|
return readdirSync("/proc").flatMap((name) => {
|
|
130
130
|
if (!/^\d+$/.test(name)) return [];
|
|
131
131
|
try {
|
|
132
|
-
const
|
|
133
|
-
const fields =
|
|
132
|
+
const stat2 = readFileSync3(`/proc/${name}/stat`, "utf8");
|
|
133
|
+
const fields = stat2.slice(stat2.lastIndexOf(")") + 2).split(" ");
|
|
134
134
|
return parseProcessTable(`${name} ${fields[1]} ${fields[19]}`);
|
|
135
135
|
} catch {
|
|
136
136
|
return [];
|
|
@@ -359,11 +359,15 @@ var init_redact = __esm({
|
|
|
359
359
|
var session_exports = {};
|
|
360
360
|
__export(session_exports, {
|
|
361
361
|
ConnectError: () => ConnectError,
|
|
362
|
+
STDERR_LINE_LIMIT: () => STDERR_LINE_LIMIT,
|
|
362
363
|
STDIO_MESSAGE_LIMIT: () => STDIO_MESSAGE_LIMIT,
|
|
363
364
|
closeAllSessions: () => closeAllSessions,
|
|
364
|
-
|
|
365
|
+
headerValue: () => headerValue,
|
|
366
|
+
openSession: () => openSession,
|
|
367
|
+
readLines: () => readLines
|
|
365
368
|
});
|
|
366
369
|
import { homedir as homedir2 } from "os";
|
|
370
|
+
import { StringDecoder } from "string_decoder";
|
|
367
371
|
import { createInterface } from "readline";
|
|
368
372
|
import {
|
|
369
373
|
Client,
|
|
@@ -377,6 +381,26 @@ import {
|
|
|
377
381
|
UnauthorizedError
|
|
378
382
|
} from "@modelcontextprotocol/client";
|
|
379
383
|
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
|
384
|
+
function headerValue(value) {
|
|
385
|
+
const plain = /^[\x21-\x7e]([\x20-\x7e]*[\x21-\x7e])?$/.test(value) && !/^=\?base64\?.*\?=$/.test(value);
|
|
386
|
+
return plain ? value : `=?base64?${Buffer.from(value, "utf8").toString("base64")}?=`;
|
|
387
|
+
}
|
|
388
|
+
function modernHeaders(body, version) {
|
|
389
|
+
const m = parsed(body);
|
|
390
|
+
if (m === null || typeof m !== "object" || Array.isArray(m)) return [];
|
|
391
|
+
const { method, params } = m;
|
|
392
|
+
if (typeof method !== "string") return [];
|
|
393
|
+
const meta = params?.["_meta"];
|
|
394
|
+
const v = meta?.["io.modelcontextprotocol/protocolVersion"];
|
|
395
|
+
const headers = [
|
|
396
|
+
["mcp-protocol-version", typeof v === "string" ? v : version],
|
|
397
|
+
["mcp-method", method]
|
|
398
|
+
];
|
|
399
|
+
const name = method === "resources/read" ? params?.["uri"] : params?.["name"];
|
|
400
|
+
if (["tools/call", "resources/read", "prompts/get"].includes(method) && typeof name === "string")
|
|
401
|
+
headers.push(["mcp-name", headerValue(name)]);
|
|
402
|
+
return headers;
|
|
403
|
+
}
|
|
380
404
|
function answers(frame, id) {
|
|
381
405
|
if (frame === null || typeof frame !== "object" || Array.isArray(frame)) return false;
|
|
382
406
|
const f = frame;
|
|
@@ -391,6 +415,40 @@ function fromEventStream(text, id) {
|
|
|
391
415
|
}
|
|
392
416
|
return void 0;
|
|
393
417
|
}
|
|
418
|
+
function readLines(stream, onLine, stats) {
|
|
419
|
+
const decoder = new StringDecoder("utf8");
|
|
420
|
+
let partial = "";
|
|
421
|
+
const feed = (text) => {
|
|
422
|
+
let from = 0;
|
|
423
|
+
for (let nl = text.indexOf("\n", from); nl >= 0; nl = text.indexOf("\n", from)) {
|
|
424
|
+
const whole = partial + text.slice(from, nl);
|
|
425
|
+
if (stats !== void 0 && whole.length > stats.high) stats.high = whole.length;
|
|
426
|
+
const line = whole.slice(0, STDERR_LINE_LIMIT);
|
|
427
|
+
partial = "";
|
|
428
|
+
onLine(line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
429
|
+
from = nl + 1;
|
|
430
|
+
}
|
|
431
|
+
const rest = partial + text.slice(from);
|
|
432
|
+
if (stats !== void 0 && rest.length > stats.high) stats.high = rest.length;
|
|
433
|
+
partial = rest.slice(0, STDERR_LINE_LIMIT);
|
|
434
|
+
};
|
|
435
|
+
return new Promise((resolve8) => {
|
|
436
|
+
let done = false;
|
|
437
|
+
const finish = () => {
|
|
438
|
+
if (done) return;
|
|
439
|
+
done = true;
|
|
440
|
+
feed(decoder.end());
|
|
441
|
+
if (partial !== "") onLine(partial.endsWith("\r") ? partial.slice(0, -1) : partial);
|
|
442
|
+
resolve8();
|
|
443
|
+
};
|
|
444
|
+
stream.on(
|
|
445
|
+
"data",
|
|
446
|
+
(chunk) => feed(typeof chunk === "string" ? chunk : decoder.write(chunk))
|
|
447
|
+
);
|
|
448
|
+
stream.once("end", finish);
|
|
449
|
+
stream.once("close", finish);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
394
452
|
function createTransport(target) {
|
|
395
453
|
if (target.kind === "stdio") {
|
|
396
454
|
return new StdioClientTransport({
|
|
@@ -488,7 +546,7 @@ function kindOf(err, stdio, transportClosed) {
|
|
|
488
546
|
return "network";
|
|
489
547
|
return "protocol";
|
|
490
548
|
}
|
|
491
|
-
async function openSession(config) {
|
|
549
|
+
async function openSession(config, options = {}) {
|
|
492
550
|
const { target } = config;
|
|
493
551
|
const stdio = target.kind === "stdio";
|
|
494
552
|
const redact = redactorFor(target);
|
|
@@ -498,10 +556,12 @@ async function openSession(config) {
|
|
|
498
556
|
const transport = createTransport(target);
|
|
499
557
|
let transportClosed = false;
|
|
500
558
|
let spawnError;
|
|
559
|
+
const stopped = /* @__PURE__ */ new Set();
|
|
501
560
|
const handshake = {
|
|
502
561
|
offered: void 0,
|
|
503
562
|
result: void 0
|
|
504
563
|
};
|
|
564
|
+
const notifications = /* @__PURE__ */ new Map();
|
|
505
565
|
tap(transport, journal, {
|
|
506
566
|
frame: (dir, message) => {
|
|
507
567
|
const m = message;
|
|
@@ -510,11 +570,18 @@ async function openSession(config) {
|
|
|
510
570
|
handshake.offered = m.params?.protocolVersion;
|
|
511
571
|
} else if (dir === "in" && handshake.id !== void 0 && m.id === handshake.id)
|
|
512
572
|
handshake.result = m.result;
|
|
573
|
+
if (dir === "in" && m.id === void 0 && typeof m.method === "string")
|
|
574
|
+
notifications.set(m.method, (notifications.get(m.method) ?? 0) + 1);
|
|
575
|
+
},
|
|
576
|
+
closed: () => {
|
|
577
|
+
transportClosed = true;
|
|
578
|
+
for (const stop of [...stopped]) stop();
|
|
513
579
|
},
|
|
514
|
-
closed: () => transportClosed = true,
|
|
515
580
|
error: (err) => {
|
|
516
|
-
if (spawnError === void 0 && err.syscall?.startsWith("spawn") === true)
|
|
581
|
+
if (spawnError === void 0 && err.syscall?.startsWith("spawn") === true) {
|
|
517
582
|
spawnError = err;
|
|
583
|
+
for (const stop of [...stopped]) stop();
|
|
584
|
+
}
|
|
518
585
|
}
|
|
519
586
|
});
|
|
520
587
|
let noted;
|
|
@@ -526,23 +593,30 @@ async function openSession(config) {
|
|
|
526
593
|
let tooLarge = false;
|
|
527
594
|
const tail = [];
|
|
528
595
|
const noise = { count: 0, first: [] };
|
|
596
|
+
const traffic = [];
|
|
597
|
+
const methods = /* @__PURE__ */ new Map();
|
|
598
|
+
const heard = (frame) => {
|
|
599
|
+
if (frame === null || typeof frame !== "object" || Array.isArray(frame)) return;
|
|
600
|
+
const f = frame;
|
|
601
|
+
const method = "method" in f || f["id"] === void 0 ? void 0 : methods.get(f["id"]);
|
|
602
|
+
traffic.push(method === void 0 ? { frame: f } : { frame: f, method });
|
|
603
|
+
};
|
|
529
604
|
const listeners = /* @__PURE__ */ new Set();
|
|
530
605
|
const seen = (line, isMessage) => {
|
|
531
606
|
if (!isMessage) {
|
|
532
607
|
noise.count++;
|
|
533
608
|
if (noise.first.length < 3) noise.first.push(clean(line).slice(0, 200));
|
|
534
609
|
}
|
|
610
|
+
if (isMessage) heard(parsed(line));
|
|
535
611
|
for (const listener of [...listeners]) listener(line);
|
|
536
612
|
};
|
|
537
613
|
let stderrDone = Promise.resolve();
|
|
538
614
|
if (transport instanceof StdioClientTransport && transport.stderr !== null) {
|
|
539
|
-
|
|
540
|
-
lines.on("line", (line) => {
|
|
615
|
+
stderrDone = readLines(transport.stderr, (line) => {
|
|
541
616
|
journal.write("stderr", { line });
|
|
542
617
|
tail.push(clean(line));
|
|
543
618
|
if (tail.length > TAIL_LINES) tail.shift();
|
|
544
619
|
});
|
|
545
|
-
stderrDone = new Promise((resolve8) => lines.once("close", resolve8));
|
|
546
620
|
watchStdout(transport, journal, seen);
|
|
547
621
|
watchOverflow(transport, () => {
|
|
548
622
|
if (tooLarge) return;
|
|
@@ -582,10 +656,19 @@ async function openSession(config) {
|
|
|
582
656
|
};
|
|
583
657
|
const untrack = track(closable);
|
|
584
658
|
const client = new Client({ name: "plune", version: config.clientVersion ?? "0.0.0" });
|
|
659
|
+
const modern = options.modern;
|
|
660
|
+
if (modern !== void 0) {
|
|
661
|
+
transport.onmessage = () => {
|
|
662
|
+
};
|
|
663
|
+
transport.onerror = () => {
|
|
664
|
+
};
|
|
665
|
+
transport.onclose = () => {
|
|
666
|
+
};
|
|
667
|
+
}
|
|
585
668
|
let timer;
|
|
586
669
|
try {
|
|
587
670
|
await Promise.race([
|
|
588
|
-
client.connect(transport, { timeout: config.timeoutMs }),
|
|
671
|
+
modern === void 0 ? client.connect(transport, { timeout: config.timeoutMs }) : transport.start(),
|
|
589
672
|
new Promise((_, reject) => {
|
|
590
673
|
timer = setTimeout(
|
|
591
674
|
() => reject(new SdkError(SdkErrorCode.RequestTimeout, "no answer")),
|
|
@@ -612,12 +695,12 @@ async function openSession(config) {
|
|
|
612
695
|
server: info === void 0 ? void 0 : { name: String(info.name), version: String(info.version) },
|
|
613
696
|
handshake: { offered: handshake.offered, result: handshake.result },
|
|
614
697
|
stderrTail: () => [...tail],
|
|
615
|
-
async request(method, params,
|
|
698
|
+
async request(method, params, options2) {
|
|
616
699
|
try {
|
|
617
700
|
return await client.request(
|
|
618
701
|
params === void 0 ? { method } : { method, params },
|
|
619
702
|
AS_SENT,
|
|
620
|
-
{ timeout:
|
|
703
|
+
{ timeout: options2?.timeoutMs ?? config.timeoutMs }
|
|
621
704
|
);
|
|
622
705
|
} catch (err) {
|
|
623
706
|
if (err instanceof ProtocolError)
|
|
@@ -627,7 +710,7 @@ async function openSession(config) {
|
|
|
627
710
|
},
|
|
628
711
|
fetchForOrigin(origin) {
|
|
629
712
|
const allowed = new URL(origin).origin;
|
|
630
|
-
const
|
|
713
|
+
const own2 = target.kind !== "stdio" && new URL(target.url).origin === allowed;
|
|
631
714
|
return async (input, init) => {
|
|
632
715
|
const url = new URL(input);
|
|
633
716
|
if (url.origin !== allowed)
|
|
@@ -635,36 +718,47 @@ async function openSession(config) {
|
|
|
635
718
|
`fetchForOrigin(${allowed}) refuses a request to another origin, ${url.origin}.`
|
|
636
719
|
);
|
|
637
720
|
const headers = new Headers(init?.headers);
|
|
638
|
-
if (
|
|
721
|
+
if (own2) {
|
|
639
722
|
for (const [name, value] of Object.entries(target.headers))
|
|
640
723
|
if (!headers.has(name)) headers.set(name, value);
|
|
641
724
|
}
|
|
642
725
|
return fetch(url, { ...init, headers, redirect: "manual" });
|
|
643
726
|
};
|
|
644
727
|
},
|
|
645
|
-
async raw(body, id,
|
|
646
|
-
const ms =
|
|
728
|
+
async raw(body, id, options2) {
|
|
729
|
+
const ms = options2?.timeoutMs ?? config.timeoutMs;
|
|
647
730
|
if (target.kind === "sse")
|
|
648
731
|
throw new ConnectError("protocol", "Messages of its own go over stdio and Streamable HTTP only, not HTTP+SSE.", []);
|
|
649
732
|
journal.write("out", { raw: body });
|
|
650
733
|
const noAnswer = () => new ConnectError("timeout", `${LEAD.timeout[0]}.`, [...tail]);
|
|
734
|
+
const sent = parsed(body);
|
|
735
|
+
if (typeof sent?.method === "string" && sent.id !== void 0) methods.set(sent.id, sent.method);
|
|
651
736
|
if (target.kind === "stdio") {
|
|
652
737
|
const stdin = transport._process?.stdin;
|
|
653
738
|
if (stdin === null || stdin === void 0 || stdin.writableEnded)
|
|
654
|
-
throw new ConnectError("exited-early", `${LEAD["exited-early"][0]}.`, [...tail]);
|
|
739
|
+
throw spawnError !== void 0 ? await toConnectError(spawnError) : new ConnectError("exited-early", `${LEAD["exited-early"][0]}.`, [...tail]);
|
|
655
740
|
return new Promise((resolve8, reject) => {
|
|
656
|
-
const
|
|
741
|
+
const done = () => {
|
|
742
|
+
clearTimeout(timer2);
|
|
657
743
|
listeners.delete(listener);
|
|
744
|
+
stopped.delete(stop);
|
|
745
|
+
};
|
|
746
|
+
const timer2 = setTimeout(() => {
|
|
747
|
+
done();
|
|
658
748
|
reject(noAnswer());
|
|
659
749
|
}, ms);
|
|
660
750
|
const listener = (line) => {
|
|
661
751
|
const frame2 = parsed(line);
|
|
662
752
|
if (!answers(frame2, id)) return;
|
|
663
|
-
|
|
664
|
-
listeners.delete(listener);
|
|
753
|
+
done();
|
|
665
754
|
resolve8({ frame: frame2, text: clean(line).slice(0, RAW_TEXT) });
|
|
666
755
|
};
|
|
756
|
+
const stop = () => {
|
|
757
|
+
done();
|
|
758
|
+
void toConnectError(spawnError ?? new Error("closed")).then(reject);
|
|
759
|
+
};
|
|
667
760
|
listeners.add(listener);
|
|
761
|
+
stopped.add(stop);
|
|
668
762
|
stdin.write(`${body}
|
|
669
763
|
`);
|
|
670
764
|
});
|
|
@@ -675,6 +769,11 @@ async function openSession(config) {
|
|
|
675
769
|
headers.set("accept", "application/json, text/event-stream");
|
|
676
770
|
if (state.sessionId !== void 0) headers.set("mcp-session-id", state.sessionId);
|
|
677
771
|
if (state._protocolVersion !== void 0) headers.set("mcp-protocol-version", state._protocolVersion);
|
|
772
|
+
if (modern !== void 0) for (const [name, value] of modernHeaders(body, modern.version)) headers.set(name, value);
|
|
773
|
+
for (const [name, value] of options2?.headers ?? []) {
|
|
774
|
+
if (value === null) headers.delete(name);
|
|
775
|
+
else headers.set(name, value);
|
|
776
|
+
}
|
|
678
777
|
const lost = async (err) => err?.name === "TimeoutError" ? noAnswer() : toConnectError(err);
|
|
679
778
|
let text = "";
|
|
680
779
|
let frame;
|
|
@@ -706,14 +805,28 @@ async function openSession(config) {
|
|
|
706
805
|
const whole = parsed(text);
|
|
707
806
|
if (whole !== null && typeof whole === "object" && !Array.isArray(whole))
|
|
708
807
|
frame = whole;
|
|
709
|
-
|
|
808
|
+
heard(frame);
|
|
809
|
+
} else
|
|
810
|
+
for (const line of text.split(/\r?\n/)) if (line.startsWith("data:")) heard(parsed(line.slice(5).trim()));
|
|
710
811
|
} catch (err) {
|
|
711
812
|
throw await lost(err);
|
|
712
813
|
}
|
|
713
|
-
journal.write("in", frame !== void 0 ? { frame } : { status, raw: text.slice(0, RAW_TEXT) });
|
|
814
|
+
journal.write("in", frame !== void 0 ? { frame } : { status, raw: clean(text).slice(0, RAW_TEXT) });
|
|
714
815
|
return { frame, status, text: clean(text).slice(0, RAW_TEXT) };
|
|
715
816
|
},
|
|
817
|
+
async notify(body) {
|
|
818
|
+
if (target.kind !== "stdio")
|
|
819
|
+
throw new ConnectError("protocol", "notify is for a stdio server.", []);
|
|
820
|
+
const stdin = transport._process?.stdin;
|
|
821
|
+
if (stdin === null || stdin === void 0 || stdin.writableEnded)
|
|
822
|
+
throw spawnError !== void 0 ? await toConnectError(spawnError) : new ConnectError("exited-early", `${LEAD["exited-early"][0]}.`, [...tail]);
|
|
823
|
+
journal.write("out", { raw: body });
|
|
824
|
+
stdin.write(`${body}
|
|
825
|
+
`);
|
|
826
|
+
},
|
|
827
|
+
traffic: () => traffic,
|
|
716
828
|
stdoutNoise: () => ({ count: noise.count, first: [...noise.first] }),
|
|
829
|
+
notified: (method) => notifications.get(method) ?? 0,
|
|
717
830
|
async endInput(waitMs) {
|
|
718
831
|
const proc = transport._process;
|
|
719
832
|
if (proc === void 0) return true;
|
|
@@ -729,7 +842,7 @@ async function openSession(config) {
|
|
|
729
842
|
close: closable.close
|
|
730
843
|
};
|
|
731
844
|
}
|
|
732
|
-
var ConnectError, RAW_TEXT, parsed, TAIL_LINES, STDIO_MESSAGE_LIMIT, AS_SENT, firstLine, LEAD;
|
|
845
|
+
var ConnectError, RAW_TEXT, parsed, TAIL_LINES, STDERR_LINE_LIMIT, STDIO_MESSAGE_LIMIT, AS_SENT, firstLine, LEAD;
|
|
733
846
|
var init_session = __esm({
|
|
734
847
|
"src/mcp-testing/connect/session.ts"() {
|
|
735
848
|
"use strict";
|
|
@@ -760,6 +873,7 @@ var init_session = __esm({
|
|
|
760
873
|
}
|
|
761
874
|
};
|
|
762
875
|
TAIL_LINES = 20;
|
|
876
|
+
STDERR_LINE_LIMIT = 64 * 1024;
|
|
763
877
|
STDIO_MESSAGE_LIMIT = 10 * 1024 * 1024;
|
|
764
878
|
AS_SENT = {
|
|
765
879
|
"~standard": { version: 1, vendor: "plune", validate: (value) => ({ value }) }
|
|
@@ -840,10 +954,10 @@ async function listAll(session, method, key, opts = {}) {
|
|
|
840
954
|
cursor === void 0 ? void 0 : { cursor },
|
|
841
955
|
opts.timeoutMs === void 0 ? {} : { timeoutMs: opts.timeoutMs }
|
|
842
956
|
);
|
|
843
|
-
const listed =
|
|
957
|
+
const listed = isRecord5(page) ? page[key] : void 0;
|
|
844
958
|
if (Array.isArray(listed)) for (const item of listed) items.push(item);
|
|
845
959
|
else malformed = true;
|
|
846
|
-
cursor =
|
|
960
|
+
cursor = isRecord5(page) && typeof page.nextCursor === "string" && page.nextCursor !== "" ? page.nextCursor : void 0;
|
|
847
961
|
if (cursor === void 0) return { items, pages, complete: true, malformed };
|
|
848
962
|
}
|
|
849
963
|
return { items, pages: MAX_PAGES, complete: false, malformed };
|
|
@@ -852,12 +966,12 @@ function asTools(items) {
|
|
|
852
966
|
const tools = [];
|
|
853
967
|
const unnamed = /* @__PURE__ */ new Map();
|
|
854
968
|
for (const t of items) {
|
|
855
|
-
const name =
|
|
969
|
+
const name = isRecord5(t) ? t.name : void 0;
|
|
856
970
|
if (typeof name === "string" && name !== "") {
|
|
857
971
|
tools.push(t);
|
|
858
972
|
continue;
|
|
859
973
|
}
|
|
860
|
-
const tool = { ...
|
|
974
|
+
const tool = { ...isRecord5(t) ? t : {}, name: "" };
|
|
861
975
|
unnamed.set(tool, name === void 0 ? "(no name)" : String(JSON.stringify(name)));
|
|
862
976
|
tools.push(tool);
|
|
863
977
|
}
|
|
@@ -875,9 +989,9 @@ function callableTools(tools, unnamed, opts = {}) {
|
|
|
875
989
|
refused.push({ tool: t.name, reason: "duplicate-name" });
|
|
876
990
|
else candidates.push(t);
|
|
877
991
|
}
|
|
878
|
-
const { safe, skipped } = selectSafeTools(candidates, opts);
|
|
992
|
+
const { safe: safe2, skipped } = selectSafeTools(candidates, opts);
|
|
879
993
|
return {
|
|
880
|
-
safe,
|
|
994
|
+
safe: safe2,
|
|
881
995
|
skipped: [...refused, ...skipped.map((s) => ({ tool: s.tool.name, reason: s.reason }))]
|
|
882
996
|
};
|
|
883
997
|
}
|
|
@@ -894,7 +1008,7 @@ async function callTool(session, name, timeoutMs, args = {}) {
|
|
|
894
1008
|
throw err;
|
|
895
1009
|
}
|
|
896
1010
|
}
|
|
897
|
-
var MAX_PAGES,
|
|
1011
|
+
var MAX_PAGES, isRecord5;
|
|
898
1012
|
var init_tools = __esm({
|
|
899
1013
|
"src/mcp-testing/connect/tools.ts"() {
|
|
900
1014
|
"use strict";
|
|
@@ -902,7 +1016,7 @@ var init_tools = __esm({
|
|
|
902
1016
|
init_safe_tools();
|
|
903
1017
|
init_session();
|
|
904
1018
|
MAX_PAGES = 100;
|
|
905
|
-
|
|
1019
|
+
isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
906
1020
|
}
|
|
907
1021
|
});
|
|
908
1022
|
|
|
@@ -921,24 +1035,6 @@ import { parse } from "yaml";
|
|
|
921
1035
|
|
|
922
1036
|
// src/config/env-overrides.ts
|
|
923
1037
|
init_esm_shims();
|
|
924
|
-
function applyEnvOverrides(config, env) {
|
|
925
|
-
const result = structuredClone(config);
|
|
926
|
-
if (env["PLUNE_PROVIDER"] !== void 0) {
|
|
927
|
-
result.provider.type = env["PLUNE_PROVIDER"];
|
|
928
|
-
}
|
|
929
|
-
if (env["PLUNE_MODEL"] !== void 0) {
|
|
930
|
-
result.provider.model = env["PLUNE_MODEL"];
|
|
931
|
-
}
|
|
932
|
-
if (env["PLUNE_TIMEOUT"] !== void 0) {
|
|
933
|
-
const n = Number(env["PLUNE_TIMEOUT"]);
|
|
934
|
-
if (!isNaN(n)) result.provider.timeout = n;
|
|
935
|
-
}
|
|
936
|
-
if (env["PLUNE_MAX_RETRIES"] !== void 0) {
|
|
937
|
-
const n = Number(env["PLUNE_MAX_RETRIES"]);
|
|
938
|
-
if (!isNaN(n)) result.provider.max_retries = n;
|
|
939
|
-
}
|
|
940
|
-
return result;
|
|
941
|
-
}
|
|
942
1038
|
|
|
943
1039
|
// src/config/errors.ts
|
|
944
1040
|
init_esm_shims();
|
|
@@ -966,6 +1062,34 @@ var ConfigValidationError = class extends Error {
|
|
|
966
1062
|
}
|
|
967
1063
|
};
|
|
968
1064
|
|
|
1065
|
+
// src/config/env-overrides.ts
|
|
1066
|
+
function applyEnvOverrides(config, env) {
|
|
1067
|
+
const result = structuredClone(config);
|
|
1068
|
+
const all = result.providers ?? [result.provider];
|
|
1069
|
+
if (result.providers !== void 0) {
|
|
1070
|
+
for (const name of ["PLUNE_PROVIDER", "PLUNE_MODEL"])
|
|
1071
|
+
if (env[name] !== void 0)
|
|
1072
|
+
throw new ConfigValidationError("Config validation failed", [
|
|
1073
|
+
`${name} sets one model, but the config lists ${result.providers.length}: remove it or list a single model`
|
|
1074
|
+
]);
|
|
1075
|
+
}
|
|
1076
|
+
if (env["PLUNE_PROVIDER"] !== void 0) {
|
|
1077
|
+
result.provider.type = env["PLUNE_PROVIDER"];
|
|
1078
|
+
}
|
|
1079
|
+
if (env["PLUNE_MODEL"] !== void 0) {
|
|
1080
|
+
result.provider.model = env["PLUNE_MODEL"];
|
|
1081
|
+
}
|
|
1082
|
+
if (env["PLUNE_TIMEOUT"] !== void 0) {
|
|
1083
|
+
const n = Number(env["PLUNE_TIMEOUT"]);
|
|
1084
|
+
if (!isNaN(n)) for (const p of all) p.timeout = n;
|
|
1085
|
+
}
|
|
1086
|
+
if (env["PLUNE_MAX_RETRIES"] !== void 0) {
|
|
1087
|
+
const n = Number(env["PLUNE_MAX_RETRIES"]);
|
|
1088
|
+
if (!isNaN(n)) for (const p of all) p.max_retries = n;
|
|
1089
|
+
}
|
|
1090
|
+
return result;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
969
1093
|
// src/config/discover.ts
|
|
970
1094
|
init_esm_shims();
|
|
971
1095
|
import * as fs from "fs";
|
|
@@ -1100,7 +1224,16 @@ var providerConfigSchema = z.object({
|
|
|
1100
1224
|
max_tokens: z.number().int().positive().optional(),
|
|
1101
1225
|
concurrency: z.number().int().positive().optional(),
|
|
1102
1226
|
timeout: z.number().int().positive().optional(),
|
|
1103
|
-
max_retries: z.number().int().min(0).optional()
|
|
1227
|
+
max_retries: z.number().int().min(0).optional(),
|
|
1228
|
+
// The values the OpenAI SDK's Chat Completions `reasoning_effort` accepts; only `openai` sends it.
|
|
1229
|
+
reasoning_effort: z.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional()
|
|
1230
|
+
});
|
|
1231
|
+
var providerListSchema = z.array(providerConfigSchema).min(1);
|
|
1232
|
+
var providerField = z.any().transform((value, ctx) => {
|
|
1233
|
+
const r = (Array.isArray(value) ? providerListSchema : providerConfigSchema).safeParse(value);
|
|
1234
|
+
if (r.success) return r.data;
|
|
1235
|
+
for (const issue of r.error.issues) ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
|
|
1236
|
+
return z.NEVER;
|
|
1104
1237
|
});
|
|
1105
1238
|
var modelPriceSchema = z.object({
|
|
1106
1239
|
input_per_1k_usd: z.number().nonnegative(),
|
|
@@ -1177,7 +1310,7 @@ var toolCallAssertionSchemas = [
|
|
|
1177
1310
|
z.object({
|
|
1178
1311
|
type: z.literal("tool-args"),
|
|
1179
1312
|
tool: toolName,
|
|
1180
|
-
args: z.record(z.string(), z.unknown()),
|
|
1313
|
+
args: z.union([z.record(z.string(), z.unknown()), z.array(z.record(z.string(), z.unknown())).min(1)]),
|
|
1181
1314
|
match: z.enum(["partial", "exact", "ignore"]).optional(),
|
|
1182
1315
|
min_count: count.optional()
|
|
1183
1316
|
}),
|
|
@@ -1291,7 +1424,8 @@ var evalConfigSchema = z.object({
|
|
|
1291
1424
|
);
|
|
1292
1425
|
var pluneConfigSchema = z.object({
|
|
1293
1426
|
version: z.literal(1),
|
|
1294
|
-
|
|
1427
|
+
// One object, or a non-empty list of models to run every eval against (a one-element list is the object).
|
|
1428
|
+
provider: providerField,
|
|
1295
1429
|
defaults: z.object({ assertions: z.array(assertionConfigSchema).optional() }).optional(),
|
|
1296
1430
|
pricing: pricingSchema.optional(),
|
|
1297
1431
|
...evalRepeatsShape,
|
|
@@ -1299,6 +1433,34 @@ var pluneConfigSchema = z.object({
|
|
|
1299
1433
|
mcp: mcpRootSchema.optional(),
|
|
1300
1434
|
evals: z.array(evalConfigSchema).min(1)
|
|
1301
1435
|
}).strict().superRefine((config, ctx) => {
|
|
1436
|
+
if (Array.isArray(config.provider)) {
|
|
1437
|
+
const pairs = /* @__PURE__ */ new Set();
|
|
1438
|
+
const byModel = /* @__PURE__ */ new Map();
|
|
1439
|
+
config.provider.forEach((p, i) => {
|
|
1440
|
+
const pair = `${p.type}/${p.model}`;
|
|
1441
|
+
if (pairs.has(pair))
|
|
1442
|
+
ctx.addIssue({ code: "custom", path: ["provider", i], message: `provider "${pair}" is listed twice` });
|
|
1443
|
+
pairs.add(pair);
|
|
1444
|
+
const other = byModel.get(p.model);
|
|
1445
|
+
if (other !== void 0 && other !== p.type)
|
|
1446
|
+
ctx.addIssue({
|
|
1447
|
+
code: "custom",
|
|
1448
|
+
path: ["provider", i, "model"],
|
|
1449
|
+
message: `model "${p.model}" is listed under ${other} and ${p.type}: cell ids are built from the model name`
|
|
1450
|
+
});
|
|
1451
|
+
byModel.set(p.model, p.type);
|
|
1452
|
+
});
|
|
1453
|
+
if (config.provider.length > 1)
|
|
1454
|
+
config.evals.forEach((ev, i) => {
|
|
1455
|
+
for (const key of ["type", "model"])
|
|
1456
|
+
if (ev.provider?.[key] !== void 0)
|
|
1457
|
+
ctx.addIssue({
|
|
1458
|
+
code: "custom",
|
|
1459
|
+
path: ["evals", i, "provider", key],
|
|
1460
|
+
message: `eval "${ev.id}" sets provider.${key}, but the root provider lists several models: the models come from the root list`
|
|
1461
|
+
});
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1302
1464
|
config.evals.forEach((evalConfig, i) => {
|
|
1303
1465
|
const server = evalConfig.mcp?.server;
|
|
1304
1466
|
if (server === void 0) {
|
|
@@ -1321,6 +1483,10 @@ var pluneConfigSchema = z.object({
|
|
|
1321
1483
|
message: `eval "${evalConfig.id}" uses MCP server "${server}", which mcp.servers does not define`
|
|
1322
1484
|
});
|
|
1323
1485
|
});
|
|
1486
|
+
}).transform(({ provider, ...rest }) => {
|
|
1487
|
+
if (!Array.isArray(provider)) return { provider, ...rest };
|
|
1488
|
+
const [first, ...others] = provider;
|
|
1489
|
+
return others.length === 0 ? { provider: first, ...rest } : { provider: first, providers: provider, ...rest };
|
|
1324
1490
|
});
|
|
1325
1491
|
|
|
1326
1492
|
// src/config/loader.ts
|
|
@@ -1358,6 +1524,16 @@ async function loadConfig(opts = {}) {
|
|
|
1358
1524
|
return applyEnvOverrides(config, env);
|
|
1359
1525
|
}
|
|
1360
1526
|
|
|
1527
|
+
// src/config/model-matrix.ts
|
|
1528
|
+
init_esm_shims();
|
|
1529
|
+
function selfJudgeWarnings(config) {
|
|
1530
|
+
if ((config.providers?.length ?? 0) < 2) return [];
|
|
1531
|
+
const inherited = (config.defaults?.assertions ?? []).some((a) => a.type === "llm-judge" && a.provider === void 0);
|
|
1532
|
+
return config.evals.filter((ev) => inherited || ev.assertions.some((a) => a.type === "llm-judge" && a.provider === void 0)).map(
|
|
1533
|
+
(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`
|
|
1534
|
+
);
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1361
1537
|
// src/providers/index.ts
|
|
1362
1538
|
init_esm_shims();
|
|
1363
1539
|
|
|
@@ -1575,6 +1751,41 @@ var STOP = {
|
|
|
1575
1751
|
end_turn: "stop",
|
|
1576
1752
|
max_tokens: "length"
|
|
1577
1753
|
};
|
|
1754
|
+
var TAKES_TEMPERATURE = [
|
|
1755
|
+
"claude-opus-4-6",
|
|
1756
|
+
"claude-sonnet-4-6",
|
|
1757
|
+
"claude-opus-4-5",
|
|
1758
|
+
"claude-sonnet-4-5",
|
|
1759
|
+
"claude-haiku-4-5",
|
|
1760
|
+
"claude-opus-4-1",
|
|
1761
|
+
"claude-opus-4-0",
|
|
1762
|
+
"claude-sonnet-4-0",
|
|
1763
|
+
"claude-opus-4-2025",
|
|
1764
|
+
"claude-sonnet-4-2025",
|
|
1765
|
+
"claude-3"
|
|
1766
|
+
];
|
|
1767
|
+
var warnedNoTemperature = /* @__PURE__ */ new Set();
|
|
1768
|
+
function temperatureFor(model, temperature) {
|
|
1769
|
+
if (temperature === void 0) return {};
|
|
1770
|
+
if (TAKES_TEMPERATURE.some((prefix) => model.startsWith(prefix))) return { temperature };
|
|
1771
|
+
if (!warnedNoTemperature.has(model)) {
|
|
1772
|
+
warnedNoTemperature.add(model);
|
|
1773
|
+
process.stderr.write(
|
|
1774
|
+
`warning: ${model} does not take a temperature; the configured temperature ${temperature} is not sent
|
|
1775
|
+
`
|
|
1776
|
+
);
|
|
1777
|
+
}
|
|
1778
|
+
return {};
|
|
1779
|
+
}
|
|
1780
|
+
var warnedNoReasoningEffort = /* @__PURE__ */ new Set();
|
|
1781
|
+
function warnReasoningEffortNotSent(model, effort) {
|
|
1782
|
+
if (effort === void 0 || warnedNoReasoningEffort.has(model)) return;
|
|
1783
|
+
warnedNoReasoningEffort.add(model);
|
|
1784
|
+
process.stderr.write(
|
|
1785
|
+
`warning: ${model} does not take reasoning_effort; the configured value ${effort} is not sent
|
|
1786
|
+
`
|
|
1787
|
+
);
|
|
1788
|
+
}
|
|
1578
1789
|
var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1579
1790
|
function toAnthropicMessages(messages) {
|
|
1580
1791
|
return messages.map((m) => {
|
|
@@ -1617,6 +1828,7 @@ function makeAnthropicProvider(config, env, pricing) {
|
|
|
1617
1828
|
...config.timeout !== void 0 ? { timeout: config.timeout } : {}
|
|
1618
1829
|
});
|
|
1619
1830
|
const maxRetries = config.max_retries ?? DEFAULT_MAX_RETRIES;
|
|
1831
|
+
warnReasoningEffortNotSent(config.model, config.reasoning_effort);
|
|
1620
1832
|
return {
|
|
1621
1833
|
async complete(req) {
|
|
1622
1834
|
try {
|
|
@@ -1624,7 +1836,7 @@ function makeAnthropicProvider(config, env, pricing) {
|
|
|
1624
1836
|
() => client.messages.create({
|
|
1625
1837
|
model: req.model,
|
|
1626
1838
|
max_tokens: req.max_tokens,
|
|
1627
|
-
...req.
|
|
1839
|
+
...temperatureFor(req.model, req.temperature),
|
|
1628
1840
|
messages: [{ role: "user", content: req.prompt_resolved }]
|
|
1629
1841
|
}),
|
|
1630
1842
|
{ max_retries: maxRetries }
|
|
@@ -1648,7 +1860,7 @@ function makeAnthropicProvider(config, env, pricing) {
|
|
|
1648
1860
|
() => client.messages.create({
|
|
1649
1861
|
model: req.model,
|
|
1650
1862
|
max_tokens: req.max_tokens,
|
|
1651
|
-
...req.
|
|
1863
|
+
...temperatureFor(req.model, req.temperature),
|
|
1652
1864
|
messages: toAnthropicMessages(req.messages),
|
|
1653
1865
|
tools: req.tools.map((t) => ({
|
|
1654
1866
|
name: t.name,
|
|
@@ -1713,7 +1925,8 @@ function parseToolArguments(id, name, raw) {
|
|
|
1713
1925
|
}
|
|
1714
1926
|
var DEFAULT_MAX_RETRIES2 = 2;
|
|
1715
1927
|
function makeOpenAiCompatibleProvider(opts) {
|
|
1716
|
-
const { config, env, pricing, apiKeyEnv, baseURL, reportsCost } = opts;
|
|
1928
|
+
const { config, env, pricing, apiKeyEnv, baseURL, reportsCost, maxCompletionTokens, sendsReasoningEffort } = opts;
|
|
1929
|
+
const reasoning = sendsReasoningEffort && config.reasoning_effort !== void 0 ? { reasoning_effort: config.reasoning_effort } : {};
|
|
1717
1930
|
const apiKey = env[apiKeyEnv];
|
|
1718
1931
|
if (apiKey === void 0 || apiKey.trim() === "") {
|
|
1719
1932
|
throw new AuthError(
|
|
@@ -1736,7 +1949,8 @@ function makeOpenAiCompatibleProvider(opts) {
|
|
|
1736
1949
|
() => client.chat.completions.create({
|
|
1737
1950
|
model: req.model,
|
|
1738
1951
|
...req.temperature !== void 0 ? { temperature: req.temperature } : {},
|
|
1739
|
-
max_tokens: req.max_tokens,
|
|
1952
|
+
...maxCompletionTokens ? { max_completion_tokens: req.max_tokens } : { max_tokens: req.max_tokens },
|
|
1953
|
+
...reasoning,
|
|
1740
1954
|
messages: [{ role: "user", content: req.prompt_resolved }],
|
|
1741
1955
|
// OpenRouter extension: ask it to include the call's actual cost in `usage` (ADR-PRC02).
|
|
1742
1956
|
...reportsCost ? { usage: { include: true } } : {}
|
|
@@ -1765,7 +1979,8 @@ function makeOpenAiCompatibleProvider(opts) {
|
|
|
1765
1979
|
() => client.chat.completions.create({
|
|
1766
1980
|
model: req.model,
|
|
1767
1981
|
...req.temperature !== void 0 ? { temperature: req.temperature } : {},
|
|
1768
|
-
max_tokens: req.max_tokens,
|
|
1982
|
+
...maxCompletionTokens ? { max_completion_tokens: req.max_tokens } : { max_tokens: req.max_tokens },
|
|
1983
|
+
...reasoning,
|
|
1769
1984
|
messages: toOpenAiMessages(req.messages),
|
|
1770
1985
|
tools: req.tools.map((t) => ({
|
|
1771
1986
|
type: "function",
|
|
@@ -1804,7 +2019,14 @@ function makeOpenAiCompatibleProvider(opts) {
|
|
|
1804
2019
|
};
|
|
1805
2020
|
}
|
|
1806
2021
|
function makeOpenAiProvider(config, env, pricing) {
|
|
1807
|
-
return makeOpenAiCompatibleProvider({
|
|
2022
|
+
return makeOpenAiCompatibleProvider({
|
|
2023
|
+
config,
|
|
2024
|
+
env,
|
|
2025
|
+
pricing,
|
|
2026
|
+
apiKeyEnv: "OPENAI_API_KEY",
|
|
2027
|
+
maxCompletionTokens: true,
|
|
2028
|
+
sendsReasoningEffort: true
|
|
2029
|
+
});
|
|
1808
2030
|
}
|
|
1809
2031
|
|
|
1810
2032
|
// src/providers/openrouter.ts
|
|
@@ -2271,6 +2493,14 @@ init_esm_shims();
|
|
|
2271
2493
|
// src/assertions/interpolate.ts
|
|
2272
2494
|
init_esm_shims();
|
|
2273
2495
|
var PLACEHOLDER = /\{\{\s*([\w.]+)\s*\}\}/g;
|
|
2496
|
+
var EXPECTED = /\{\{\s*expected\s*\}\}/;
|
|
2497
|
+
function usesExpected(params) {
|
|
2498
|
+
if (typeof params === "string") return EXPECTED.test(params);
|
|
2499
|
+
if (Array.isArray(params)) return params.some(usesExpected);
|
|
2500
|
+
if (params !== null && typeof params === "object")
|
|
2501
|
+
return Object.values(params).some(usesExpected);
|
|
2502
|
+
return false;
|
|
2503
|
+
}
|
|
2274
2504
|
function interpolate(template, ctx) {
|
|
2275
2505
|
return template.replace(PLACEHOLDER, (match, key) => {
|
|
2276
2506
|
if (key === "expected") {
|
|
@@ -2614,14 +2844,15 @@ function checkNames(type, t, names) {
|
|
|
2614
2844
|
const offered = t.tools.filter((x) => x.offered).map((x) => x.name);
|
|
2615
2845
|
const unknown = names.find((n) => n !== void 0 && !offered.includes(n));
|
|
2616
2846
|
if (unknown === void 0) return;
|
|
2617
|
-
const
|
|
2847
|
+
const list2 = offered.length > 0 ? offered.join(", ") : "(none)";
|
|
2618
2848
|
throw new AssertionRunError(
|
|
2619
2849
|
"ASSERTION_UNKNOWN_TOOL",
|
|
2620
|
-
`${type}: no tool "${unknown}" was offered to the model; offered: ${
|
|
2850
|
+
`${type}: no tool "${unknown}" was offered to the model; offered: ${list2}.${AFTER}`
|
|
2621
2851
|
);
|
|
2622
2852
|
}
|
|
2623
|
-
function absence(type, t, what) {
|
|
2624
|
-
if (t.collection === "complete"
|
|
2853
|
+
function absence(type, t, what, reads) {
|
|
2854
|
+
if (t.collection === "complete" || reads === "calls" && t.stop.reason === "complete")
|
|
2855
|
+
return pass;
|
|
2625
2856
|
const why = t.stop.reason === "limit" ? `the loop was stopped by ${t.stop.limit ?? "a limit"}` : "the transcript is partial (a stored excerpt was cut)";
|
|
2626
2857
|
throw unmeasured(
|
|
2627
2858
|
type,
|
|
@@ -2663,7 +2894,7 @@ var toolNotCalled = check((ctx) => {
|
|
|
2663
2894
|
const t = transcriptOf("tool-not-called", ctx);
|
|
2664
2895
|
checkNames("tool-not-called", t, [tool]);
|
|
2665
2896
|
const calls = callsFor(t, tool);
|
|
2666
|
-
if (calls.length === 0) return absence("tool-not-called", t, `a call to "${tool}"
|
|
2897
|
+
if (calls.length === 0) return absence("tool-not-called", t, `a call to "${tool}"`, "calls");
|
|
2667
2898
|
return fail(
|
|
2668
2899
|
`expected "${tool}" never called; got ${plural(calls.length, "call")}: ${describeCalls(calls)}; check what in the prompt or the tool list led the model to it`
|
|
2669
2900
|
);
|
|
@@ -2686,13 +2917,15 @@ var toolArgs = check((ctx) => {
|
|
|
2686
2917
|
const { tool, match = "partial", min_count: min = 1 } = ctx.params;
|
|
2687
2918
|
const t = transcriptOf("tool-args", ctx);
|
|
2688
2919
|
checkNames("tool-args", t, [tool]);
|
|
2689
|
-
const
|
|
2690
|
-
|
|
2920
|
+
const sets = (Array.isArray(ctx.params.args) ? ctx.params.args : [ctx.params.args]).map(
|
|
2921
|
+
(a) => interpolateDeep(a, ctx)
|
|
2922
|
+
);
|
|
2923
|
+
const matches = (actual) => match === "ignore" || sets.some((args) => match === "exact" ? sameJson(args, actual) : partialMatch(args, actual));
|
|
2691
2924
|
const calls = callsFor(t, tool);
|
|
2692
2925
|
const hits = calls.filter((c) => matches(c.call.args)).length;
|
|
2693
2926
|
if (hits >= min) return pass;
|
|
2694
2927
|
return fail(
|
|
2695
|
-
`expected a call to "${tool}" with arguments ${describeArgs(
|
|
2928
|
+
`expected a call to "${tool}" with arguments ${sets.map(describeArgs).join(" or ")} (${match}) at least ${plural(min, "time")}; got ${hits} of ${plural(calls.length, "call")}: ${describeCalls(calls)}; check the argument names and values against the tool's input schema`
|
|
2696
2929
|
);
|
|
2697
2930
|
});
|
|
2698
2931
|
var onlyTools = check((ctx) => {
|
|
@@ -2700,7 +2933,7 @@ var onlyTools = check((ctx) => {
|
|
|
2700
2933
|
const t = transcriptOf("only-tools", ctx);
|
|
2701
2934
|
checkNames("only-tools", t, tools);
|
|
2702
2935
|
const off = callsOf(t).filter((c) => !tools.includes(c.call.name));
|
|
2703
|
-
if (off.length === 0) return absence("only-tools", t, "a call to another tool");
|
|
2936
|
+
if (off.length === 0) return absence("only-tools", t, "a call to another tool", "calls");
|
|
2704
2937
|
const allowed = tools.length > 0 ? `only ${tools.join(", ")} called` : "no tool call";
|
|
2705
2938
|
return fail(
|
|
2706
2939
|
`expected ${allowed}; got ${describeCalls(off)}; check whether allowed_tools should leave the others out`
|
|
@@ -2709,6 +2942,38 @@ var onlyTools = check((ctx) => {
|
|
|
2709
2942
|
|
|
2710
2943
|
// src/assertions/tool-calls/order.ts
|
|
2711
2944
|
init_esm_shims();
|
|
2945
|
+
|
|
2946
|
+
// src/util/tool-calls.ts
|
|
2947
|
+
init_esm_shims();
|
|
2948
|
+
var PAGINATION_KEYS = [
|
|
2949
|
+
"cursor",
|
|
2950
|
+
"page",
|
|
2951
|
+
"offset",
|
|
2952
|
+
"limit",
|
|
2953
|
+
"after",
|
|
2954
|
+
"before",
|
|
2955
|
+
"start",
|
|
2956
|
+
"pageToken",
|
|
2957
|
+
"page_token",
|
|
2958
|
+
"nextCursor",
|
|
2959
|
+
"next_cursor"
|
|
2960
|
+
];
|
|
2961
|
+
var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2962
|
+
function sameValue(a, b) {
|
|
2963
|
+
return a !== void 0 && b !== void 0 && canonicalJson(a) === canonicalJson(b);
|
|
2964
|
+
}
|
|
2965
|
+
function withoutPagination(args) {
|
|
2966
|
+
if (!isRecord2(args)) return args;
|
|
2967
|
+
return Object.fromEntries(Object.entries(args).filter(([k]) => !PAGINATION_KEYS.includes(k)));
|
|
2968
|
+
}
|
|
2969
|
+
function isIdenticalCall(a, b) {
|
|
2970
|
+
return a.name === b.name && sameValue(a.args, b.args);
|
|
2971
|
+
}
|
|
2972
|
+
function isPageTurn(a, b) {
|
|
2973
|
+
return a.name === b.name && !isIdenticalCall(a, b) && sameValue(withoutPagination(a.args), withoutPagination(b.args));
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
// src/assertions/tool-calls/order.ts
|
|
2712
2977
|
function inOrder(names, tools) {
|
|
2713
2978
|
let next = 0;
|
|
2714
2979
|
for (const n of names) if (n === tools[next]) next++;
|
|
@@ -2746,7 +3011,7 @@ var noRepeatedCall = check((ctx) => {
|
|
|
2746
3011
|
for (let i = 1; i < calls.length; i++) {
|
|
2747
3012
|
const [prev, cur] = [calls[i - 1], calls[i]];
|
|
2748
3013
|
if (tool !== void 0 && cur.call.name !== tool) continue;
|
|
2749
|
-
if (
|
|
3014
|
+
if (isIdenticalCall(prev.call, cur.call))
|
|
2750
3015
|
return fail(
|
|
2751
3016
|
`expected no call repeated right after itself; got ${describeCall(prev)} then ${describeCall(cur)}; check whether the first answer told the model what it needed`
|
|
2752
3017
|
);
|
|
@@ -2769,7 +3034,7 @@ var noToolErrors = check((ctx) => {
|
|
|
2769
3034
|
const t = transcriptOf("no-tool-errors", ctx);
|
|
2770
3035
|
checkNames("no-tool-errors", t, [tool]);
|
|
2771
3036
|
const errors = callsFor(t, tool).filter((c) => c.call.is_error);
|
|
2772
|
-
if (errors.length === 0) return absence("no-tool-errors", t, "a call with an error");
|
|
3037
|
+
if (errors.length === 0) return absence("no-tool-errors", t, "a call with an error", "calls");
|
|
2773
3038
|
return fail(
|
|
2774
3039
|
`expected no tool call with an error; got ${describeCalls(errors, (c) => `${describeCall(c)} (${c.call.error_kind ?? "error"})`)}; check the arguments the model sent against the tool's input schema`
|
|
2775
3040
|
);
|
|
@@ -2793,7 +3058,8 @@ var noDestructiveTool = check((ctx) => {
|
|
|
2793
3058
|
const why = riskOf(c.call.name, listed.get(c.call.name));
|
|
2794
3059
|
if (why !== void 0) risky.push({ c, why });
|
|
2795
3060
|
}
|
|
2796
|
-
if (risky.length === 0)
|
|
3061
|
+
if (risky.length === 0)
|
|
3062
|
+
return absence("no-destructive-tool", t, "a call to a destructive tool", "calls");
|
|
2797
3063
|
return fail(
|
|
2798
3064
|
`expected no call to a tool that may be destructive; got ${failedOn(risky)}; the hints are the server's own claim, so check them on the server`
|
|
2799
3065
|
);
|
|
@@ -3125,6 +3391,159 @@ function wireNames(names) {
|
|
|
3125
3391
|
return { toWire, toServer };
|
|
3126
3392
|
}
|
|
3127
3393
|
|
|
3394
|
+
// src/orchestrator/friction.ts
|
|
3395
|
+
init_esm_shims();
|
|
3396
|
+
var SCAN_DEPTH = 6;
|
|
3397
|
+
var SCAN_ITEMS = 50;
|
|
3398
|
+
var MAX_PATHS = 10;
|
|
3399
|
+
var MAX_PATH = 120;
|
|
3400
|
+
var MIN_VALUE = 6;
|
|
3401
|
+
var WORDS = "id|ids|key|uuid|slug|number|ref|identifier";
|
|
3402
|
+
var WHOLE = new RegExp(`^(?:${WORDS})$`, "i");
|
|
3403
|
+
var SNAKE = new RegExp(`_(?:${WORDS})$`, "i");
|
|
3404
|
+
var CAMEL = /[a-z0-9](?:Id|Ids|Uuid|Key|Slug|Number|Ref|Identifier)$/;
|
|
3405
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
3406
|
+
var isIdKey = (key) => WHOLE.test(key) || SNAKE.test(key) || CAMEL.test(key);
|
|
3407
|
+
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3408
|
+
var isScalar = (v) => typeof v === "string" && v !== "" || typeof v === "number" && Number.isFinite(v);
|
|
3409
|
+
var EMAIL = /@/;
|
|
3410
|
+
function segment(key) {
|
|
3411
|
+
const plain = /^[A-Za-z_][\w-]*$/.test(key) && key.length <= 40 && !UUID.test(key) && !EMAIL.test(key);
|
|
3412
|
+
return plain ? key : "*";
|
|
3413
|
+
}
|
|
3414
|
+
var cap = (path10) => path10.length > MAX_PATH ? path10.slice(0, MAX_PATH) : path10;
|
|
3415
|
+
var hashOf = (v) => sha256(v).slice(0, 16);
|
|
3416
|
+
function noteValue(out, v, at) {
|
|
3417
|
+
if (typeof v !== "string" || v.length < MIN_VALUE) return;
|
|
3418
|
+
const h = hashOf(v);
|
|
3419
|
+
const where = out.values.get(h) ?? /* @__PURE__ */ new Set();
|
|
3420
|
+
where.add(at);
|
|
3421
|
+
out.values.set(h, where);
|
|
3422
|
+
}
|
|
3423
|
+
function walk(value, path10, depth, out) {
|
|
3424
|
+
if (depth > SCAN_DEPTH) return;
|
|
3425
|
+
if (typeof value === "string" && UUID.test(value)) {
|
|
3426
|
+
const at = cap(path10 === "" ? "(root)" : path10);
|
|
3427
|
+
out.paths.add(at);
|
|
3428
|
+
noteValue(out, value, at);
|
|
3429
|
+
}
|
|
3430
|
+
if (Array.isArray(value)) {
|
|
3431
|
+
for (const item of value.slice(0, SCAN_ITEMS)) walk(item, `${path10}[]`, depth + 1, out);
|
|
3432
|
+
return;
|
|
3433
|
+
}
|
|
3434
|
+
if (!isRecord3(value)) return;
|
|
3435
|
+
for (const [key, v] of Object.entries(value)) {
|
|
3436
|
+
const at = cap(path10 === "" ? segment(key) : `${path10}.${segment(key)}`);
|
|
3437
|
+
if (isIdKey(key) && (isScalar(v) || Array.isArray(v) && v.length > 0 && v.every(isScalar))) {
|
|
3438
|
+
out.paths.add(at);
|
|
3439
|
+
for (const x of Array.isArray(v) ? v : [v]) noteValue(out, x, at);
|
|
3440
|
+
}
|
|
3441
|
+
walk(v, at, depth + 1, out);
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
function scanIds(result) {
|
|
3445
|
+
const found = { paths: /* @__PURE__ */ new Set(), values: /* @__PURE__ */ new Map() };
|
|
3446
|
+
let readable = false;
|
|
3447
|
+
if (isRecord3(result)) {
|
|
3448
|
+
if (result.structuredContent !== void 0) {
|
|
3449
|
+
readable = true;
|
|
3450
|
+
walk(result.structuredContent, "", 0, found);
|
|
3451
|
+
}
|
|
3452
|
+
if (Array.isArray(result.content))
|
|
3453
|
+
for (const block of result.content) {
|
|
3454
|
+
if (!isRecord3(block) || block.type !== "text" || typeof block.text !== "string") continue;
|
|
3455
|
+
try {
|
|
3456
|
+
walk(JSON.parse(block.text), "", 0, found);
|
|
3457
|
+
readable = true;
|
|
3458
|
+
} catch {
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
if (!readable) return { unreadable: "the answer is not JSON" };
|
|
3463
|
+
return {
|
|
3464
|
+
paths: [...found.paths].sort().slice(0, MAX_PATHS),
|
|
3465
|
+
values: [...found.values].map(([hash, at]) => ({ hash, paths: [...at].sort() }))
|
|
3466
|
+
};
|
|
3467
|
+
}
|
|
3468
|
+
var list = (steps) => steps.join(", ");
|
|
3469
|
+
function frictionAdvice(calls) {
|
|
3470
|
+
const acc = /* @__PURE__ */ new Map();
|
|
3471
|
+
const add = (type, tool, steps, paths = [], note) => {
|
|
3472
|
+
const key = `${type}\0${tool}`;
|
|
3473
|
+
let a = acc.get(key);
|
|
3474
|
+
if (a === void 0) {
|
|
3475
|
+
a = { type, tool, steps: /* @__PURE__ */ new Set(), count: 0, paths: /* @__PURE__ */ new Set(), note };
|
|
3476
|
+
acc.set(key, a);
|
|
3477
|
+
}
|
|
3478
|
+
steps.forEach((s) => a.steps.add(s));
|
|
3479
|
+
paths.forEach((p) => a.paths.add(p));
|
|
3480
|
+
a.count++;
|
|
3481
|
+
};
|
|
3482
|
+
const sent = calls.filter((c) => c.executed);
|
|
3483
|
+
for (let j = 1; j < sent.length; j++) {
|
|
3484
|
+
const [prev, cur] = [sent[j - 1], sent[j]];
|
|
3485
|
+
if (isIdenticalCall(prev, cur)) add("identical-retry", cur.name, [prev.step, cur.step]);
|
|
3486
|
+
else if (isPageTurn(prev, cur)) add("pagination-continuation", cur.name, [prev.step, cur.step]);
|
|
3487
|
+
}
|
|
3488
|
+
for (const [j, cur] of sent.entries()) {
|
|
3489
|
+
if (cur.is_error) continue;
|
|
3490
|
+
const before = sent.slice(0, j).filter(
|
|
3491
|
+
(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.
|
|
3492
|
+
!isIdenticalCall(e, cur) && !isPageTurn(e, cur)
|
|
3493
|
+
);
|
|
3494
|
+
if (before.length === 0) continue;
|
|
3495
|
+
const scans = [cur, ...before].map((c) => c.ids);
|
|
3496
|
+
const unread = scans.some((x) => x === void 0 || "unreadable" in x);
|
|
3497
|
+
if (unread || cur.ids === void 0 || "unreadable" in cur.ids) {
|
|
3498
|
+
const named = scans.find((x) => x !== void 0 && "unreadable" in x);
|
|
3499
|
+
const why = named !== void 0 && "unreadable" in named ? named.unreadable : "no answer was kept";
|
|
3500
|
+
add("friction-unmeasured", cur.name, [...before.map((e) => e.step), cur.step], [], why);
|
|
3501
|
+
continue;
|
|
3502
|
+
}
|
|
3503
|
+
const mine = new Map(cur.ids.values.map((v) => [v.hash, v.paths]));
|
|
3504
|
+
const shared = before.filter((e) => {
|
|
3505
|
+
const ids = e.ids;
|
|
3506
|
+
return ids.values.some((v) => mine.has(v.hash));
|
|
3507
|
+
});
|
|
3508
|
+
if (shared.length === 0) continue;
|
|
3509
|
+
const seen = new Set(
|
|
3510
|
+
shared.flatMap((e) => e.ids.values.map((v) => v.hash))
|
|
3511
|
+
);
|
|
3512
|
+
const paths = [...mine].filter(([h]) => seen.has(h)).flatMap(([, p]) => p);
|
|
3513
|
+
add("search-after-id", cur.name, [...shared.map((e) => e.step), cur.step], paths);
|
|
3514
|
+
}
|
|
3515
|
+
return [...acc.values()].map((a) => {
|
|
3516
|
+
const steps = [...a.steps].sort((x, y) => x - y);
|
|
3517
|
+
const paths = [...a.paths].sort();
|
|
3518
|
+
const base = {
|
|
3519
|
+
type: a.type,
|
|
3520
|
+
tool: a.tool,
|
|
3521
|
+
steps,
|
|
3522
|
+
count: a.count,
|
|
3523
|
+
...paths.length > 0 ? { paths } : {}
|
|
3524
|
+
};
|
|
3525
|
+
if (a.type === "identical-retry")
|
|
3526
|
+
return {
|
|
3527
|
+
...base,
|
|
3528
|
+
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`
|
|
3529
|
+
};
|
|
3530
|
+
if (a.type === "pagination-continuation")
|
|
3531
|
+
return {
|
|
3532
|
+
...base,
|
|
3533
|
+
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`
|
|
3534
|
+
};
|
|
3535
|
+
if (a.type === "search-after-id")
|
|
3536
|
+
return {
|
|
3537
|
+
...base,
|
|
3538
|
+
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`
|
|
3539
|
+
};
|
|
3540
|
+
return {
|
|
3541
|
+
...base,
|
|
3542
|
+
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`
|
|
3543
|
+
};
|
|
3544
|
+
});
|
|
3545
|
+
}
|
|
3546
|
+
|
|
3128
3547
|
// src/orchestrator/agent.ts
|
|
3129
3548
|
var EXCERPT_BYTES = 4 * 1024;
|
|
3130
3549
|
var TRANSCRIPT_BYTES = 256 * 1024;
|
|
@@ -3143,14 +3562,14 @@ var AgentError = class extends Error {
|
|
|
3143
3562
|
}
|
|
3144
3563
|
code;
|
|
3145
3564
|
};
|
|
3146
|
-
var
|
|
3565
|
+
var isRecord4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3147
3566
|
function resultText(result) {
|
|
3148
|
-
if (!
|
|
3567
|
+
if (!isRecord4(result)) return JSON.stringify(result) ?? "";
|
|
3149
3568
|
const content = Array.isArray(result.content) ? result.content : [];
|
|
3150
3569
|
if (content.length === 0 && result.structuredContent !== void 0)
|
|
3151
3570
|
return JSON.stringify(result.structuredContent);
|
|
3152
3571
|
return content.map(
|
|
3153
|
-
(b) =>
|
|
3572
|
+
(b) => isRecord4(b) && b.type === "text" && typeof b.text === "string" ? b.text : JSON.stringify(b)
|
|
3154
3573
|
).join("\n");
|
|
3155
3574
|
}
|
|
3156
3575
|
function excerpts() {
|
|
@@ -3172,7 +3591,7 @@ function excerpts() {
|
|
|
3172
3591
|
function listedTools(items) {
|
|
3173
3592
|
const seen = /* @__PURE__ */ new Set();
|
|
3174
3593
|
return items.filter((t) => {
|
|
3175
|
-
if (!
|
|
3594
|
+
if (!isRecord4(t) || typeof t.name !== "string" || t.name === "" || seen.has(t.name))
|
|
3176
3595
|
return false;
|
|
3177
3596
|
seen.add(t.name);
|
|
3178
3597
|
return true;
|
|
@@ -3190,13 +3609,7 @@ async function runAgentRow(p) {
|
|
|
3190
3609
|
input_tokens: one.input_tokens * limits.max_steps,
|
|
3191
3610
|
output_tokens: one.output_tokens * limits.max_steps
|
|
3192
3611
|
};
|
|
3193
|
-
return {
|
|
3194
|
-
vars: p.row.vars,
|
|
3195
|
-
output: null,
|
|
3196
|
-
cached: false,
|
|
3197
|
-
usage: { ...est, ...costFields(p.provider.estimateCost(est)) },
|
|
3198
|
-
assertions: []
|
|
3199
|
-
};
|
|
3612
|
+
return dryRunRow(p.row.vars, { ...est, ...costFields(p.provider.estimateCost(est)) });
|
|
3200
3613
|
}
|
|
3201
3614
|
const respond = p.provider.respond.bind(p.provider);
|
|
3202
3615
|
const deadline = t0 + limits.timeout_ms;
|
|
@@ -3222,6 +3635,9 @@ async function runAgentRow(p) {
|
|
|
3222
3635
|
let output = "";
|
|
3223
3636
|
let error;
|
|
3224
3637
|
let session;
|
|
3638
|
+
const scanned = /* @__PURE__ */ new Map();
|
|
3639
|
+
const overrides = p.toolDescriptions ?? {};
|
|
3640
|
+
const replaced = /* @__PURE__ */ new Set();
|
|
3225
3641
|
try {
|
|
3226
3642
|
const opening = p.connect(p.server, limits.timeout_ms);
|
|
3227
3643
|
try {
|
|
@@ -3235,30 +3651,54 @@ async function runAgentRow(p) {
|
|
|
3235
3651
|
if (err instanceof LimitStop) throw err;
|
|
3236
3652
|
throw new AgentError("MCP_CONNECT", err.message);
|
|
3237
3653
|
}
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
offered
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3654
|
+
const open2 = session;
|
|
3655
|
+
let names = wireNames([]);
|
|
3656
|
+
let tools = [];
|
|
3657
|
+
let offeredNames = [];
|
|
3658
|
+
const list2 = async () => {
|
|
3659
|
+
let listed;
|
|
3660
|
+
try {
|
|
3661
|
+
listed = listedTools(await bounded(open2.listTools(limits.tool_timeout_ms)));
|
|
3662
|
+
} catch (err) {
|
|
3663
|
+
if (err instanceof LimitStop) throw err;
|
|
3664
|
+
throw new AgentError("MCP_LIST_TOOLS", `tools/list failed: ${err.message}`);
|
|
3665
|
+
}
|
|
3666
|
+
const offered = listed.filter(
|
|
3667
|
+
(t) => p.allowedTools === void 0 || p.allowedTools.includes(t.name)
|
|
3668
|
+
);
|
|
3669
|
+
for (const t of listed) {
|
|
3670
|
+
const isOffered = offered.includes(t);
|
|
3671
|
+
const known = transcript.tools.find((k) => k.name === t.name);
|
|
3672
|
+
if (known !== void 0) known.offered ||= isOffered;
|
|
3673
|
+
else
|
|
3674
|
+
transcript.tools.push({
|
|
3675
|
+
name: t.name,
|
|
3676
|
+
offered: isOffered,
|
|
3677
|
+
...isRecord4(t.annotations) ? { annotations: t.annotations } : {}
|
|
3678
|
+
});
|
|
3679
|
+
}
|
|
3680
|
+
const now = offered.map((t) => t.name);
|
|
3681
|
+
const added = now.filter((n) => !offeredNames.includes(n));
|
|
3682
|
+
const removed = offeredNames.filter((n) => !now.includes(n));
|
|
3683
|
+
offeredNames = now;
|
|
3684
|
+
names = wireNames(now);
|
|
3685
|
+
tools = offered.map((t) => {
|
|
3686
|
+
const swap = overrides[t.name];
|
|
3687
|
+
if (swap !== void 0) replaced.add(t.name);
|
|
3688
|
+
const description = swap ?? (typeof t.description === "string" ? t.description : void 0);
|
|
3689
|
+
return {
|
|
3690
|
+
name: names.toWire.get(t.name),
|
|
3691
|
+
...description !== void 0 ? { description } : {},
|
|
3692
|
+
input_schema: isRecord4(t.inputSchema) ? t.inputSchema : { type: "object" }
|
|
3693
|
+
};
|
|
3694
|
+
});
|
|
3695
|
+
return added.length + removed.length > 0 ? { added, removed } : void 0;
|
|
3696
|
+
};
|
|
3697
|
+
await list2();
|
|
3259
3698
|
const messages = [{ role: "user", content: prompt5 }];
|
|
3260
3699
|
let calls = 0;
|
|
3261
3700
|
let tokens = 0;
|
|
3701
|
+
let changed;
|
|
3262
3702
|
for (let index = 1; ; index++) {
|
|
3263
3703
|
const res = await bounded(
|
|
3264
3704
|
respond({
|
|
@@ -3289,8 +3729,10 @@ async function runAgentRow(p) {
|
|
|
3289
3729
|
text: kept.cut(res.text).text,
|
|
3290
3730
|
...res.finish_reason !== void 0 ? { finish_reason: res.finish_reason } : {},
|
|
3291
3731
|
usage: usage2,
|
|
3292
|
-
calls: records2
|
|
3732
|
+
calls: records2,
|
|
3733
|
+
...changed !== void 0 ? { offered_changed: changed } : {}
|
|
3293
3734
|
};
|
|
3735
|
+
changed = void 0;
|
|
3294
3736
|
transcript.steps.push(step);
|
|
3295
3737
|
if (res.finish_reason === "error")
|
|
3296
3738
|
throw new AgentError(
|
|
@@ -3307,6 +3749,7 @@ async function runAgentRow(p) {
|
|
|
3307
3749
|
if (tokens > limits.max_total_tokens) throw new LimitStop("max_total_tokens");
|
|
3308
3750
|
const results = [];
|
|
3309
3751
|
const answer = (rec, c, content) => results.push({ id: c.id, content, is_error: rec.is_error });
|
|
3752
|
+
let succeeded = false;
|
|
3310
3753
|
for (const [i, c] of res.tool_calls.entries()) {
|
|
3311
3754
|
const rec = records2[i];
|
|
3312
3755
|
if (calls >= limits.max_tool_calls) throw new LimitStop("max_tool_calls");
|
|
@@ -3317,7 +3760,7 @@ async function runAgentRow(p) {
|
|
|
3317
3760
|
answer(rec, c, `Tool "${c.name}" is not available.`);
|
|
3318
3761
|
continue;
|
|
3319
3762
|
}
|
|
3320
|
-
if (c.args_invalid === true || !
|
|
3763
|
+
if (c.args_invalid === true || !isRecord4(c.args)) {
|
|
3321
3764
|
Object.assign(rec, { is_error: true, error_kind: "bad-arguments" });
|
|
3322
3765
|
answer(rec, c, "The arguments are not a JSON object.");
|
|
3323
3766
|
continue;
|
|
@@ -3333,8 +3776,10 @@ async function runAgentRow(p) {
|
|
|
3333
3776
|
if (got.kind === "lost") throw new AgentError("MCP_SERVER_LOST", got.message);
|
|
3334
3777
|
const text = got.kind === "error" ? got.message : resultText(got.result);
|
|
3335
3778
|
if (got.kind === "error") Object.assign(rec, { is_error: true, error_kind: "protocol" });
|
|
3336
|
-
else if (
|
|
3779
|
+
else if (isRecord4(got.result) && got.result.isError === true)
|
|
3337
3780
|
Object.assign(rec, { is_error: true, error_kind: "content" });
|
|
3781
|
+
succeeded ||= !rec.is_error;
|
|
3782
|
+
if (got.kind === "result" && !rec.is_error) scanned.set(rec, scanIds(got.result));
|
|
3338
3783
|
rec.result = kept.cut(text);
|
|
3339
3784
|
answer(rec, c, text);
|
|
3340
3785
|
}
|
|
@@ -3342,6 +3787,7 @@ async function runAgentRow(p) {
|
|
|
3342
3787
|
{ role: "assistant", text: res.text, tool_calls: res.tool_calls },
|
|
3343
3788
|
{ role: "tool", results }
|
|
3344
3789
|
);
|
|
3790
|
+
if (succeeded) changed = await list2();
|
|
3345
3791
|
}
|
|
3346
3792
|
} catch (err) {
|
|
3347
3793
|
if (err instanceof LimitStop) transcript.stop = { reason: "limit", limit: err.limit };
|
|
@@ -3354,8 +3800,27 @@ async function runAgentRow(p) {
|
|
|
3354
3800
|
});
|
|
3355
3801
|
}
|
|
3356
3802
|
if (transcript.stop.reason !== "complete" || kept.any) transcript.collection = "partial";
|
|
3803
|
+
const friction = error === void 0 ? frictionAdvice(
|
|
3804
|
+
transcript.steps.flatMap(
|
|
3805
|
+
(s) => s.calls.map(
|
|
3806
|
+
(c) => ({
|
|
3807
|
+
step: s.index,
|
|
3808
|
+
name: c.name,
|
|
3809
|
+
args: c.args,
|
|
3810
|
+
executed: c.executed,
|
|
3811
|
+
is_error: c.is_error,
|
|
3812
|
+
...scanned.has(c) ? { ids: scanned.get(c) } : {}
|
|
3813
|
+
})
|
|
3814
|
+
)
|
|
3815
|
+
)
|
|
3816
|
+
) : [];
|
|
3357
3817
|
const mask = session?.redact;
|
|
3358
3818
|
const agent = mask?.value(transcript) ?? transcript;
|
|
3819
|
+
if (replaced.size > 0)
|
|
3820
|
+
agent.description_overrides = [...replaced].sort().map((tool) => ({
|
|
3821
|
+
tool,
|
|
3822
|
+
sha256: sha256(overrides[tool])
|
|
3823
|
+
}));
|
|
3359
3824
|
const spent = usages.length > 0 ? { usage: sumUsage(usages) } : {};
|
|
3360
3825
|
if (error !== void 0) {
|
|
3361
3826
|
return {
|
|
@@ -3374,7 +3839,12 @@ async function runAgentRow(p) {
|
|
|
3374
3839
|
output,
|
|
3375
3840
|
agent
|
|
3376
3841
|
);
|
|
3377
|
-
|
|
3842
|
+
const covered = p.assertions.filter((x) => x.type === "no-repeated-call");
|
|
3843
|
+
const signals = (mask?.value(friction) ?? friction).filter(
|
|
3844
|
+
(f) => !(f.type === "identical-retry" && covered.some((c) => c.tool === void 0 || c.tool === f.tool))
|
|
3845
|
+
);
|
|
3846
|
+
const findings = [...advice, ...signals];
|
|
3847
|
+
if (findings.length > 0) agent.advice = findings;
|
|
3378
3848
|
const usage = sumUsage(usages);
|
|
3379
3849
|
return {
|
|
3380
3850
|
vars: p.row.vars,
|
|
@@ -3431,6 +3901,9 @@ function pricedField(priced) {
|
|
|
3431
3901
|
function costFields(c) {
|
|
3432
3902
|
return { cost_usd: c.cost_usd, ...pricedField(c.priced) };
|
|
3433
3903
|
}
|
|
3904
|
+
function dryRunRow(vars, usage) {
|
|
3905
|
+
return { vars, output: null, cached: false, usage, inconclusive: "skipped", assertions: [] };
|
|
3906
|
+
}
|
|
3434
3907
|
async function assess(p, output, transcript) {
|
|
3435
3908
|
let judgeCost = 0;
|
|
3436
3909
|
let judgeUnpriced = false;
|
|
@@ -3443,7 +3916,10 @@ async function assess(p, output, transcript) {
|
|
|
3443
3916
|
const advice = [];
|
|
3444
3917
|
let assertionError;
|
|
3445
3918
|
for (const assertion of p.assertions) {
|
|
3446
|
-
const run = () =>
|
|
3919
|
+
const run = () => usesExpected(assertion) && (p.row.expected === void 0 || p.row.expected === "") ? Promise.resolve({
|
|
3920
|
+
passed: false,
|
|
3921
|
+
reason: "the row has no expected value, and this check compares against {{expected}}"
|
|
3922
|
+
}) : getAssertion(assertion.type).run({
|
|
3447
3923
|
output,
|
|
3448
3924
|
vars: p.row.vars,
|
|
3449
3925
|
row: p.row,
|
|
@@ -3483,8 +3959,7 @@ async function runRow(p) {
|
|
|
3483
3959
|
if (p.dryRun) {
|
|
3484
3960
|
const est = estimateUsage(prompt5, maxTokens);
|
|
3485
3961
|
const cost = p.provider.estimateCost(est);
|
|
3486
|
-
|
|
3487
|
-
return { vars: p.row.vars, output: null, cached: false, usage: usage2, assertions: [] };
|
|
3962
|
+
return dryRunRow(p.row.vars, { ...est, ...costFields(cost) });
|
|
3488
3963
|
}
|
|
3489
3964
|
const key = cacheKey(
|
|
3490
3965
|
{
|
|
@@ -3707,12 +4182,11 @@ function summarize(evals, durationMs) {
|
|
|
3707
4182
|
}
|
|
3708
4183
|
return { ...summary, cache };
|
|
3709
4184
|
}
|
|
3710
|
-
function agenticProvider(
|
|
4185
|
+
function agenticProvider(ev, providerConfig, deps, cacheStrict) {
|
|
3711
4186
|
if (cacheStrict)
|
|
3712
4187
|
throw new RunConfigError(
|
|
3713
4188
|
`Eval "${ev.id}" uses MCP server "${ev.mcp.server}": its tool loop is never cached, so --cache-strict cannot answer it`
|
|
3714
4189
|
);
|
|
3715
|
-
const providerConfig = { ...config.provider, ...ev.provider };
|
|
3716
4190
|
const provider = deps.resolveProvider(providerConfig);
|
|
3717
4191
|
if (provider.respond === void 0)
|
|
3718
4192
|
throw new RunConfigError(
|
|
@@ -3739,51 +4213,77 @@ async function runOrchestration(config, options, deps) {
|
|
|
3739
4213
|
const started = deps.now();
|
|
3740
4214
|
const dryRun = options.dryRun ?? false;
|
|
3741
4215
|
const evalResults = [];
|
|
4216
|
+
const models = config.providers ?? [config.provider];
|
|
3742
4217
|
const prepared = selectEvals(config.evals, options.only).map((ev) => {
|
|
3743
4218
|
const template = resolveTemplate(ev, deps.baseDir);
|
|
3744
4219
|
const rows = deps.loadDataset(ev.dataset, deps.baseDir);
|
|
3745
4220
|
for (const row of rows) {
|
|
3746
4221
|
resolvePrompt(template, row.vars);
|
|
3747
4222
|
}
|
|
3748
|
-
const
|
|
3749
|
-
|
|
4223
|
+
const cells = models.map((model) => {
|
|
4224
|
+
const providerConfig = { ...model, ...ev.provider };
|
|
4225
|
+
const agentic = ev.mcp === void 0 || dryRun ? void 0 : agenticProvider(ev, providerConfig, deps, cacheStrict);
|
|
4226
|
+
return { providerConfig, agentic };
|
|
4227
|
+
});
|
|
4228
|
+
return { ev, template, rows, cells };
|
|
3750
4229
|
});
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
const
|
|
3758
|
-
const
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
4230
|
+
const swapped = Object.keys(options.toolDescriptions ?? {}).length > 0;
|
|
4231
|
+
if (swapped && !prepared.some((x) => x.ev.mcp !== void 0))
|
|
4232
|
+
throw new RunConfigError(
|
|
4233
|
+
"--tool-description needs an eval with mcp in this run: no tool is offered otherwise"
|
|
4234
|
+
);
|
|
4235
|
+
cellLoop: for (const { ev, template, rows, cells } of prepared) {
|
|
4236
|
+
for (const { providerConfig, agentic } of cells) {
|
|
4237
|
+
const provider = agentic ?? deps.resolveProvider(providerConfig);
|
|
4238
|
+
const limit2 = options.concurrency ?? providerConfig.concurrency ?? (ev.mcp !== void 0 ? 1 : 4);
|
|
4239
|
+
const runs = options.runs ?? ev.runs ?? config.runs ?? 1;
|
|
4240
|
+
const passThreshold = ev.pass_threshold ?? config.pass_threshold ?? 1;
|
|
4241
|
+
const assertions = [...config.defaults?.assertions ?? [], ...ev.assertions];
|
|
4242
|
+
const rowResults = await mapLimit(rows, limit2, (row) => {
|
|
4243
|
+
const params = {
|
|
4244
|
+
template,
|
|
4245
|
+
assertions,
|
|
4246
|
+
row,
|
|
4247
|
+
providerConfig,
|
|
4248
|
+
provider,
|
|
4249
|
+
embedder: deps.embedder,
|
|
4250
|
+
cache: deps.cache,
|
|
4251
|
+
now: deps.now,
|
|
4252
|
+
dryRun,
|
|
4253
|
+
noCache,
|
|
4254
|
+
cacheStrict,
|
|
4255
|
+
...options.cacheMaxAgeMs !== void 0 ? { cacheMaxAgeMs: options.cacheMaxAgeMs } : {}
|
|
4256
|
+
};
|
|
4257
|
+
if (ev.mcp === void 0) return runRepeats(params, runs, passThreshold);
|
|
4258
|
+
const agentParams = {
|
|
4259
|
+
...params,
|
|
4260
|
+
server: ev.mcp.server,
|
|
4261
|
+
...ev.mcp.allowed_tools !== void 0 ? { allowedTools: ev.mcp.allowed_tools } : {},
|
|
4262
|
+
limits: mcpLimits(config, ev),
|
|
4263
|
+
...options.toolDescriptions !== void 0 ? { toolDescriptions: options.toolDescriptions } : {},
|
|
4264
|
+
// A dry run connects nowhere; the loop never calls this then.
|
|
4265
|
+
connect: deps.connectMcp ?? (() => Promise.reject(new Error("no MCP connection")))
|
|
4266
|
+
};
|
|
4267
|
+
return runRepeats(agentParams, runs, passThreshold, runAgentRow);
|
|
4268
|
+
});
|
|
4269
|
+
const passed = !dryRun && rowResults.every((r) => rowStatus(r) === "passed");
|
|
4270
|
+
const measured = {
|
|
4271
|
+
runs,
|
|
4272
|
+
rows: rows.length,
|
|
4273
|
+
rows_hash: sha256(canonicalJson(rows.map((r) => canonicalJson(r.vars)).sort())),
|
|
4274
|
+
assertions_hash: sha256(canonicalJson(assertions)),
|
|
4275
|
+
model: `${providerConfig.type}/${providerConfig.model}`
|
|
3781
4276
|
};
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
4277
|
+
evalResults.push({
|
|
4278
|
+
id: models.length > 1 ? `${ev.id}@${providerConfig.model}` : ev.id,
|
|
4279
|
+
tags: ev.tags ?? [],
|
|
4280
|
+
rows: rowResults,
|
|
4281
|
+
passed,
|
|
4282
|
+
measured,
|
|
4283
|
+
...models.length > 1 ? { provider: { type: providerConfig.type, model: providerConfig.model } } : {}
|
|
4284
|
+
});
|
|
4285
|
+
if (options.bail === true && !dryRun && !passed) break cellLoop;
|
|
4286
|
+
}
|
|
3787
4287
|
}
|
|
3788
4288
|
const finished = deps.now();
|
|
3789
4289
|
const summary = summarize(evalResults, finished - started);
|
|
@@ -3793,6 +4293,8 @@ async function runOrchestration(config, options, deps) {
|
|
|
3793
4293
|
started_at: new Date(started).toISOString(),
|
|
3794
4294
|
finished_at: new Date(finished).toISOString(),
|
|
3795
4295
|
config_hash: configHash(config),
|
|
4296
|
+
// The one fact every reader of the result asks: was anything measured (plune-ai/cli#244).
|
|
4297
|
+
...dryRun ? { dry_run: true } : {},
|
|
3796
4298
|
summary,
|
|
3797
4299
|
evals: evalResults
|
|
3798
4300
|
};
|
|
@@ -3805,11 +4307,19 @@ init_esm_shims();
|
|
|
3805
4307
|
init_esm_shims();
|
|
3806
4308
|
import * as fs4 from "fs";
|
|
3807
4309
|
import * as path5 from "path";
|
|
3808
|
-
function loadDataset(
|
|
3809
|
-
if (typeof
|
|
3810
|
-
return
|
|
4310
|
+
function loadDataset(ref5, baseDir) {
|
|
4311
|
+
if (typeof ref5 !== "string") {
|
|
4312
|
+
return ref5.examples;
|
|
4313
|
+
}
|
|
4314
|
+
const file = path5.resolve(baseDir, ref5);
|
|
4315
|
+
let content;
|
|
4316
|
+
try {
|
|
4317
|
+
content = fs4.readFileSync(file, "utf8");
|
|
4318
|
+
} catch (err) {
|
|
4319
|
+
throw new RunConfigError(
|
|
4320
|
+
err.code === "ENOENT" ? `${ref5}: dataset file not found (looked for ${file})` : `${ref5}: cannot read the dataset file (${err.message})`
|
|
4321
|
+
);
|
|
3811
4322
|
}
|
|
3812
|
-
const content = fs4.readFileSync(path5.resolve(baseDir, ref), "utf8");
|
|
3813
4323
|
const rows = [];
|
|
3814
4324
|
content.split(/\r?\n/).forEach((line, i) => {
|
|
3815
4325
|
if (line.trim().length === 0) return;
|
|
@@ -3817,13 +4327,13 @@ function loadDataset(ref, baseDir) {
|
|
|
3817
4327
|
try {
|
|
3818
4328
|
row = JSON.parse(line.trim());
|
|
3819
4329
|
} catch (err) {
|
|
3820
|
-
throw new RunConfigError(`${
|
|
4330
|
+
throw new RunConfigError(`${ref5}:${i + 1}: not valid JSON (${err.message})`);
|
|
3821
4331
|
}
|
|
3822
4332
|
const vars = isObject2(row) ? row["vars"] : void 0;
|
|
3823
4333
|
if (!isObject2(vars)) {
|
|
3824
4334
|
const why = isObject2(row) && "vars" in row ? `vars: Invalid input: expected record, received ${typeName(vars)}` : 'this row has no "vars"';
|
|
3825
4335
|
throw new RunConfigError(
|
|
3826
|
-
`${
|
|
4336
|
+
`${ref5}:${i + 1}: a dataset row must be { "vars": { ... } }; ${why}`
|
|
3827
4337
|
);
|
|
3828
4338
|
}
|
|
3829
4339
|
rows.push(row);
|
|
@@ -3846,6 +4356,41 @@ var NOOP_CACHE = { get: () => void 0, set: () => {
|
|
|
3846
4356
|
function isMockMode(env) {
|
|
3847
4357
|
return env["PLUNE_MOCK_PROVIDER"] === "1";
|
|
3848
4358
|
}
|
|
4359
|
+
var MAX_DESCRIPTION_BYTES = 64 * 1024;
|
|
4360
|
+
function parseToolDescriptions(values) {
|
|
4361
|
+
const out = {};
|
|
4362
|
+
for (const v of values) {
|
|
4363
|
+
const eq = v.indexOf("=");
|
|
4364
|
+
const tool = eq < 0 ? "" : v.slice(0, eq).trim();
|
|
4365
|
+
let text = eq < 0 ? "" : v.slice(eq + 1);
|
|
4366
|
+
if (tool === "" || text === "")
|
|
4367
|
+
throw new RunConfigError(
|
|
4368
|
+
`--tool-description must be <tool>=<text> or <tool>=@<file> (got "${tool === "" ? v : tool + "="}")`
|
|
4369
|
+
);
|
|
4370
|
+
if (Object.hasOwn(out, tool))
|
|
4371
|
+
throw new RunConfigError(`--tool-description names "${tool}" twice`);
|
|
4372
|
+
if (text.startsWith("@")) {
|
|
4373
|
+
const file = text.slice(1);
|
|
4374
|
+
try {
|
|
4375
|
+
const full = path6.resolve(file);
|
|
4376
|
+
const stat2 = fs5.statSync(full);
|
|
4377
|
+
if (!stat2.isFile())
|
|
4378
|
+
throw new RunConfigError(`--tool-description ${tool}: ${file} is not a file`);
|
|
4379
|
+
if (stat2.size > MAX_DESCRIPTION_BYTES)
|
|
4380
|
+
throw new RunConfigError(`--tool-description ${tool}: ${file} is over 64 KB`);
|
|
4381
|
+
text = fs5.readFileSync(full, "utf8").replace(/\r?\n$/, "");
|
|
4382
|
+
} catch (err) {
|
|
4383
|
+
if (err instanceof RunConfigError) throw err;
|
|
4384
|
+
throw new RunConfigError(`--tool-description ${tool}: cannot read ${file}`);
|
|
4385
|
+
}
|
|
4386
|
+
if (text === "") throw new RunConfigError(`--tool-description ${tool}: ${file} is empty`);
|
|
4387
|
+
}
|
|
4388
|
+
if (Buffer.byteLength(text, "utf8") > MAX_DESCRIPTION_BYTES)
|
|
4389
|
+
throw new RunConfigError(`--tool-description ${tool}: the text is over 64 KB`);
|
|
4390
|
+
out[tool] = text;
|
|
4391
|
+
}
|
|
4392
|
+
return out;
|
|
4393
|
+
}
|
|
3849
4394
|
function mockScript(env) {
|
|
3850
4395
|
const file = env["PLUNE_MOCK_SCRIPT"];
|
|
3851
4396
|
if (file === void 0 || file === "") return void 0;
|
|
@@ -3910,8 +4455,10 @@ async function handleRun(options, depsFactory) {
|
|
|
3910
4455
|
options.configPath !== void 0 ? { configPath: options.configPath } : {}
|
|
3911
4456
|
);
|
|
3912
4457
|
const baseDir = options.configPath !== void 0 ? path6.dirname(path6.resolve(options.configPath)) : process.cwd();
|
|
3913
|
-
for (const warning of mcpSecretWarnings(config)
|
|
4458
|
+
for (const warning of [...mcpSecretWarnings(config), ...selfJudgeWarnings(config)])
|
|
4459
|
+
process.stderr.write(`warning: ${warning}
|
|
3914
4460
|
`);
|
|
4461
|
+
const toolDescriptions = options.toolDescription !== void 0 && options.toolDescription.length > 0 ? parseToolDescriptions(options.toolDescription) : void 0;
|
|
3915
4462
|
const factory = depsFactory ?? ((c, d) => buildRealDeps(c, d, options.dryRun));
|
|
3916
4463
|
const deps = factory(config, baseDir);
|
|
3917
4464
|
try {
|
|
@@ -3930,10 +4477,25 @@ async function handleRun(options, depsFactory) {
|
|
|
3930
4477
|
...options.bail !== void 0 ? { bail: options.bail } : {},
|
|
3931
4478
|
...options.cacheStrict === true ? { cacheStrict: true } : {},
|
|
3932
4479
|
...options.cacheMaxAgeMs !== void 0 ? { cacheMaxAgeMs: options.cacheMaxAgeMs } : {},
|
|
3933
|
-
...options.runs !== void 0 ? { runs: options.runs } : {}
|
|
4480
|
+
...options.runs !== void 0 ? { runs: options.runs } : {},
|
|
4481
|
+
...toolDescriptions !== void 0 ? { toolDescriptions } : {}
|
|
3934
4482
|
},
|
|
3935
4483
|
deps
|
|
3936
4484
|
);
|
|
4485
|
+
for (const tool of Object.keys(toolDescriptions ?? {})) {
|
|
4486
|
+
const used = result.evals.some(
|
|
4487
|
+
(ev) => ev.rows.some(
|
|
4488
|
+
(r) => (r.agent?.description_overrides ?? []).some(
|
|
4489
|
+
(o) => o.tool === tool
|
|
4490
|
+
)
|
|
4491
|
+
)
|
|
4492
|
+
);
|
|
4493
|
+
if (!used && !options.dryRun)
|
|
4494
|
+
process.stderr.write(
|
|
4495
|
+
`warning: --tool-description ${tool}: no row offered a tool of that name, nothing was replaced
|
|
4496
|
+
`
|
|
4497
|
+
);
|
|
4498
|
+
}
|
|
3937
4499
|
if (options.dryRun) {
|
|
3938
4500
|
const agentic = new Set(config.evals.filter((ev) => ev.mcp !== void 0).map((ev) => ev.id));
|
|
3939
4501
|
if (result.evals.some((ev) => agentic.has(ev.id)))
|
|
@@ -3941,7 +4503,7 @@ async function handleRun(options, depsFactory) {
|
|
|
3941
4503
|
"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"
|
|
3942
4504
|
);
|
|
3943
4505
|
}
|
|
3944
|
-
persist(result, baseDir);
|
|
4506
|
+
if (result.dry_run !== true) persist(result, baseDir);
|
|
3945
4507
|
return result;
|
|
3946
4508
|
} finally {
|
|
3947
4509
|
deps.cache.close();
|
|
@@ -4042,7 +4604,9 @@ var rowResultSchema = z3.object({
|
|
|
4042
4604
|
duration_ms: z3.number().optional(),
|
|
4043
4605
|
result: z3.object({ text: z3.string(), bytes: z3.number(), truncated: z3.boolean() }).optional()
|
|
4044
4606
|
})
|
|
4045
|
-
)
|
|
4607
|
+
),
|
|
4608
|
+
/** Optional and additive: the step whose request first offered a changed list. */
|
|
4609
|
+
offered_changed: z3.object({ added: z3.array(z3.string()), removed: z3.array(z3.string()) }).optional()
|
|
4046
4610
|
})
|
|
4047
4611
|
),
|
|
4048
4612
|
stop: z3.object({
|
|
@@ -4051,7 +4615,17 @@ var rowResultSchema = z3.object({
|
|
|
4051
4615
|
}),
|
|
4052
4616
|
collection: z3.enum(["complete", "partial"]),
|
|
4053
4617
|
/** Heuristic findings, never a verdict. Optional and additive. */
|
|
4054
|
-
advice: z3.array(
|
|
4618
|
+
advice: z3.array(
|
|
4619
|
+
z3.object({
|
|
4620
|
+
type: z3.string(),
|
|
4621
|
+
reason: z3.string(),
|
|
4622
|
+
tool: z3.string().optional(),
|
|
4623
|
+
steps: z3.array(z3.number()).optional(),
|
|
4624
|
+
count: z3.number().optional(),
|
|
4625
|
+
paths: z3.array(z3.string()).optional()
|
|
4626
|
+
})
|
|
4627
|
+
).optional(),
|
|
4628
|
+
description_overrides: z3.array(z3.object({ tool: z3.string(), sha256: z3.string() })).optional()
|
|
4055
4629
|
}).optional()
|
|
4056
4630
|
});
|
|
4057
4631
|
var summarySchema = z3.object({
|
|
@@ -4076,7 +4650,17 @@ var evalResultSchema = z3.object({
|
|
|
4076
4650
|
id: z3.string(),
|
|
4077
4651
|
tags: z3.array(z3.string()),
|
|
4078
4652
|
rows: z3.array(rowResultSchema),
|
|
4079
|
-
passed: z3.boolean()
|
|
4653
|
+
passed: z3.boolean(),
|
|
4654
|
+
/** What the eval measured, for the pass-rate gate of `plune diff`. Optional and additive. */
|
|
4655
|
+
measured: z3.object({
|
|
4656
|
+
runs: z3.number(),
|
|
4657
|
+
rows: z3.number(),
|
|
4658
|
+
rows_hash: z3.string(),
|
|
4659
|
+
assertions_hash: z3.string(),
|
|
4660
|
+
model: z3.string().optional()
|
|
4661
|
+
}).optional(),
|
|
4662
|
+
/** The type and model of a cell of a multi-model run. Optional and additive. */
|
|
4663
|
+
provider: z3.object({ type: z3.string(), model: z3.string() }).optional()
|
|
4080
4664
|
});
|
|
4081
4665
|
var runResultSchema = z3.object({
|
|
4082
4666
|
schemaVersion: z3.literal(RUN_RESULT_SCHEMA_VERSION),
|
|
@@ -4084,6 +4668,8 @@ var runResultSchema = z3.object({
|
|
|
4084
4668
|
started_at: z3.string(),
|
|
4085
4669
|
finished_at: z3.string(),
|
|
4086
4670
|
config_hash: z3.string(),
|
|
4671
|
+
/** cli#244. The result of `--dry-run`. Optional and additive — a RunResult without it validates unchanged. */
|
|
4672
|
+
dry_run: z3.boolean().optional(),
|
|
4087
4673
|
summary: summarySchema,
|
|
4088
4674
|
evals: z3.array(evalResultSchema)
|
|
4089
4675
|
});
|
|
@@ -4357,6 +4943,1539 @@ import * as path9 from "path";
|
|
|
4357
4943
|
init_esm_shims();
|
|
4358
4944
|
import * as fs7 from "fs/promises";
|
|
4359
4945
|
import * as path8 from "path";
|
|
4946
|
+
|
|
4947
|
+
// src/mcp-testing/scan/config/config.ts
|
|
4948
|
+
init_esm_shims();
|
|
4949
|
+
|
|
4950
|
+
// src/mcp-testing/report/human.ts
|
|
4951
|
+
init_esm_shims();
|
|
4952
|
+
init_failure_detail();
|
|
4953
|
+
|
|
4954
|
+
// src/mcp-testing/conformance/score.ts
|
|
4955
|
+
init_esm_shims();
|
|
4956
|
+
init_exit_codes();
|
|
4957
|
+
|
|
4958
|
+
// src/mcp-testing/conformance/catalog.ts
|
|
4959
|
+
init_esm_shims();
|
|
4960
|
+
|
|
4961
|
+
// src/mcp-testing/conformance/apps-catalog.ts
|
|
4962
|
+
init_esm_shims();
|
|
4963
|
+
var BOTH = ["legacy", "modern"];
|
|
4964
|
+
var APPS_SPEC_URL = "https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx";
|
|
4965
|
+
var ref = (section) => ({
|
|
4966
|
+
revision: "2026-01-26",
|
|
4967
|
+
page: "apps.mdx",
|
|
4968
|
+
section,
|
|
4969
|
+
url: APPS_SPEC_URL
|
|
4970
|
+
});
|
|
4971
|
+
var FORMAT = "UI Resource Format";
|
|
4972
|
+
var DISCOVERY = "Resource Discovery";
|
|
4973
|
+
var apps = (s) => ({
|
|
4974
|
+
...s,
|
|
4975
|
+
suite: "apps",
|
|
4976
|
+
kind: "check",
|
|
4977
|
+
derived: s.derived ?? false,
|
|
4978
|
+
needsFixture: s.needsFixture ?? false,
|
|
4979
|
+
transports: ["stdio", "http"],
|
|
4980
|
+
eras: BOTH
|
|
4981
|
+
});
|
|
4982
|
+
var APPS_CATALOG = [
|
|
4983
|
+
apps({
|
|
4984
|
+
id: "apps-ui-resource-uri-scheme",
|
|
4985
|
+
title: "The address of a UI resource starts with ui://",
|
|
4986
|
+
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.",
|
|
4987
|
+
level: "MUST",
|
|
4988
|
+
derived: true,
|
|
4989
|
+
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.',
|
|
4990
|
+
specRefs: [ref(FORMAT), ref(DISCOVERY)]
|
|
4991
|
+
}),
|
|
4992
|
+
apps({
|
|
4993
|
+
id: "apps-ui-resource-exists",
|
|
4994
|
+
title: "The resource a tool names can be read",
|
|
4995
|
+
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.",
|
|
4996
|
+
level: "MUST",
|
|
4997
|
+
derived: true,
|
|
4998
|
+
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.`,
|
|
4999
|
+
specRefs: [ref(DISCOVERY)]
|
|
5000
|
+
}),
|
|
5001
|
+
apps({
|
|
5002
|
+
id: "apps-ui-mime-type",
|
|
5003
|
+
title: "The content of a UI resource is text/html;profile=mcp-app",
|
|
5004
|
+
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).',
|
|
5005
|
+
level: "MUST",
|
|
5006
|
+
derivation: 'Content Requirements: "`mimeType` MUST be `text/html;profile=mcp-app` (other types reserved for future extensions)"',
|
|
5007
|
+
specRefs: [ref(FORMAT)]
|
|
5008
|
+
}),
|
|
5009
|
+
apps({
|
|
5010
|
+
id: "apps-ui-content-payload",
|
|
5011
|
+
title: "The content is one of text and blob, and is an HTML5 document",
|
|
5012
|
+
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.",
|
|
5013
|
+
level: "MUST",
|
|
5014
|
+
derived: true,
|
|
5015
|
+
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.',
|
|
5016
|
+
specRefs: [ref(FORMAT)]
|
|
5017
|
+
}),
|
|
5018
|
+
apps({
|
|
5019
|
+
id: "apps-ui-listed-mime",
|
|
5020
|
+
title: "A listed UI resource has the mimeType text/html;profile=mcp-app",
|
|
5021
|
+
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.",
|
|
5022
|
+
level: "SHOULD",
|
|
5023
|
+
derivation: 'UIResource.mimeType: "SHOULD be `text/html;profile=mcp-app` for HTML-based UIs in the initial MVP."',
|
|
5024
|
+
specRefs: [ref(FORMAT)]
|
|
5025
|
+
}),
|
|
5026
|
+
apps({
|
|
5027
|
+
id: "apps-ui-visibility-values",
|
|
5028
|
+
title: "visibility holds only model and app",
|
|
5029
|
+
description: 'Where a tool sets _meta.ui.visibility, it is an array whose every element is "model" or "app".',
|
|
5030
|
+
level: "SHOULD",
|
|
5031
|
+
derived: true,
|
|
5032
|
+
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.',
|
|
5033
|
+
specRefs: [ref(DISCOVERY)]
|
|
5034
|
+
}),
|
|
5035
|
+
apps({
|
|
5036
|
+
id: "apps-ui-tool-text-fallback",
|
|
5037
|
+
title: "A tool with a UI also returns content",
|
|
5038
|
+
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).",
|
|
5039
|
+
level: "MUST",
|
|
5040
|
+
needsFixture: true,
|
|
5041
|
+
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.',
|
|
5042
|
+
specRefs: [ref("Client<>Server Capability Negotiation")]
|
|
5043
|
+
}),
|
|
5044
|
+
apps({
|
|
5045
|
+
id: "apps-ui-meta-shapes",
|
|
5046
|
+
title: "csp, permissions, domain and prefersBorder have the shapes of the text",
|
|
5047
|
+
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).",
|
|
5048
|
+
level: "SHOULD",
|
|
5049
|
+
derived: true,
|
|
5050
|
+
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.',
|
|
5051
|
+
specRefs: [ref(FORMAT)]
|
|
5052
|
+
})
|
|
5053
|
+
];
|
|
5054
|
+
|
|
5055
|
+
// src/mcp-testing/conformance/auth-catalog.ts
|
|
5056
|
+
init_esm_shims();
|
|
5057
|
+
var L = "2025-11-25";
|
|
5058
|
+
var M = "2026-07-28";
|
|
5059
|
+
var BOTH2 = ["legacy", "modern"];
|
|
5060
|
+
var MODERN = ["modern"];
|
|
5061
|
+
var ref2 = (revision, page, section) => ({
|
|
5062
|
+
revision,
|
|
5063
|
+
page,
|
|
5064
|
+
section
|
|
5065
|
+
});
|
|
5066
|
+
var AUTH = "basic/authorization";
|
|
5067
|
+
var DISCOVERY2 = "basic/authorization/authorization-server-discovery";
|
|
5068
|
+
var SECURITY = "basic/authorization/security-considerations";
|
|
5069
|
+
var REGISTRATION = "basic/authorization/client-registration";
|
|
5070
|
+
var oauth = (s) => ({
|
|
5071
|
+
...s,
|
|
5072
|
+
suite: "oauth",
|
|
5073
|
+
kind: "check",
|
|
5074
|
+
derived: s.derived ?? false,
|
|
5075
|
+
needsFixture: s.needsFixture ?? false,
|
|
5076
|
+
transports: ["http"]
|
|
5077
|
+
});
|
|
5078
|
+
var OAUTH_CATALOG = [
|
|
5079
|
+
oauth({
|
|
5080
|
+
id: "oauth-requires-auth",
|
|
5081
|
+
title: "A request without a token gets 401",
|
|
5082
|
+
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).",
|
|
5083
|
+
level: "MUST",
|
|
5084
|
+
specRefs: [ref2(L, AUTH, "Error Handling"), ref2(M, AUTH, "Error Handling")],
|
|
5085
|
+
eras: BOTH2
|
|
5086
|
+
}),
|
|
5087
|
+
oauth({
|
|
5088
|
+
id: "oauth-challenge-bearer",
|
|
5089
|
+
title: "The 401 carries a Bearer challenge",
|
|
5090
|
+
description: "The 401 answer has a WWW-Authenticate header with the scheme Bearer.",
|
|
5091
|
+
level: "MUST",
|
|
5092
|
+
derived: true,
|
|
5093
|
+
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.`,
|
|
5094
|
+
specRefs: [
|
|
5095
|
+
ref2(L, AUTH, "Protected Resource Metadata Discovery Requirements"),
|
|
5096
|
+
ref2(M, DISCOVERY2, "Protected Resource Metadata Discovery Requirements")
|
|
5097
|
+
],
|
|
5098
|
+
eras: BOTH2
|
|
5099
|
+
}),
|
|
5100
|
+
oauth({
|
|
5101
|
+
id: "oauth-prm-reachable",
|
|
5102
|
+
title: "The protected resource metadata can be found",
|
|
5103
|
+
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.",
|
|
5104
|
+
level: "MUST",
|
|
5105
|
+
specRefs: [
|
|
5106
|
+
ref2(L, AUTH, "Protected Resource Metadata Discovery Requirements"),
|
|
5107
|
+
ref2(M, DISCOVERY2, "Protected Resource Metadata Discovery Requirements")
|
|
5108
|
+
],
|
|
5109
|
+
eras: BOTH2
|
|
5110
|
+
}),
|
|
5111
|
+
oauth({
|
|
5112
|
+
id: "oauth-challenge-metadata-url",
|
|
5113
|
+
title: "resource_metadata names a URL that serves the document",
|
|
5114
|
+
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.",
|
|
5115
|
+
level: "MUST",
|
|
5116
|
+
derived: true,
|
|
5117
|
+
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.',
|
|
5118
|
+
specRefs: [
|
|
5119
|
+
ref2(L, AUTH, "Protected Resource Metadata Discovery Requirements"),
|
|
5120
|
+
ref2(M, DISCOVERY2, "Protected Resource Metadata Discovery Requirements")
|
|
5121
|
+
],
|
|
5122
|
+
eras: BOTH2
|
|
5123
|
+
}),
|
|
5124
|
+
oauth({
|
|
5125
|
+
id: "oauth-prm-valid",
|
|
5126
|
+
title: "The protected resource metadata names an authorization server",
|
|
5127
|
+
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).",
|
|
5128
|
+
level: "MUST",
|
|
5129
|
+
derived: true,
|
|
5130
|
+
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.`,
|
|
5131
|
+
specRefs: [
|
|
5132
|
+
ref2(L, AUTH, "Authorization Server Location"),
|
|
5133
|
+
ref2(M, DISCOVERY2, "Authorization Server Location")
|
|
5134
|
+
],
|
|
5135
|
+
eras: BOTH2
|
|
5136
|
+
}),
|
|
5137
|
+
oauth({
|
|
5138
|
+
id: "oauth-challenge-scope",
|
|
5139
|
+
title: "The 401 names the scope it needs",
|
|
5140
|
+
description: "WWW-Authenticate has a scope parameter.",
|
|
5141
|
+
level: "SHOULD",
|
|
5142
|
+
specRefs: [
|
|
5143
|
+
ref2(L, AUTH, "Protected Resource Metadata Discovery Requirements"),
|
|
5144
|
+
ref2(M, AUTH, "Scope Selection Strategy")
|
|
5145
|
+
],
|
|
5146
|
+
eras: BOTH2
|
|
5147
|
+
}),
|
|
5148
|
+
oauth({
|
|
5149
|
+
id: "oauth-as-metadata-discoverable",
|
|
5150
|
+
title: "The authorization server publishes metadata",
|
|
5151
|
+
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).",
|
|
5152
|
+
level: "MUST",
|
|
5153
|
+
specRefs: [
|
|
5154
|
+
ref2(L, AUTH, "Authorization Server Metadata Discovery"),
|
|
5155
|
+
ref2(M, DISCOVERY2, "Authorization Server Metadata Discovery")
|
|
5156
|
+
],
|
|
5157
|
+
eras: BOTH2
|
|
5158
|
+
}),
|
|
5159
|
+
oauth({
|
|
5160
|
+
id: "oauth-as-issuer-matches",
|
|
5161
|
+
title: "The issuer of the metadata is the issuer it was found by",
|
|
5162
|
+
description: "The issuer member of the metadata document is identical, character for character, to the issuer identifier the well-known URL was built from.",
|
|
5163
|
+
level: "MUST",
|
|
5164
|
+
derived: true,
|
|
5165
|
+
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.',
|
|
5166
|
+
specRefs: [ref2(M, DISCOVERY2, "Authorization Server Metadata Discovery")],
|
|
5167
|
+
eras: MODERN
|
|
5168
|
+
}),
|
|
5169
|
+
oauth({
|
|
5170
|
+
id: "oauth-as-https",
|
|
5171
|
+
title: "The authorization endpoints are HTTPS",
|
|
5172
|
+
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.",
|
|
5173
|
+
level: "MUST",
|
|
5174
|
+
specRefs: [ref2(L, AUTH, "Communication Security"), ref2(M, SECURITY, "Communication Security")],
|
|
5175
|
+
eras: BOTH2
|
|
5176
|
+
}),
|
|
5177
|
+
oauth({
|
|
5178
|
+
id: "oauth-as-pkce-advertised",
|
|
5179
|
+
title: "The authorization server advertises PKCE",
|
|
5180
|
+
description: "The metadata has code_challenge_methods_supported.",
|
|
5181
|
+
level: "MUST",
|
|
5182
|
+
derived: true,
|
|
5183
|
+
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).',
|
|
5184
|
+
specRefs: [
|
|
5185
|
+
ref2(L, AUTH, "Authorization Code Protection"),
|
|
5186
|
+
ref2(M, SECURITY, "Authorization Code Protection")
|
|
5187
|
+
],
|
|
5188
|
+
eras: BOTH2
|
|
5189
|
+
}),
|
|
5190
|
+
oauth({
|
|
5191
|
+
id: "oauth-as-pkce-s256",
|
|
5192
|
+
title: "PKCE with S256 is advertised",
|
|
5193
|
+
description: "code_challenge_methods_supported lists S256.",
|
|
5194
|
+
level: "SHOULD",
|
|
5195
|
+
derived: true,
|
|
5196
|
+
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.",
|
|
5197
|
+
specRefs: [
|
|
5198
|
+
ref2(L, AUTH, "Authorization Code Protection"),
|
|
5199
|
+
ref2(M, SECURITY, "Authorization Code Protection")
|
|
5200
|
+
],
|
|
5201
|
+
eras: BOTH2
|
|
5202
|
+
}),
|
|
5203
|
+
oauth({
|
|
5204
|
+
id: "oauth-as-iss-advertised",
|
|
5205
|
+
title: "The authorization server advertises the iss parameter",
|
|
5206
|
+
description: "The metadata has authorization_response_iss_parameter_supported: true.",
|
|
5207
|
+
level: "SHOULD",
|
|
5208
|
+
specRefs: [ref2(M, AUTH, "Authorization Response Validation")],
|
|
5209
|
+
eras: MODERN
|
|
5210
|
+
}),
|
|
5211
|
+
oauth({
|
|
5212
|
+
id: "oauth-as-cimd-advertised",
|
|
5213
|
+
title: "The authorization server advertises Client ID Metadata Documents",
|
|
5214
|
+
description: "The metadata has client_id_metadata_document_supported: true.",
|
|
5215
|
+
level: "SHOULD",
|
|
5216
|
+
specRefs: [
|
|
5217
|
+
ref2(L, AUTH, "Client ID Metadata Documents"),
|
|
5218
|
+
ref2(M, REGISTRATION, "Client ID Metadata Documents")
|
|
5219
|
+
],
|
|
5220
|
+
eras: BOTH2
|
|
5221
|
+
}),
|
|
5222
|
+
oauth({
|
|
5223
|
+
id: "oauth-neg-invalid-token-401",
|
|
5224
|
+
title: "A token that is not valid gets 401",
|
|
5225
|
+
description: "A request with a bearer token the authorization server never issued answers 401.",
|
|
5226
|
+
level: "MUST",
|
|
5227
|
+
specRefs: [ref2(L, AUTH, "Token Handling"), ref2(M, AUTH, "Token Handling")],
|
|
5228
|
+
eras: BOTH2
|
|
5229
|
+
}),
|
|
5230
|
+
oauth({
|
|
5231
|
+
id: "oauth-neg-wrong-audience",
|
|
5232
|
+
title: "A token issued for another resource is refused",
|
|
5233
|
+
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.",
|
|
5234
|
+
level: "MUST",
|
|
5235
|
+
specRefs: [
|
|
5236
|
+
ref2(L, AUTH, "Token Handling"),
|
|
5237
|
+
ref2(L, AUTH, "Access Token Privilege Restriction"),
|
|
5238
|
+
ref2(M, AUTH, "Token Handling"),
|
|
5239
|
+
ref2(M, SECURITY, "Token Audience Binding and Validation")
|
|
5240
|
+
],
|
|
5241
|
+
eras: BOTH2,
|
|
5242
|
+
needsFixture: true
|
|
5243
|
+
}),
|
|
5244
|
+
oauth({
|
|
5245
|
+
id: "oauth-e2e-token-works",
|
|
5246
|
+
title: "A token issued for the server is accepted",
|
|
5247
|
+
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.",
|
|
5248
|
+
level: "MUST",
|
|
5249
|
+
derived: true,
|
|
5250
|
+
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.',
|
|
5251
|
+
specRefs: [ref2(L, AUTH, "Token Handling"), ref2(M, AUTH, "Token Handling")],
|
|
5252
|
+
eras: BOTH2,
|
|
5253
|
+
needsFixture: true
|
|
5254
|
+
}),
|
|
5255
|
+
oauth({
|
|
5256
|
+
id: "oauth-neg-insufficient-scope",
|
|
5257
|
+
title: "A token with too narrow a scope gets 403 with insufficient_scope",
|
|
5258
|
+
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.',
|
|
5259
|
+
level: "SHOULD",
|
|
5260
|
+
derived: true,
|
|
5261
|
+
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.`,
|
|
5262
|
+
specRefs: [
|
|
5263
|
+
ref2(L, AUTH, "Runtime Insufficient Scope Errors"),
|
|
5264
|
+
ref2(M, AUTH, "Runtime Insufficient Scope Errors")
|
|
5265
|
+
],
|
|
5266
|
+
eras: BOTH2,
|
|
5267
|
+
needsFixture: true
|
|
5268
|
+
}),
|
|
5269
|
+
oauth({
|
|
5270
|
+
id: "oauth-authz-response-iss",
|
|
5271
|
+
title: "iss in the authorization response is the issuer, and is advertised",
|
|
5272
|
+
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.',
|
|
5273
|
+
level: "MUST",
|
|
5274
|
+
derived: true,
|
|
5275
|
+
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.',
|
|
5276
|
+
specRefs: [ref2(M, AUTH, "Authorization Response Validation")],
|
|
5277
|
+
eras: MODERN,
|
|
5278
|
+
needsFixture: true
|
|
5279
|
+
}),
|
|
5280
|
+
oauth({
|
|
5281
|
+
id: "oauth-neg-pkce-wrong-verifier",
|
|
5282
|
+
title: "A code exchanged with a wrong code_verifier is refused",
|
|
5283
|
+
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.',
|
|
5284
|
+
level: "MUST",
|
|
5285
|
+
derived: true,
|
|
5286
|
+
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.',
|
|
5287
|
+
specRefs: [
|
|
5288
|
+
ref2(L, AUTH, "Authorization Code Protection"),
|
|
5289
|
+
ref2(M, SECURITY, "Authorization Code Protection")
|
|
5290
|
+
],
|
|
5291
|
+
eras: BOTH2,
|
|
5292
|
+
needsFixture: true
|
|
5293
|
+
}),
|
|
5294
|
+
oauth({
|
|
5295
|
+
id: "oauth-neg-token-redirect-mismatch",
|
|
5296
|
+
title: "A code exchanged with another redirect_uri is refused as such",
|
|
5297
|
+
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).',
|
|
5298
|
+
level: "MUST",
|
|
5299
|
+
derived: true,
|
|
5300
|
+
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.',
|
|
5301
|
+
specRefs: [ref2(L, AUTH, "Open Redirection"), ref2(M, SECURITY, "Open Redirection")],
|
|
5302
|
+
eras: BOTH2,
|
|
5303
|
+
needsFixture: true
|
|
5304
|
+
}),
|
|
5305
|
+
oauth({
|
|
5306
|
+
id: "oauth-reg-prereg",
|
|
5307
|
+
title: "A pre-registered client is accepted",
|
|
5308
|
+
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.",
|
|
5309
|
+
level: "SHOULD",
|
|
5310
|
+
derived: true,
|
|
5311
|
+
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.',
|
|
5312
|
+
specRefs: [ref2(L, AUTH, "Preregistration"), ref2(M, REGISTRATION, "Pre-registration")],
|
|
5313
|
+
eras: BOTH2
|
|
5314
|
+
}),
|
|
5315
|
+
oauth({
|
|
5316
|
+
id: "oauth-reg-dcr",
|
|
5317
|
+
title: "Dynamic client registration works",
|
|
5318
|
+
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.",
|
|
5319
|
+
level: "MAY",
|
|
5320
|
+
specRefs: [
|
|
5321
|
+
ref2(L, AUTH, "Dynamic Client Registration"),
|
|
5322
|
+
ref2(M, REGISTRATION, "Dynamic Client Registration")
|
|
5323
|
+
],
|
|
5324
|
+
eras: BOTH2
|
|
5325
|
+
}),
|
|
5326
|
+
oauth({
|
|
5327
|
+
id: "oauth-reg-dcr-http-redirect-rejected",
|
|
5328
|
+
title: "A redirect over http outside loopback is not registered",
|
|
5329
|
+
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.",
|
|
5330
|
+
level: "MUST",
|
|
5331
|
+
derived: true,
|
|
5332
|
+
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.',
|
|
5333
|
+
specRefs: [
|
|
5334
|
+
ref2(L, AUTH, "Communication Security"),
|
|
5335
|
+
ref2(L, AUTH, "Open Redirection"),
|
|
5336
|
+
ref2(M, SECURITY, "Communication Security"),
|
|
5337
|
+
ref2(M, SECURITY, "Open Redirection")
|
|
5338
|
+
],
|
|
5339
|
+
eras: BOTH2
|
|
5340
|
+
}),
|
|
5341
|
+
oauth({
|
|
5342
|
+
id: "oauth-reg-cimd",
|
|
5343
|
+
title: "A client_id that is a URL is read as a document",
|
|
5344
|
+
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.",
|
|
5345
|
+
level: "MUST",
|
|
5346
|
+
derived: true,
|
|
5347
|
+
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.',
|
|
5348
|
+
specRefs: [
|
|
5349
|
+
ref2(L, AUTH, "Client ID Metadata Documents"),
|
|
5350
|
+
ref2(M, REGISTRATION, "Client ID Metadata Documents")
|
|
5351
|
+
],
|
|
5352
|
+
eras: BOTH2,
|
|
5353
|
+
needsFixture: true
|
|
5354
|
+
}),
|
|
5355
|
+
oauth({
|
|
5356
|
+
id: "oauth-token-format",
|
|
5357
|
+
title: "The token response has access_token and token_type Bearer",
|
|
5358
|
+
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.",
|
|
5359
|
+
level: "MUST",
|
|
5360
|
+
derived: true,
|
|
5361
|
+
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.',
|
|
5362
|
+
specRefs: [ref2(L, AUTH, "Token Requirements"), ref2(M, AUTH, "Token Requirements")],
|
|
5363
|
+
eras: BOTH2,
|
|
5364
|
+
needsFixture: true
|
|
5365
|
+
}),
|
|
5366
|
+
oauth({
|
|
5367
|
+
id: "oauth-neg-invalid-client",
|
|
5368
|
+
title: "A client that does not exist is not accepted",
|
|
5369
|
+
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.",
|
|
5370
|
+
level: "MUST",
|
|
5371
|
+
derived: true,
|
|
5372
|
+
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).',
|
|
5373
|
+
specRefs: [ref2(L, AUTH, "Open Redirection"), ref2(M, SECURITY, "Open Redirection")],
|
|
5374
|
+
eras: BOTH2,
|
|
5375
|
+
needsFixture: true
|
|
5376
|
+
}),
|
|
5377
|
+
oauth({
|
|
5378
|
+
id: "oauth-neg-authorize-redirect-mismatch",
|
|
5379
|
+
title: "A redirect URI that is not registered is not redirected to",
|
|
5380
|
+
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.",
|
|
5381
|
+
level: "MUST",
|
|
5382
|
+
derived: false,
|
|
5383
|
+
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."',
|
|
5384
|
+
specRefs: [ref2(L, AUTH, "Open Redirection"), ref2(M, SECURITY, "Open Redirection")],
|
|
5385
|
+
eras: BOTH2,
|
|
5386
|
+
needsFixture: true
|
|
5387
|
+
})
|
|
5388
|
+
];
|
|
5389
|
+
|
|
5390
|
+
// src/mcp-testing/conformance/tasks-catalog.ts
|
|
5391
|
+
init_esm_shims();
|
|
5392
|
+
var TASKS_SPEC_URL = "https://github.com/modelcontextprotocol/ext-tasks/blob/main/specification/2026-07-28/tasks.md";
|
|
5393
|
+
var MODERN2 = ["modern"];
|
|
5394
|
+
var ref3 = (section) => ({
|
|
5395
|
+
revision: "2026-07-28",
|
|
5396
|
+
page: "tasks.md",
|
|
5397
|
+
section,
|
|
5398
|
+
url: TASKS_SPEC_URL
|
|
5399
|
+
});
|
|
5400
|
+
var tasks = (s) => ({
|
|
5401
|
+
...s,
|
|
5402
|
+
suite: "tasks",
|
|
5403
|
+
kind: "check",
|
|
5404
|
+
derived: s.derived ?? false,
|
|
5405
|
+
// Every check reads a task, and a task comes from a tool the user names in --fixture.
|
|
5406
|
+
needsFixture: s.needsFixture ?? true,
|
|
5407
|
+
transports: s.transports ?? ["stdio", "http"],
|
|
5408
|
+
eras: MODERN2
|
|
5409
|
+
});
|
|
5410
|
+
var TASKS_CATALOG = [
|
|
5411
|
+
tasks({
|
|
5412
|
+
id: "tasks-result-type",
|
|
5413
|
+
title: 'A task handle has resultType "task", and no other result has it',
|
|
5414
|
+
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".',
|
|
5415
|
+
level: "MUST",
|
|
5416
|
+
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`."',
|
|
5417
|
+
specRefs: [ref3("Polymorphic Results"), ref3("Task Creation")]
|
|
5418
|
+
}),
|
|
5419
|
+
tasks({
|
|
5420
|
+
id: "tasks-undeclared-no-task",
|
|
5421
|
+
title: "A client that did not declare the extension is given no task",
|
|
5422
|
+
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.",
|
|
5423
|
+
level: "MUST",
|
|
5424
|
+
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."',
|
|
5425
|
+
specRefs: [ref3("Capability Negotiation")]
|
|
5426
|
+
}),
|
|
5427
|
+
tasks({
|
|
5428
|
+
id: "tasks-undeclared-capability-error",
|
|
5429
|
+
title: "tasks/get, tasks/update and tasks/cancel without the declaration are -32021",
|
|
5430
|
+
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.",
|
|
5431
|
+
level: "MUST",
|
|
5432
|
+
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.',
|
|
5433
|
+
specRefs: [ref3("Protocol Errors"), ref3("Capability Negotiation")]
|
|
5434
|
+
}),
|
|
5435
|
+
tasks({
|
|
5436
|
+
id: "tasks-get-status-shape",
|
|
5437
|
+
title: 'tasks/get answers a task with resultType "complete" and the fields of a task',
|
|
5438
|
+
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.',
|
|
5439
|
+
level: "MUST",
|
|
5440
|
+
derived: true,
|
|
5441
|
+
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".',
|
|
5442
|
+
specRefs: [ref3("Task Polling"), ref3("Tasks")]
|
|
5443
|
+
}),
|
|
5444
|
+
tasks({
|
|
5445
|
+
id: "tasks-status-payload",
|
|
5446
|
+
title: "completed has a result, failed an error, input_required inputRequests",
|
|
5447
|
+
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).",
|
|
5448
|
+
level: "MUST",
|
|
5449
|
+
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."',
|
|
5450
|
+
specRefs: [ref3("Task Polling")]
|
|
5451
|
+
}),
|
|
5452
|
+
tasks({
|
|
5453
|
+
id: "tasks-ttl-poll-integers",
|
|
5454
|
+
title: "ttlMs is an integer or null, pollIntervalMs an integer",
|
|
5455
|
+
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.",
|
|
5456
|
+
level: "SHOULD",
|
|
5457
|
+
derived: true,
|
|
5458
|
+
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.',
|
|
5459
|
+
specRefs: [ref3("Tasks")]
|
|
5460
|
+
}),
|
|
5461
|
+
tasks({
|
|
5462
|
+
id: "tasks-unknown-id-get",
|
|
5463
|
+
title: "tasks/get for an unknown taskId is -32602",
|
|
5464
|
+
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).",
|
|
5465
|
+
level: "MUST",
|
|
5466
|
+
derivation: 'Protocol Errors: "Invalid or nonexistent `taskId`: `-32602` (Invalid params)" and "Servers **MUST** return this error for `tasks/get`."',
|
|
5467
|
+
specRefs: [ref3("Protocol Errors")]
|
|
5468
|
+
}),
|
|
5469
|
+
tasks({
|
|
5470
|
+
id: "tasks-unknown-id-update-cancel",
|
|
5471
|
+
title: "tasks/update and tasks/cancel for an unknown taskId are -32602",
|
|
5472
|
+
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).",
|
|
5473
|
+
level: "SHOULD",
|
|
5474
|
+
derivation: 'Protocol Errors: "Servers **SHOULD** return this error for `tasks/update` and `tasks/cancel`."',
|
|
5475
|
+
specRefs: [ref3("Protocol Errors")]
|
|
5476
|
+
}),
|
|
5477
|
+
tasks({
|
|
5478
|
+
id: "tasks-cancel-ack",
|
|
5479
|
+
title: "tasks/cancel is acknowledged with an empty result",
|
|
5480
|
+
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.',
|
|
5481
|
+
level: "MUST",
|
|
5482
|
+
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."',
|
|
5483
|
+
specRefs: [ref3("Task Cancellation")]
|
|
5484
|
+
}),
|
|
5485
|
+
tasks({
|
|
5486
|
+
id: "tasks-update-ack",
|
|
5487
|
+
title: "tasks/update is acknowledged with an empty result",
|
|
5488
|
+
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.',
|
|
5489
|
+
level: "MUST",
|
|
5490
|
+
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."',
|
|
5491
|
+
specRefs: [ref3("Task Update Requests")]
|
|
5492
|
+
}),
|
|
5493
|
+
tasks({
|
|
5494
|
+
id: "tasks-failed-status-message",
|
|
5495
|
+
title: "A failed task has a statusMessage",
|
|
5496
|
+
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).",
|
|
5497
|
+
level: "SHOULD",
|
|
5498
|
+
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."',
|
|
5499
|
+
specRefs: [ref3("Task Execution Errors")]
|
|
5500
|
+
}),
|
|
5501
|
+
tasks({
|
|
5502
|
+
id: "tasks-http-name-header",
|
|
5503
|
+
title: "tasks/get with Mcp-Name set to the taskId is accepted",
|
|
5504
|
+
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).",
|
|
5505
|
+
level: "SHOULD",
|
|
5506
|
+
derived: true,
|
|
5507
|
+
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.',
|
|
5508
|
+
specRefs: [ref3("Streamable HTTP: Routing Headers")],
|
|
5509
|
+
transports: ["http"]
|
|
5510
|
+
}),
|
|
5511
|
+
tasks({
|
|
5512
|
+
id: "tasks-input-request-keys-unique",
|
|
5513
|
+
title: "An inputRequests key never names two different requests",
|
|
5514
|
+
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.",
|
|
5515
|
+
level: "MUST",
|
|
5516
|
+
derived: true,
|
|
5517
|
+
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.',
|
|
5518
|
+
specRefs: [ref3("Task Update Requests")]
|
|
5519
|
+
})
|
|
5520
|
+
];
|
|
5521
|
+
|
|
5522
|
+
// src/mcp-testing/conformance/catalog.ts
|
|
5523
|
+
var L2 = "2025-11-25";
|
|
5524
|
+
var M2 = "2026-07-28";
|
|
5525
|
+
var BOTH3 = ["legacy", "modern"];
|
|
5526
|
+
var MODERN3 = ["modern"];
|
|
5527
|
+
var ANY = ["stdio", "http"];
|
|
5528
|
+
var check2 = (s) => ({
|
|
5529
|
+
...s,
|
|
5530
|
+
suite: "protocol",
|
|
5531
|
+
kind: "check",
|
|
5532
|
+
derived: s.derived ?? false,
|
|
5533
|
+
needsFixture: s.needsFixture ?? false
|
|
5534
|
+
});
|
|
5535
|
+
var ref4 = (revision, page, section) => ({ revision, page, section });
|
|
5536
|
+
var unscored = (kind, s) => ({
|
|
5537
|
+
...check2({ ...s, level: null }),
|
|
5538
|
+
kind
|
|
5539
|
+
});
|
|
5540
|
+
var HTTP = ["http"];
|
|
5541
|
+
var LT = "basic/transports";
|
|
5542
|
+
var MT = "basic/transports/streamable-http";
|
|
5543
|
+
var CATALOG = [
|
|
5544
|
+
// Lifecycle
|
|
5545
|
+
check2({
|
|
5546
|
+
id: "life-initialize-result",
|
|
5547
|
+
title: "initialize answers with protocolVersion, capabilities and serverInfo",
|
|
5548
|
+
description: "The result of initialize holds the protocol version the server chose, its capabilities and its serverInfo.",
|
|
5549
|
+
level: "MUST",
|
|
5550
|
+
specRefs: [ref4(L2, "basic/lifecycle", "Initialization")],
|
|
5551
|
+
eras: ["legacy"],
|
|
5552
|
+
transports: ANY
|
|
5553
|
+
}),
|
|
5554
|
+
check2({
|
|
5555
|
+
id: "life-version-negotiation",
|
|
5556
|
+
title: "The protocol version is negotiated",
|
|
5557
|
+
description: "Asked for a version it supports, the server answers with that version; asked for one it does not, with another version it supports.",
|
|
5558
|
+
level: "MUST",
|
|
5559
|
+
specRefs: [ref4(L2, "basic/lifecycle", "Version Negotiation")],
|
|
5560
|
+
eras: ["legacy"],
|
|
5561
|
+
transports: ANY
|
|
5562
|
+
}),
|
|
5563
|
+
check2({
|
|
5564
|
+
id: "life-capabilities-declared-served",
|
|
5565
|
+
title: "Every declared capability is served",
|
|
5566
|
+
description: "For each capability declared (tools, resources, prompts, logging, completions), the matching request does not answer Method not found (-32601).",
|
|
5567
|
+
level: "MUST",
|
|
5568
|
+
derived: true,
|
|
5569
|
+
derivation: "basic/lifecycle, Operation: only negotiated capabilities are used; the server pages: a server that supports a feature MUST declare its capability.",
|
|
5570
|
+
specRefs: [ref4(L2, "basic/lifecycle", "Operation")],
|
|
5571
|
+
eras: BOTH3,
|
|
5572
|
+
transports: ANY
|
|
5573
|
+
}),
|
|
5574
|
+
check2({
|
|
5575
|
+
id: "life-capabilities-served-declared",
|
|
5576
|
+
title: "Every served list is declared",
|
|
5577
|
+
description: "When tools/list, resources/list or prompts/list answers, the matching capability is declared.",
|
|
5578
|
+
level: "MUST",
|
|
5579
|
+
specRefs: [
|
|
5580
|
+
ref4(L2, "server/tools", "Capabilities"),
|
|
5581
|
+
ref4(L2, "server/resources", "Capabilities"),
|
|
5582
|
+
ref4(L2, "server/prompts", "Capabilities")
|
|
5583
|
+
],
|
|
5584
|
+
eras: BOTH3,
|
|
5585
|
+
transports: ANY
|
|
5586
|
+
}),
|
|
5587
|
+
check2({
|
|
5588
|
+
id: "life-ping-empty-result",
|
|
5589
|
+
title: "ping answers with an empty result",
|
|
5590
|
+
description: "ping is answered promptly with result: {}.",
|
|
5591
|
+
level: "MUST",
|
|
5592
|
+
specRefs: [ref4(L2, "basic/utilities/ping", "Behavior Requirements")],
|
|
5593
|
+
eras: ["legacy"],
|
|
5594
|
+
transports: ANY
|
|
5595
|
+
}),
|
|
5596
|
+
// The 2026-07-28 revision: server/discover and the per-request metadata, run first (the rest stands on discover).
|
|
5597
|
+
check2({
|
|
5598
|
+
id: "mod-discover-result",
|
|
5599
|
+
title: "server/discover answers a complete DiscoverResult",
|
|
5600
|
+
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).',
|
|
5601
|
+
level: "MUST",
|
|
5602
|
+
specRefs: [ref4(M2, "server/discover", "Discovery"), ref4(M2, "basic/versioning", "Protocol Version Negotiation")],
|
|
5603
|
+
eras: MODERN3,
|
|
5604
|
+
transports: ANY
|
|
5605
|
+
}),
|
|
5606
|
+
check2({
|
|
5607
|
+
id: "mod-discover-server-info",
|
|
5608
|
+
title: "server/discover names the server in _meta",
|
|
5609
|
+
description: 'The DiscoverResult has _meta["io.modelcontextprotocol/serverInfo"] with a name and a version.',
|
|
5610
|
+
level: "SHOULD",
|
|
5611
|
+
specRefs: [ref4(M2, "server/discover", "DiscoverResult"), ref4(M2, "basic/index", "_meta")],
|
|
5612
|
+
eras: MODERN3,
|
|
5613
|
+
transports: ANY
|
|
5614
|
+
}),
|
|
5615
|
+
check2({
|
|
5616
|
+
id: "mod-meta-required-fields",
|
|
5617
|
+
title: "A request without a required _meta field is Invalid params",
|
|
5618
|
+
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.",
|
|
5619
|
+
level: "MUST",
|
|
5620
|
+
specRefs: [ref4(M2, "basic/index", "_meta"), ref4(M2, MT, "Server Validation")],
|
|
5621
|
+
eras: MODERN3,
|
|
5622
|
+
transports: ANY
|
|
5623
|
+
}),
|
|
5624
|
+
check2({
|
|
5625
|
+
id: "mod-unsupported-version",
|
|
5626
|
+
title: "An unsupported protocol version is UnsupportedProtocolVersion",
|
|
5627
|
+
description: "server/discover for revision 1900-01-01 gets -32022 with data.supported, a non-empty list; over HTTP with status 400.",
|
|
5628
|
+
level: "MUST",
|
|
5629
|
+
specRefs: [ref4(M2, "basic/versioning", "Protocol Version Negotiation"), ref4(M2, MT, "Protocol Version Header")],
|
|
5630
|
+
eras: MODERN3,
|
|
5631
|
+
transports: ANY
|
|
5632
|
+
}),
|
|
5633
|
+
// Base protocol
|
|
5634
|
+
check2({
|
|
5635
|
+
id: "base-jsonrpc-parse-error",
|
|
5636
|
+
title: "Invalid JSON is a parse error",
|
|
5637
|
+
description: "A message that is not valid JSON gets the error -32700 with id: null.",
|
|
5638
|
+
level: "MUST",
|
|
5639
|
+
derived: true,
|
|
5640
|
+
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.",
|
|
5641
|
+
specRefs: [ref4(L2, "basic/index", "Messages")],
|
|
5642
|
+
eras: BOTH3,
|
|
5643
|
+
transports: ANY
|
|
5644
|
+
}),
|
|
5645
|
+
check2({
|
|
5646
|
+
id: "base-unknown-method-error",
|
|
5647
|
+
title: "An unknown method is Method not found",
|
|
5648
|
+
description: "A request for a method the server does not have gets the error -32601.",
|
|
5649
|
+
level: "MUST",
|
|
5650
|
+
derived: true,
|
|
5651
|
+
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.",
|
|
5652
|
+
specRefs: [ref4(L2, "basic/index", "Messages")],
|
|
5653
|
+
eras: BOTH3,
|
|
5654
|
+
transports: ANY
|
|
5655
|
+
}),
|
|
5656
|
+
check2({
|
|
5657
|
+
id: "base-response-id-matches",
|
|
5658
|
+
title: "A response carries the id of its request",
|
|
5659
|
+
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.",
|
|
5660
|
+
level: "MUST",
|
|
5661
|
+
specRefs: [ref4(L2, "basic/index", "Responses"), ref4(M2, "basic/index", "Responses")],
|
|
5662
|
+
eras: BOTH3,
|
|
5663
|
+
transports: ANY
|
|
5664
|
+
}),
|
|
5665
|
+
check2({
|
|
5666
|
+
id: "base-invalid-params-error",
|
|
5667
|
+
title: "Plainly wrong parameters are Invalid params",
|
|
5668
|
+
description: "A request with plainly wrong parameters (tools/call without name) gets -32602, not -32603 and not a result.",
|
|
5669
|
+
level: "SHOULD",
|
|
5670
|
+
specRefs: [ref4(L2, "server/tools", "Error Handling")],
|
|
5671
|
+
eras: BOTH3,
|
|
5672
|
+
transports: ANY
|
|
5673
|
+
}),
|
|
5674
|
+
// Tools
|
|
5675
|
+
check2({
|
|
5676
|
+
id: "tools-list-shape",
|
|
5677
|
+
title: "Every listed tool has a name and an inputSchema object",
|
|
5678
|
+
description: "Each entry of tools/list has a string name and an inputSchema that is an object, not null.",
|
|
5679
|
+
level: "MUST",
|
|
5680
|
+
specRefs: [ref4(L2, "server/tools", "Tool")],
|
|
5681
|
+
eras: BOTH3,
|
|
5682
|
+
transports: ANY
|
|
5683
|
+
}),
|
|
5684
|
+
check2({
|
|
5685
|
+
id: "tools-input-schema-valid",
|
|
5686
|
+
title: "Every inputSchema is a valid object schema",
|
|
5687
|
+
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.',
|
|
5688
|
+
level: "MUST",
|
|
5689
|
+
specRefs: [ref4(L2, "basic/index", "JSON Schema Usage")],
|
|
5690
|
+
eras: BOTH3,
|
|
5691
|
+
transports: ANY
|
|
5692
|
+
}),
|
|
5693
|
+
check2({
|
|
5694
|
+
id: "tools-output-schema-valid",
|
|
5695
|
+
title: "Every outputSchema is a valid schema",
|
|
5696
|
+
description: "An outputSchema, when given, is valid in its dialect; before 2026-07-28 its root is an object, from then on any type.",
|
|
5697
|
+
level: "MUST",
|
|
5698
|
+
specRefs: [ref4(L2, "server/tools", "Output Schema"), ref4(M2, "changelog", "Minor changes")],
|
|
5699
|
+
eras: BOTH3,
|
|
5700
|
+
transports: ANY
|
|
5701
|
+
}),
|
|
5702
|
+
check2({
|
|
5703
|
+
id: "tools-structured-conformant",
|
|
5704
|
+
title: "structuredContent conforms to the outputSchema",
|
|
5705
|
+
description: "The structuredContent of a call (from the fixture) conforms to the tool's outputSchema.",
|
|
5706
|
+
level: "MUST",
|
|
5707
|
+
specRefs: [ref4(L2, "server/tools", "Output Schema")],
|
|
5708
|
+
eras: BOTH3,
|
|
5709
|
+
transports: ANY,
|
|
5710
|
+
needsFixture: true
|
|
5711
|
+
}),
|
|
5712
|
+
check2({
|
|
5713
|
+
id: "tools-structured-has-text",
|
|
5714
|
+
title: "structuredContent is also given as text",
|
|
5715
|
+
description: "A result with structuredContent also has a text block with the serialized JSON.",
|
|
5716
|
+
level: "SHOULD",
|
|
5717
|
+
specRefs: [ref4(L2, "server/tools", "Structured Content")],
|
|
5718
|
+
eras: BOTH3,
|
|
5719
|
+
transports: ANY,
|
|
5720
|
+
needsFixture: true
|
|
5721
|
+
}),
|
|
5722
|
+
check2({
|
|
5723
|
+
id: "tools-name-format",
|
|
5724
|
+
title: "Tool names use the allowed characters",
|
|
5725
|
+
description: "Each tool name is 1 to 128 characters of A-Z, a-z, 0-9, _, - and ., without spaces or commas.",
|
|
5726
|
+
level: "SHOULD",
|
|
5727
|
+
specRefs: [ref4(L2, "server/tools", "Tool Names")],
|
|
5728
|
+
eras: BOTH3,
|
|
5729
|
+
transports: ANY
|
|
5730
|
+
}),
|
|
5731
|
+
check2({
|
|
5732
|
+
id: "tools-name-unique",
|
|
5733
|
+
title: "Tool names are unique",
|
|
5734
|
+
description: "No two tools of the server share a name, across every page of tools/list.",
|
|
5735
|
+
level: "SHOULD",
|
|
5736
|
+
specRefs: [ref4(L2, "server/tools", "Tool Names")],
|
|
5737
|
+
eras: BOTH3,
|
|
5738
|
+
transports: ANY
|
|
5739
|
+
}),
|
|
5740
|
+
check2({
|
|
5741
|
+
id: "tools-call-unknown-error",
|
|
5742
|
+
title: "Calling an unknown tool is a protocol error",
|
|
5743
|
+
description: "tools/call for a tool that does not exist gets a JSON-RPC error, not a result with isError.",
|
|
5744
|
+
level: "SHOULD",
|
|
5745
|
+
specRefs: [ref4(L2, "server/tools", "Error Handling")],
|
|
5746
|
+
eras: BOTH3,
|
|
5747
|
+
transports: ANY
|
|
5748
|
+
}),
|
|
5749
|
+
check2({
|
|
5750
|
+
id: "tools-list-order-stable",
|
|
5751
|
+
title: "tools/list keeps its order",
|
|
5752
|
+
description: "Two calls of tools/list give the tools in the same order.",
|
|
5753
|
+
level: "SHOULD",
|
|
5754
|
+
specRefs: [ref4(M2, "server/tools", "Capabilities")],
|
|
5755
|
+
eras: ["modern"],
|
|
5756
|
+
transports: ANY
|
|
5757
|
+
}),
|
|
5758
|
+
// Resources
|
|
5759
|
+
check2({
|
|
5760
|
+
id: "resources-list-shape",
|
|
5761
|
+
title: "Every listed resource has a uri and a name",
|
|
5762
|
+
description: "Each entry of resources/list has uri and name.",
|
|
5763
|
+
level: "MUST",
|
|
5764
|
+
derived: true,
|
|
5765
|
+
derivation: 'server/resources, Resource: uri and name are listed without "Optional"; no keyword.',
|
|
5766
|
+
specRefs: [ref4(L2, "server/resources", "Resource")],
|
|
5767
|
+
eras: BOTH3,
|
|
5768
|
+
transports: ANY
|
|
5769
|
+
}),
|
|
5770
|
+
check2({
|
|
5771
|
+
id: "resources-read-listed",
|
|
5772
|
+
title: "A listed resource can be read",
|
|
5773
|
+
description: "resources/read of the first listed resource answers with contents, each with a uri and exactly one of text and blob.",
|
|
5774
|
+
level: "MUST",
|
|
5775
|
+
derived: true,
|
|
5776
|
+
derivation: "server/resources, Resource Contents: a content is text or binary data under its uri; no keyword.",
|
|
5777
|
+
specRefs: [ref4(L2, "server/resources", "Resource Contents")],
|
|
5778
|
+
eras: BOTH3,
|
|
5779
|
+
transports: ANY
|
|
5780
|
+
}),
|
|
5781
|
+
check2({
|
|
5782
|
+
id: "resources-read-not-found",
|
|
5783
|
+
title: "Reading an unknown resource is an error",
|
|
5784
|
+
description: "resources/read of a uri that does not exist gets -32002, not empty contents.",
|
|
5785
|
+
level: "SHOULD",
|
|
5786
|
+
specRefs: [ref4(L2, "server/resources", "Error Handling")],
|
|
5787
|
+
eras: ["legacy"],
|
|
5788
|
+
transports: ANY
|
|
5789
|
+
}),
|
|
5790
|
+
check2({
|
|
5791
|
+
id: "resources-templates-shape",
|
|
5792
|
+
title: "Every resource template has a uriTemplate and a name",
|
|
5793
|
+
description: "Each entry of resources/templates/list has uriTemplate and name.",
|
|
5794
|
+
level: "MUST",
|
|
5795
|
+
derived: true,
|
|
5796
|
+
derivation: "server/resources, Resource Templates: every example template has uriTemplate and name; no keyword.",
|
|
5797
|
+
specRefs: [ref4(L2, "server/resources", "Resource Templates")],
|
|
5798
|
+
eras: BOTH3,
|
|
5799
|
+
transports: ANY
|
|
5800
|
+
}),
|
|
5801
|
+
// Prompts
|
|
5802
|
+
check2({
|
|
5803
|
+
id: "prompts-list-shape",
|
|
5804
|
+
title: "Every listed prompt has a name",
|
|
5805
|
+
description: "Each entry of prompts/list has name; arguments, when given, is a list of objects with name.",
|
|
5806
|
+
level: "MUST",
|
|
5807
|
+
derived: true,
|
|
5808
|
+
derivation: 'server/prompts, Prompt: name is listed without "Optional", arguments is optional; no keyword.',
|
|
5809
|
+
specRefs: [ref4(L2, "server/prompts", "Prompt")],
|
|
5810
|
+
eras: BOTH3,
|
|
5811
|
+
transports: ANY
|
|
5812
|
+
}),
|
|
5813
|
+
check2({
|
|
5814
|
+
id: "prompts-get-unknown-error",
|
|
5815
|
+
title: "Getting an unknown prompt is an error",
|
|
5816
|
+
description: "prompts/get with a name that does not exist gets a JSON-RPC error.",
|
|
5817
|
+
level: "SHOULD",
|
|
5818
|
+
specRefs: [ref4(L2, "server/prompts", "Error Handling")],
|
|
5819
|
+
eras: BOTH3,
|
|
5820
|
+
transports: ANY
|
|
5821
|
+
}),
|
|
5822
|
+
// Pagination
|
|
5823
|
+
check2({
|
|
5824
|
+
id: "pagination-walk-complete",
|
|
5825
|
+
title: "Paging through a list ends, without repeats",
|
|
5826
|
+
description: "Following nextCursor ends within the page limit and no entry comes back on a later page.",
|
|
5827
|
+
level: "SHOULD",
|
|
5828
|
+
specRefs: [ref4(L2, "server/utilities/pagination", "Implementation Guidelines")],
|
|
5829
|
+
eras: BOTH3,
|
|
5830
|
+
transports: ANY
|
|
5831
|
+
}),
|
|
5832
|
+
check2({
|
|
5833
|
+
id: "pagination-invalid-cursor",
|
|
5834
|
+
title: "An invalid cursor is Invalid params",
|
|
5835
|
+
description: "A list request with a cursor the server never gave gets -32602.",
|
|
5836
|
+
level: "SHOULD",
|
|
5837
|
+
specRefs: [ref4(L2, "server/utilities/pagination", "Error Handling")],
|
|
5838
|
+
eras: BOTH3,
|
|
5839
|
+
transports: ANY
|
|
5840
|
+
}),
|
|
5841
|
+
// Utilities
|
|
5842
|
+
check2({
|
|
5843
|
+
id: "logging-set-level",
|
|
5844
|
+
title: "logging/setLevel is accepted when logging is declared",
|
|
5845
|
+
description: "A server that declares logging accepts logging/setLevel.",
|
|
5846
|
+
level: "SHOULD",
|
|
5847
|
+
derived: true,
|
|
5848
|
+
derivation: "server/utilities/logging: the MUST is on declaring the capability, not on handling logging/setLevel, so handling it is a SHOULD.",
|
|
5849
|
+
specRefs: [ref4(L2, "server/utilities/logging", "Capabilities")],
|
|
5850
|
+
eras: ["legacy"],
|
|
5851
|
+
transports: ANY
|
|
5852
|
+
}),
|
|
5853
|
+
check2({
|
|
5854
|
+
id: "completion-complete",
|
|
5855
|
+
title: "completion/complete answers when completions is declared",
|
|
5856
|
+
description: "A server that declares completions answers completion/complete with a valid result.",
|
|
5857
|
+
level: "SHOULD",
|
|
5858
|
+
derived: true,
|
|
5859
|
+
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.",
|
|
5860
|
+
specRefs: [ref4(L2, "server/utilities/completion", "Capabilities")],
|
|
5861
|
+
eras: BOTH3,
|
|
5862
|
+
transports: ANY
|
|
5863
|
+
}),
|
|
5864
|
+
// The 2026-07-28 revision: what changed for every transport.
|
|
5865
|
+
check2({
|
|
5866
|
+
id: "mod-removed-methods",
|
|
5867
|
+
title: "The methods the revision removed are Method not found",
|
|
5868
|
+
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.",
|
|
5869
|
+
level: "MUST",
|
|
5870
|
+
derived: true,
|
|
5871
|
+
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.",
|
|
5872
|
+
specRefs: [ref4(M2, "changelog", "Major changes"), ref4(M2, MT, "Protocol Version Header")],
|
|
5873
|
+
eras: MODERN3,
|
|
5874
|
+
transports: ANY
|
|
5875
|
+
}),
|
|
5876
|
+
check2({
|
|
5877
|
+
id: "mod-stateless-no-prior-context",
|
|
5878
|
+
title: "A list answers on a fresh connection with no request before it",
|
|
5879
|
+
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.",
|
|
5880
|
+
level: "MUST",
|
|
5881
|
+
specRefs: [ref4(M2, "basic/index", "Statelessness")],
|
|
5882
|
+
eras: MODERN3,
|
|
5883
|
+
transports: ANY
|
|
5884
|
+
}),
|
|
5885
|
+
check2({
|
|
5886
|
+
id: "mod-list-stable-across-connections",
|
|
5887
|
+
title: "The lists do not vary per connection",
|
|
5888
|
+
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.",
|
|
5889
|
+
level: "MUST",
|
|
5890
|
+
specRefs: [
|
|
5891
|
+
ref4(M2, "server/tools", "Capabilities"),
|
|
5892
|
+
ref4(M2, "server/prompts", "Capabilities"),
|
|
5893
|
+
ref4(M2, "server/resources", "Capabilities")
|
|
5894
|
+
],
|
|
5895
|
+
eras: MODERN3,
|
|
5896
|
+
transports: ANY
|
|
5897
|
+
}),
|
|
5898
|
+
check2({
|
|
5899
|
+
id: "mod-resource-not-found",
|
|
5900
|
+
title: "Reading an unknown resource is Invalid params",
|
|
5901
|
+
description: "resources/read of a uri that does not exist gets -32602; -32002, the code of earlier revisions, fails.",
|
|
5902
|
+
level: "MUST",
|
|
5903
|
+
specRefs: [ref4(M2, "server/resources", "Error Handling"), ref4(M2, "basic/index", "Error Codes")],
|
|
5904
|
+
eras: MODERN3,
|
|
5905
|
+
transports: ANY
|
|
5906
|
+
}),
|
|
5907
|
+
check2({
|
|
5908
|
+
id: "mod-resource-no-empty-contents",
|
|
5909
|
+
title: "An unknown resource is not empty contents",
|
|
5910
|
+
description: "resources/read of a uri that does not exist does not answer a result with an empty contents list.",
|
|
5911
|
+
level: "MUST",
|
|
5912
|
+
specRefs: [ref4(M2, "server/resources", "Error Handling")],
|
|
5913
|
+
eras: MODERN3,
|
|
5914
|
+
transports: ANY
|
|
5915
|
+
}),
|
|
5916
|
+
check2({
|
|
5917
|
+
id: "mod-cache-hints-coverage",
|
|
5918
|
+
title: "Every cacheable result has ttlMs and cacheScope",
|
|
5919
|
+
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.",
|
|
5920
|
+
level: "MUST",
|
|
5921
|
+
specRefs: [ref4(M2, "server/utilities/caching", "Cacheable Results")],
|
|
5922
|
+
eras: MODERN3,
|
|
5923
|
+
transports: ANY
|
|
5924
|
+
}),
|
|
5925
|
+
check2({
|
|
5926
|
+
id: "mod-cache-ttl-valid",
|
|
5927
|
+
title: "ttlMs is an integer of at least 0",
|
|
5928
|
+
description: "Every ttlMs on those results is an integer number of milliseconds, 0 or more.",
|
|
5929
|
+
level: "MUST",
|
|
5930
|
+
specRefs: [ref4(M2, "server/utilities/caching", "Time-to-Live (TTL) Field")],
|
|
5931
|
+
eras: MODERN3,
|
|
5932
|
+
transports: ANY
|
|
5933
|
+
}),
|
|
5934
|
+
check2({
|
|
5935
|
+
id: "mod-cache-scope-valid",
|
|
5936
|
+
title: 'cacheScope is "public" or "private"',
|
|
5937
|
+
description: 'Every cacheScope on those results is exactly "public" or "private".',
|
|
5938
|
+
level: "MUST",
|
|
5939
|
+
derived: true,
|
|
5940
|
+
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.',
|
|
5941
|
+
specRefs: [ref4(M2, "server/utilities/caching", "Cache Scope Field")],
|
|
5942
|
+
eras: MODERN3,
|
|
5943
|
+
transports: ANY
|
|
5944
|
+
}),
|
|
5945
|
+
check2({
|
|
5946
|
+
id: "mod-cache-scope-stable-pages",
|
|
5947
|
+
title: "All pages of a list have the same cacheScope",
|
|
5948
|
+
description: "Every page of a paginated list carries the cacheScope of its first page. Without a list of two pages, not-applicable.",
|
|
5949
|
+
level: "MUST",
|
|
5950
|
+
specRefs: [ref4(M2, "server/utilities/caching", "Interaction with Pagination")],
|
|
5951
|
+
eras: MODERN3,
|
|
5952
|
+
transports: ANY
|
|
5953
|
+
}),
|
|
5954
|
+
check2({
|
|
5955
|
+
id: "mod-undeclared-capability",
|
|
5956
|
+
title: "A capability the client did not declare is asked for with -32021",
|
|
5957
|
+
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).',
|
|
5958
|
+
level: "MUST",
|
|
5959
|
+
specRefs: [ref4(M2, "basic/index", "_meta")],
|
|
5960
|
+
eras: MODERN3,
|
|
5961
|
+
transports: ANY,
|
|
5962
|
+
needsFixture: true
|
|
5963
|
+
}),
|
|
5964
|
+
// Subscriptions: one subscriptions/listen per run, watched for a short time and then cancelled.
|
|
5965
|
+
check2({
|
|
5966
|
+
id: "mod-sub-ack-first",
|
|
5967
|
+
title: "A subscription is acknowledged first",
|
|
5968
|
+
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.",
|
|
5969
|
+
level: "MUST",
|
|
5970
|
+
specRefs: [ref4(M2, "basic/patterns/subscriptions", "Acknowledgment")],
|
|
5971
|
+
eras: MODERN3,
|
|
5972
|
+
transports: ANY
|
|
5973
|
+
}),
|
|
5974
|
+
check2({
|
|
5975
|
+
id: "mod-sub-filter-and-tag",
|
|
5976
|
+
title: "A subscription gets only what it asked for, each tagged",
|
|
5977
|
+
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).",
|
|
5978
|
+
level: "MUST",
|
|
5979
|
+
specRefs: [ref4(M2, "basic/patterns/subscriptions", "Opening a Stream"), ref4(M2, "basic/index", "_meta")],
|
|
5980
|
+
eras: MODERN3,
|
|
5981
|
+
transports: ANY
|
|
5982
|
+
}),
|
|
5983
|
+
check2({
|
|
5984
|
+
id: "mod-sub-graceful-close",
|
|
5985
|
+
title: "A subscription the server ends gets a successful response",
|
|
5986
|
+
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).",
|
|
5987
|
+
level: "SHOULD",
|
|
5988
|
+
specRefs: [ref4(M2, "basic/patterns/subscriptions", "Graceful Closure")],
|
|
5989
|
+
eras: MODERN3,
|
|
5990
|
+
transports: ANY
|
|
5991
|
+
}),
|
|
5992
|
+
// Streamable HTTP on the wire: raw requests, never an MCP client (../raw-http.ts).
|
|
5993
|
+
check2({
|
|
5994
|
+
id: "http-notification-202",
|
|
5995
|
+
title: "A notification POST is 202 with no body, or an error status",
|
|
5996
|
+
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.",
|
|
5997
|
+
level: "MUST",
|
|
5998
|
+
specRefs: [ref4(L2, LT, "Sending Messages to the Server"), ref4(M2, MT, "Sending Messages")],
|
|
5999
|
+
eras: BOTH3,
|
|
6000
|
+
transports: HTTP
|
|
6001
|
+
}),
|
|
6002
|
+
check2({
|
|
6003
|
+
id: "http-request-content-type",
|
|
6004
|
+
title: "A request is answered as application/json or text/event-stream",
|
|
6005
|
+
description: "The answer to a JSON-RPC request has Content-Type application/json or text/event-stream.",
|
|
6006
|
+
level: "MUST",
|
|
6007
|
+
specRefs: [ref4(L2, LT, "Sending Messages to the Server"), ref4(M2, MT, "Sending Messages")],
|
|
6008
|
+
eras: BOTH3,
|
|
6009
|
+
transports: HTTP
|
|
6010
|
+
}),
|
|
6011
|
+
check2({
|
|
6012
|
+
id: "http-response-utf8",
|
|
6013
|
+
title: "The answer is UTF-8 JSON",
|
|
6014
|
+
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.",
|
|
6015
|
+
level: "MUST",
|
|
6016
|
+
specRefs: [ref4(L2, LT, "Transports")],
|
|
6017
|
+
eras: BOTH3,
|
|
6018
|
+
transports: HTTP
|
|
6019
|
+
}),
|
|
6020
|
+
check2({
|
|
6021
|
+
id: "http-single-endpoint",
|
|
6022
|
+
title: "The MCP endpoint takes POST",
|
|
6023
|
+
description: "The URL under test takes a valid JSON-RPC request by POST: not 404 (other than a JSON-RPC -32601) and not 405.",
|
|
6024
|
+
level: "MUST",
|
|
6025
|
+
specRefs: [ref4(L2, LT, "Streamable HTTP"), ref4(M2, MT, "Streamable HTTP")],
|
|
6026
|
+
eras: BOTH3,
|
|
6027
|
+
transports: HTTP
|
|
6028
|
+
}),
|
|
6029
|
+
check2({
|
|
6030
|
+
id: "http-get-stream-or-405",
|
|
6031
|
+
title: "GET opens an SSE stream or is 405",
|
|
6032
|
+
description: "A GET with Accept: text/event-stream gets Content-Type text/event-stream or 405 Method Not Allowed.",
|
|
6033
|
+
level: "MUST",
|
|
6034
|
+
specRefs: [ref4(L2, LT, "Listening for Messages from the Server")],
|
|
6035
|
+
eras: ["legacy"],
|
|
6036
|
+
transports: HTTP
|
|
6037
|
+
}),
|
|
6038
|
+
check2({
|
|
6039
|
+
id: "http-modern-get-delete-405",
|
|
6040
|
+
title: "A modern-only server answers GET and DELETE with 405",
|
|
6041
|
+
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.",
|
|
6042
|
+
level: "SHOULD",
|
|
6043
|
+
specRefs: [ref4(M2, MT, "Earlier Streamable HTTP Revisions")],
|
|
6044
|
+
eras: ["modern"],
|
|
6045
|
+
transports: HTTP
|
|
6046
|
+
}),
|
|
6047
|
+
check2({
|
|
6048
|
+
id: "http-session-id-visible-ascii",
|
|
6049
|
+
title: "A session id is visible ASCII",
|
|
6050
|
+
description: "An MCP-Session-Id the server assigns holds only characters 0x21 to 0x7E. Without one, not-applicable.",
|
|
6051
|
+
level: "MUST",
|
|
6052
|
+
specRefs: [ref4(L2, LT, "Session Management")],
|
|
6053
|
+
eras: ["legacy"],
|
|
6054
|
+
transports: HTTP
|
|
6055
|
+
}),
|
|
6056
|
+
check2({
|
|
6057
|
+
id: "http-session-required-400",
|
|
6058
|
+
title: "A request without the session id is 400",
|
|
6059
|
+
description: "When the server assigned a session id, a request other than initialize without MCP-Session-Id gets 400 Bad Request.",
|
|
6060
|
+
level: "SHOULD",
|
|
6061
|
+
specRefs: [ref4(L2, LT, "Session Management")],
|
|
6062
|
+
eras: ["legacy"],
|
|
6063
|
+
transports: HTTP
|
|
6064
|
+
}),
|
|
6065
|
+
check2({
|
|
6066
|
+
id: "http-protocol-version-header-invalid-400",
|
|
6067
|
+
title: "An invalid MCP-Protocol-Version is 400",
|
|
6068
|
+
description: "A request after initialize with an MCP-Protocol-Version that is not a revision gets 400 Bad Request.",
|
|
6069
|
+
level: "MUST",
|
|
6070
|
+
specRefs: [ref4(L2, LT, "Protocol Version Header")],
|
|
6071
|
+
eras: ["legacy"],
|
|
6072
|
+
transports: HTTP
|
|
6073
|
+
}),
|
|
6074
|
+
check2({
|
|
6075
|
+
id: "http-concurrent-posts-matched",
|
|
6076
|
+
title: "Concurrent POSTs each get their own answer",
|
|
6077
|
+
description: "Several POSTs sent at once, each with its own id, are each answered with the id of their request.",
|
|
6078
|
+
level: "MUST",
|
|
6079
|
+
derived: true,
|
|
6080
|
+
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.",
|
|
6081
|
+
specRefs: [ref4(L2, LT, "Sending Messages to the Server"), ref4(M2, "basic/index", "Responses")],
|
|
6082
|
+
eras: BOTH3,
|
|
6083
|
+
transports: HTTP
|
|
6084
|
+
}),
|
|
6085
|
+
check2({
|
|
6086
|
+
id: "http-sse-event-ids-unique",
|
|
6087
|
+
title: "SSE event ids are unique in the session",
|
|
6088
|
+
description: "When the server gives SSE events an id, no id comes back twice across the streams of the session. Without ids, not-applicable.",
|
|
6089
|
+
level: "MUST",
|
|
6090
|
+
specRefs: [ref4(L2, LT, "Resumability and Redelivery")],
|
|
6091
|
+
eras: ["legacy"],
|
|
6092
|
+
transports: HTTP
|
|
6093
|
+
}),
|
|
6094
|
+
check2({
|
|
6095
|
+
id: "http-sse-stream-closes",
|
|
6096
|
+
title: "The SSE stream of a request ends after its response",
|
|
6097
|
+
description: "When a request is answered over SSE, the server closes the stream once the response is sent.",
|
|
6098
|
+
level: "SHOULD",
|
|
6099
|
+
specRefs: [ref4(L2, LT, "Sending Messages to the Server"), ref4(M2, MT, "Receiving Messages")],
|
|
6100
|
+
eras: BOTH3,
|
|
6101
|
+
transports: HTTP
|
|
6102
|
+
}),
|
|
6103
|
+
check2({
|
|
6104
|
+
id: "http-sse-no-server-requests",
|
|
6105
|
+
title: "The SSE stream of a request holds no request of the server",
|
|
6106
|
+
description: "The SSE answer to a request holds its response and notifications, never a JSON-RPC request of the server.",
|
|
6107
|
+
level: "MUST",
|
|
6108
|
+
specRefs: [ref4(M2, MT, "Receiving Messages")],
|
|
6109
|
+
eras: ["modern"],
|
|
6110
|
+
transports: HTTP
|
|
6111
|
+
}),
|
|
6112
|
+
check2({
|
|
6113
|
+
id: "http-accel-buffering-header",
|
|
6114
|
+
title: "An SSE answer sends X-Accel-Buffering: no",
|
|
6115
|
+
description: "A response that opens an SSE stream has the header X-Accel-Buffering: no.",
|
|
6116
|
+
level: "SHOULD",
|
|
6117
|
+
specRefs: [ref4(M2, MT, "Receiving Messages")],
|
|
6118
|
+
eras: ["modern"],
|
|
6119
|
+
transports: HTTP
|
|
6120
|
+
}),
|
|
6121
|
+
check2({
|
|
6122
|
+
id: "http-close-cancels",
|
|
6123
|
+
title: "Closing the SSE stream cancels the request",
|
|
6124
|
+
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).",
|
|
6125
|
+
level: "MUST",
|
|
6126
|
+
specRefs: [ref4(M2, MT, "Cancellation")],
|
|
6127
|
+
eras: ["modern"],
|
|
6128
|
+
transports: HTTP,
|
|
6129
|
+
needsFixture: true
|
|
6130
|
+
}),
|
|
6131
|
+
// The request headers of the 2026-07-28 revision, each probe a POST of its own.
|
|
6132
|
+
check2({
|
|
6133
|
+
id: "mod-unimplemented-method",
|
|
6134
|
+
title: "An unknown method over HTTP is 404 with -32601",
|
|
6135
|
+
description: "A POST of a method the server does not implement gets 404 Not Found and the JSON-RPC error -32601.",
|
|
6136
|
+
level: "MUST",
|
|
6137
|
+
specRefs: [ref4(M2, MT, "Protocol Version Header")],
|
|
6138
|
+
eras: MODERN3,
|
|
6139
|
+
transports: HTTP
|
|
6140
|
+
}),
|
|
6141
|
+
check2({
|
|
6142
|
+
id: "mod-header-protocol-version-mismatch",
|
|
6143
|
+
title: "An MCP-Protocol-Version unlike the body is HeaderMismatch",
|
|
6144
|
+
description: "server/discover with MCP-Protocol-Version: 2025-11-25 and 2026-07-28 in _meta gets 400 and -32020.",
|
|
6145
|
+
level: "MUST",
|
|
6146
|
+
specRefs: [ref4(M2, MT, "Protocol Version Header"), ref4(M2, MT, "Server Validation")],
|
|
6147
|
+
eras: MODERN3,
|
|
6148
|
+
transports: HTTP
|
|
6149
|
+
}),
|
|
6150
|
+
check2({
|
|
6151
|
+
id: "mod-header-method-mismatch",
|
|
6152
|
+
title: "An Mcp-Method unlike the body is HeaderMismatch",
|
|
6153
|
+
description: "server/discover sent with Mcp-Method: tools/list gets 400 and -32020.",
|
|
6154
|
+
level: "MUST",
|
|
6155
|
+
specRefs: [ref4(M2, MT, "Server Validation")],
|
|
6156
|
+
eras: MODERN3,
|
|
6157
|
+
transports: HTTP
|
|
6158
|
+
}),
|
|
6159
|
+
check2({
|
|
6160
|
+
id: "mod-header-name-mismatch",
|
|
6161
|
+
title: "An Mcp-Name unlike the body is HeaderMismatch",
|
|
6162
|
+
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.",
|
|
6163
|
+
level: "MUST",
|
|
6164
|
+
specRefs: [ref4(M2, MT, "Standard Request Headers"), ref4(M2, MT, "Server Validation"), ref4(M2, MT, "Case Sensitivity")],
|
|
6165
|
+
eras: MODERN3,
|
|
6166
|
+
transports: HTTP
|
|
6167
|
+
}),
|
|
6168
|
+
check2({
|
|
6169
|
+
id: "mod-header-missing-rejected",
|
|
6170
|
+
title: "A request without a required header is HeaderMismatch",
|
|
6171
|
+
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.",
|
|
6172
|
+
level: "MUST",
|
|
6173
|
+
specRefs: [ref4(M2, MT, "Server Validation"), ref4(M2, MT, "Standard Request Headers"), ref4(M2, MT, "Protocol Version Header")],
|
|
6174
|
+
eras: MODERN3,
|
|
6175
|
+
transports: HTTP
|
|
6176
|
+
}),
|
|
6177
|
+
check2({
|
|
6178
|
+
id: "mod-header-names-case-insensitive",
|
|
6179
|
+
title: "Header names are read in any case",
|
|
6180
|
+
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.",
|
|
6181
|
+
level: "MUST",
|
|
6182
|
+
specRefs: [ref4(M2, MT, "Case Sensitivity")],
|
|
6183
|
+
eras: MODERN3,
|
|
6184
|
+
transports: HTTP
|
|
6185
|
+
}),
|
|
6186
|
+
check2({
|
|
6187
|
+
id: "mod-header-name-base64-decoded",
|
|
6188
|
+
title: "A Base64 Mcp-Name is decoded before it is compared",
|
|
6189
|
+
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.",
|
|
6190
|
+
level: "MUST",
|
|
6191
|
+
specRefs: [ref4(M2, MT, "Value Encoding")],
|
|
6192
|
+
eras: MODERN3,
|
|
6193
|
+
transports: HTTP
|
|
6194
|
+
}),
|
|
6195
|
+
check2({
|
|
6196
|
+
id: "mod-param-header-mismatch",
|
|
6197
|
+
title: "An Mcp-Param header unlike the body, or missing, is HeaderMismatch",
|
|
6198
|
+
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.",
|
|
6199
|
+
level: "MUST",
|
|
6200
|
+
specRefs: [ref4(M2, MT, "Server Behavior for Custom Headers")],
|
|
6201
|
+
eras: MODERN3,
|
|
6202
|
+
transports: HTTP,
|
|
6203
|
+
needsFixture: true
|
|
6204
|
+
}),
|
|
6205
|
+
check2({
|
|
6206
|
+
id: "mod-x-mcp-header-declarations",
|
|
6207
|
+
title: "Every x-mcp-header declaration is valid",
|
|
6208
|
+
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.",
|
|
6209
|
+
level: "MUST",
|
|
6210
|
+
specRefs: [ref4(M2, "server/tools", "x-mcp-header"), ref4(M2, MT, "Schema Extension")],
|
|
6211
|
+
eras: MODERN3,
|
|
6212
|
+
transports: HTTP
|
|
6213
|
+
}),
|
|
6214
|
+
check2({
|
|
6215
|
+
id: "mod-no-session-id",
|
|
6216
|
+
title: "A modern-only server neither mints nor echoes a session id",
|
|
6217
|
+
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.",
|
|
6218
|
+
level: "SHOULD",
|
|
6219
|
+
specRefs: [ref4(M2, MT, "Earlier Streamable HTTP Revisions")],
|
|
6220
|
+
eras: MODERN3,
|
|
6221
|
+
transports: HTTP
|
|
6222
|
+
}),
|
|
6223
|
+
// These two change the server's state, each in a session of its own made for it, so they come last.
|
|
6224
|
+
check2({
|
|
6225
|
+
id: "http-session-terminated-404",
|
|
6226
|
+
title: "A terminated session is 404",
|
|
6227
|
+
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.",
|
|
6228
|
+
level: "MUST",
|
|
6229
|
+
specRefs: [ref4(L2, LT, "Session Management")],
|
|
6230
|
+
eras: ["legacy"],
|
|
6231
|
+
transports: HTTP
|
|
6232
|
+
}),
|
|
6233
|
+
check2({
|
|
6234
|
+
id: "http-sse-no-broadcast",
|
|
6235
|
+
title: "A message goes to one SSE stream, not to each",
|
|
6236
|
+
description: "With two GET streams open, a message of the server (made by the first --fixture call) arrives on one of them only.",
|
|
6237
|
+
level: "MUST",
|
|
6238
|
+
specRefs: [ref4(L2, LT, "Multiple Connections")],
|
|
6239
|
+
eras: ["legacy"],
|
|
6240
|
+
transports: HTTP,
|
|
6241
|
+
needsFixture: true
|
|
6242
|
+
}),
|
|
6243
|
+
// A local server against DNS rebinding: only for localhost, 127.0.0.1, [::1] and *.localhost.
|
|
6244
|
+
check2({
|
|
6245
|
+
id: "http-origin-invalid-403",
|
|
6246
|
+
title: "A foreign Origin is refused with 403",
|
|
6247
|
+
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).",
|
|
6248
|
+
level: "MUST",
|
|
6249
|
+
specRefs: [ref4(L2, LT, "Security Warning"), ref4(M2, MT, "Security & Endpoint")],
|
|
6250
|
+
eras: BOTH3,
|
|
6251
|
+
transports: HTTP
|
|
6252
|
+
}),
|
|
6253
|
+
unscored("control", {
|
|
6254
|
+
id: "http-origin-localhost-accepted",
|
|
6255
|
+
title: "An Origin of localhost is accepted",
|
|
6256
|
+
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.",
|
|
6257
|
+
specRefs: [ref4(L2, LT, "Security Warning"), ref4(M2, MT, "Security & Endpoint")],
|
|
6258
|
+
eras: BOTH3,
|
|
6259
|
+
transports: HTTP
|
|
6260
|
+
}),
|
|
6261
|
+
unscored("control", {
|
|
6262
|
+
id: "http-origin-absent-accepted",
|
|
6263
|
+
title: "A request without Origin is accepted",
|
|
6264
|
+
description: "A request with no Origin (not from a browser) is accepted: the specification speaks only of an Origin that is present and invalid.",
|
|
6265
|
+
specRefs: [ref4(L2, LT, "Security Warning"), ref4(M2, MT, "Security & Endpoint")],
|
|
6266
|
+
eras: BOTH3,
|
|
6267
|
+
transports: HTTP
|
|
6268
|
+
}),
|
|
6269
|
+
check2({
|
|
6270
|
+
id: "http-bind-loopback",
|
|
6271
|
+
title: "A local server listens on loopback only",
|
|
6272
|
+
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).",
|
|
6273
|
+
level: "SHOULD",
|
|
6274
|
+
specRefs: [ref4(L2, LT, "Security Warning"), ref4(M2, MT, "Security & Endpoint")],
|
|
6275
|
+
eras: BOTH3,
|
|
6276
|
+
transports: HTTP
|
|
6277
|
+
}),
|
|
6278
|
+
unscored("advice", {
|
|
6279
|
+
id: "http-host-rebinding-advice",
|
|
6280
|
+
title: "A foreign Host is refused (advice outside the specification)",
|
|
6281
|
+
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.",
|
|
6282
|
+
specRefs: [ref4(L2, LT, "Security Warning"), ref4(M2, MT, "Security & Endpoint")],
|
|
6283
|
+
eras: BOTH3,
|
|
6284
|
+
transports: HTTP
|
|
6285
|
+
}),
|
|
6286
|
+
// The 2026-07-28 revision over the whole run: these read every message the run got back, so they come after the rest.
|
|
6287
|
+
check2({
|
|
6288
|
+
id: "mod-result-type-present",
|
|
6289
|
+
title: "Every result has a known resultType",
|
|
6290
|
+
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.',
|
|
6291
|
+
level: "MUST",
|
|
6292
|
+
specRefs: [ref4(M2, "basic/index", "ResultType")],
|
|
6293
|
+
eras: MODERN3,
|
|
6294
|
+
transports: ANY
|
|
6295
|
+
}),
|
|
6296
|
+
check2({
|
|
6297
|
+
id: "mod-error-code-range",
|
|
6298
|
+
title: "No error code of the reserved range is invented",
|
|
6299
|
+
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.",
|
|
6300
|
+
level: "MUST",
|
|
6301
|
+
specRefs: [ref4(M2, "basic/index", "Error Codes")],
|
|
6302
|
+
eras: MODERN3,
|
|
6303
|
+
transports: ANY
|
|
6304
|
+
}),
|
|
6305
|
+
check2({
|
|
6306
|
+
id: "mod-logs-need-log-level",
|
|
6307
|
+
title: "No log message for a request without logLevel",
|
|
6308
|
+
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.",
|
|
6309
|
+
level: "MUST",
|
|
6310
|
+
specRefs: [ref4(M2, "server/utilities/logging", "Per-request log level")],
|
|
6311
|
+
eras: MODERN3,
|
|
6312
|
+
transports: ANY
|
|
6313
|
+
}),
|
|
6314
|
+
check2({
|
|
6315
|
+
id: "mod-wire-schema-valid",
|
|
6316
|
+
title: "Every message conforms to the schema of the revision",
|
|
6317
|
+
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.",
|
|
6318
|
+
level: "MUST",
|
|
6319
|
+
derived: true,
|
|
6320
|
+
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.",
|
|
6321
|
+
specRefs: [ref4(M2, "basic/index", "Schema")],
|
|
6322
|
+
eras: MODERN3,
|
|
6323
|
+
transports: ANY
|
|
6324
|
+
}),
|
|
6325
|
+
// stdio
|
|
6326
|
+
check2({
|
|
6327
|
+
id: "stdio-stdout-clean",
|
|
6328
|
+
title: "stdout holds only MCP messages",
|
|
6329
|
+
description: "Every line the server writes to stdout is one whole JSON-RPC message, with no newline inside it.",
|
|
6330
|
+
level: "MUST",
|
|
6331
|
+
specRefs: [ref4(L2, "basic/transports", "stdio"), ref4(M2, "basic/transports/stdio", "stdio")],
|
|
6332
|
+
eras: BOTH3,
|
|
6333
|
+
transports: ["stdio"]
|
|
6334
|
+
}),
|
|
6335
|
+
check2({
|
|
6336
|
+
id: "stdio-exit-on-eof",
|
|
6337
|
+
title: "The server exits when stdin closes",
|
|
6338
|
+
description: "After its stdin is closed the server process ends within a short time.",
|
|
6339
|
+
level: "SHOULD",
|
|
6340
|
+
specRefs: [ref4(M2, "basic/transports/stdio", "Shutdown")],
|
|
6341
|
+
eras: BOTH3,
|
|
6342
|
+
transports: ["stdio"]
|
|
6343
|
+
}),
|
|
6344
|
+
// The oauth suite (auth-catalog.ts)
|
|
6345
|
+
...OAUTH_CATALOG,
|
|
6346
|
+
// The apps suite (apps-catalog.ts)
|
|
6347
|
+
...APPS_CATALOG,
|
|
6348
|
+
// The tasks suite (tasks-catalog.ts)
|
|
6349
|
+
...TASKS_CATALOG
|
|
6350
|
+
];
|
|
6351
|
+
var BY_ID = new Map(CATALOG.map((e) => [e.id, e]));
|
|
6352
|
+
|
|
6353
|
+
// src/mcp-testing/conformance/profile.ts
|
|
6354
|
+
init_esm_shims();
|
|
6355
|
+
import { createHash as createHash3 } from "crypto";
|
|
6356
|
+
|
|
6357
|
+
// src/mcp-testing/report/human.ts
|
|
6358
|
+
init_exit_codes();
|
|
6359
|
+
|
|
6360
|
+
// src/mcp-testing/snapshot/index.ts
|
|
6361
|
+
init_esm_shims();
|
|
6362
|
+
|
|
6363
|
+
// src/mcp-testing/snapshot/snapshot.ts
|
|
6364
|
+
init_esm_shims();
|
|
6365
|
+
|
|
6366
|
+
// src/mcp-testing/snapshot/diff.ts
|
|
6367
|
+
init_esm_shims();
|
|
6368
|
+
|
|
6369
|
+
// src/mcp-testing/report/human.ts
|
|
6370
|
+
var noCommands = (text) => text.replace(/^([\s\u0085]*)::/gm, "$1?::").replaceAll("##[", "##?[");
|
|
6371
|
+
|
|
6372
|
+
// src/mcp-testing/scan/descriptions.ts
|
|
6373
|
+
init_esm_shims();
|
|
6374
|
+
|
|
6375
|
+
// src/mcp-testing/scan/phrases.ts
|
|
6376
|
+
init_esm_shims();
|
|
6377
|
+
var DESCRIPTION_PHRASES = {
|
|
6378
|
+
version: 1,
|
|
6379
|
+
rules: {
|
|
6380
|
+
"scan/desc/override-instruction": [
|
|
6381
|
+
"\\b(?:ignore|disregard|forget|override) (?:all |any )?(?:of )?(?:the |your |my )?(?:previous|prior|above|earlier|preceding|other|system) (?:instructions?|prompts?|messages?|rules?|context)",
|
|
6382
|
+
"\\b(?:ignore|disregard) (?:all |any )?(?:of )?(?:the |your )?(?:previous|prior|above|earlier|preceding)\\b",
|
|
6383
|
+
"\\bnew (?:system )?instructions:",
|
|
6384
|
+
"\\byou are now (?:a|an|in)\\b"
|
|
6385
|
+
],
|
|
6386
|
+
"scan/desc/sensitive-path": [
|
|
6387
|
+
"(?<![\\w.~])(?:~/)?\\.ssh\\b",
|
|
6388
|
+
"\\bid_(?:rsa|dsa|ecdsa|ed25519)\\b",
|
|
6389
|
+
"(?<![\\w.~])(?:~/)?\\.aws/(?:credentials|config)\\b",
|
|
6390
|
+
"(?<![\\w.~])(?:~/)?\\.env\\b",
|
|
6391
|
+
"(?<![\\w.~])(?:~/)?\\.(?:npmrc|pypirc|netrc|pgpass|git-credentials)\\b",
|
|
6392
|
+
"(?<![\\w.~])(?:~/)?\\.(?:docker/config\\.json|kube/config|gnupg|config/gcloud)\\b",
|
|
6393
|
+
"/etc/(?:shadow|passwd)\\b",
|
|
6394
|
+
"\\bcredentials\\.json\\b",
|
|
6395
|
+
"\\bread (?:the )?(?:contents? of )?(?:the |any |a )?(?:file|files)\\b"
|
|
6396
|
+
],
|
|
6397
|
+
"scan/desc/conceal-from-user": [
|
|
6398
|
+
"\\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",
|
|
6399
|
+
"\\bwithout (?:telling|informing|notifying|alerting) (?:the )?user",
|
|
6400
|
+
"\\b(?:hide|conceal|keep) (?:this |it |that )?(?:secret |hidden )?from (?:the )?user",
|
|
6401
|
+
"\\bthe user (?:must|should) not (?:know|see|be told)"
|
|
6402
|
+
],
|
|
6403
|
+
"scan/desc/call-other-tool-first": [
|
|
6404
|
+
"\\b(?:before|prior to) (?:using|calling|invoking|running) this tool,? (?:you )?(?:must |should |always )?(?:first )?(?:call|use|invoke|run)\\b",
|
|
6405
|
+
"\\b(?:always |must )?(?:first )?(?:call|invoke|run) (?:the )?[\\w.-]+ (?:tool )?(?:first|beforehand|before (?:this|using this|calling this))\\b",
|
|
6406
|
+
"\\binstead of (?:this tool|calling this tool|using this tool),? (?:call|use|invoke)\\b"
|
|
6407
|
+
],
|
|
6408
|
+
"scan/desc/param-asks-for-context": [
|
|
6409
|
+
"\\b(?:the )?(?:entire|full|whole|complete) (?:conversation|chat|dialog(?:ue)?|history|context|transcript)",
|
|
6410
|
+
"\\bconversation history\\b",
|
|
6411
|
+
"\\b(?:all |the )?(?:previous|prior|earlier) messages\\b",
|
|
6412
|
+
"\\bsystem prompt\\b",
|
|
6413
|
+
"\\b(?:contents?|text) of (?:the |any |a )?(?:file|files|document)\\b",
|
|
6414
|
+
"\\b(?:output|result|response) (?:of|from) (?:the |another |other |any )?(?:tools?)\\b"
|
|
6415
|
+
]
|
|
6416
|
+
}
|
|
6417
|
+
};
|
|
6418
|
+
|
|
6419
|
+
// src/mcp-testing/scan/descriptions.ts
|
|
6420
|
+
var MAX_TEXT_BYTES = 1024 * 1024;
|
|
6421
|
+
var EXCERPT = 80;
|
|
6422
|
+
var U = (cp) => `U+${cp.toString(16).toUpperCase().padStart(4, "0")}`;
|
|
6423
|
+
var SHOWN = /^[\p{L}\p{N}\p{P}\p{S} ]$/u;
|
|
6424
|
+
function visible(s, max = EXCERPT) {
|
|
6425
|
+
const pieces = [];
|
|
6426
|
+
let len = 0;
|
|
6427
|
+
for (const ch of s) {
|
|
6428
|
+
const piece = SHOWN.test(ch) ? ch : `[${U(ch.codePointAt(0))}]`;
|
|
6429
|
+
pieces.push(piece);
|
|
6430
|
+
len += [...piece].length;
|
|
6431
|
+
if (len > max) {
|
|
6432
|
+
while (len > max - 3) len -= [...pieces.pop()].length;
|
|
6433
|
+
return `${pieces.join("")}...`;
|
|
6434
|
+
}
|
|
6435
|
+
}
|
|
6436
|
+
return pieces.join("");
|
|
6437
|
+
}
|
|
6438
|
+
var EMOJI = new RegExp("\\p{Extended_Pictographic}", "u");
|
|
6439
|
+
var PHRASES = Object.fromEntries(
|
|
6440
|
+
Object.entries(DESCRIPTION_PHRASES.rules).map(([id, list2]) => [id, new RegExp(list2.map((p) => `(?:${p.replace(/ /g, "\\s+")})`).join("|"), "giu")])
|
|
6441
|
+
);
|
|
6442
|
+
|
|
6443
|
+
// src/mcp-testing/scan/config/json-tree.ts
|
|
6444
|
+
init_esm_shims();
|
|
6445
|
+
|
|
6446
|
+
// src/mcp-testing/scan/config/config.ts
|
|
6447
|
+
var MAX_FILE_BYTES = 8 * 1024 * 1024;
|
|
6448
|
+
var MAX_VALUE = 64 * 1024;
|
|
6449
|
+
var SHOWN_NAME = 64;
|
|
6450
|
+
var KNOWN_FORMATS = [
|
|
6451
|
+
["github-token", /(?<![A-Za-z0-9])(?:gh[pousr]_|github_pat_)[A-Za-z0-9_]{36,}/],
|
|
6452
|
+
["aws-access-key-id", /(?<![A-Za-z0-9])(?:AKIA|ASIA|AGPA|AIDA|AROA)[A-Z2-7]{16}(?![A-Za-z0-9])/],
|
|
6453
|
+
["slack-token", /(?<![A-Za-z0-9])xox[abprs]-[A-Za-z0-9-]{10,}/],
|
|
6454
|
+
["stripe-key", /(?<![A-Za-z0-9])[rs]k_live_[A-Za-z0-9]{16,}/],
|
|
6455
|
+
["anthropic-key", /(?<![A-Za-z0-9])sk-ant-[A-Za-z0-9_-]{20,}/],
|
|
6456
|
+
["openai-key", /(?<![A-Za-z0-9])sk-(?:proj|svcacct)-[A-Za-z0-9_-]{32,}/],
|
|
6457
|
+
["google-api-key", /(?<![A-Za-z0-9])AIza[0-9A-Za-z_-]{35}/],
|
|
6458
|
+
["npm-token", /(?<![A-Za-z0-9])npm_[A-Za-z0-9]{36}(?![A-Za-z0-9])/],
|
|
6459
|
+
["gitlab-token", /(?<![A-Za-z0-9])glpat-[A-Za-z0-9_-]{20}/],
|
|
6460
|
+
["private-key", /-----BEGIN (?:[A-Z]+ )*PRIVATE KEY-----/]
|
|
6461
|
+
];
|
|
6462
|
+
var KEY_PREFIX = /^\s*(?:gh[pousr]_|github_pat_|AKIA|ASIA|AGPA|AIDA|AROA|xox[abprs]-|[rs]k_live_|sk-ant-|AIza|npm_|glpat-|-----BEGIN )/;
|
|
6463
|
+
var NAME_FORMATS = KNOWN_FORMATS.map(
|
|
6464
|
+
([, re]) => new RegExp(re.source.replace("(?<![A-Za-z0-9])", "").replace("(?![A-Za-z0-9])", ""), re.flags)
|
|
6465
|
+
);
|
|
6466
|
+
var tokenish = (name) => {
|
|
6467
|
+
const head = name.slice(0, 256);
|
|
6468
|
+
return KEY_PREFIX.test(head) || NAME_FORMATS.some((re) => re.test(head));
|
|
6469
|
+
};
|
|
6470
|
+
var safe = (name) => noCommands(visible(tokenish(name) ? "[key]" : name, SHOWN_NAME));
|
|
6471
|
+
var safeText = (text) => noCommands(
|
|
6472
|
+
visible(
|
|
6473
|
+
text.slice(0, 1024).replace(/[^\\/]+/g, (seg) => tokenish(seg) ? "[key]" : seg),
|
|
6474
|
+
400
|
|
6475
|
+
)
|
|
6476
|
+
);
|
|
6477
|
+
|
|
6478
|
+
// src/cli/commands/cairn-artifact.ts
|
|
4360
6479
|
var SUPPORTED_ARTIFACT_VERSION = 1;
|
|
4361
6480
|
var INGEST_SCHEMA_VERSION = 1;
|
|
4362
6481
|
var NoCairnRunsError = class extends Error {
|
|
@@ -4406,6 +6525,14 @@ var CairnRunPartialError = class extends Error {
|
|
|
4406
6525
|
this.name = "CairnRunPartialError";
|
|
4407
6526
|
}
|
|
4408
6527
|
};
|
|
6528
|
+
var CairnArtifactShapeError = class extends Error {
|
|
6529
|
+
constructor(file, field, problem) {
|
|
6530
|
+
super(
|
|
6531
|
+
`Cannot read this Cairn run: ${file}${field === "" ? "" : field.startsWith("[") ? field : ` ${field}`} ${problem}. Nothing was uploaded.`
|
|
6532
|
+
);
|
|
6533
|
+
this.name = "CairnArtifactShapeError";
|
|
6534
|
+
}
|
|
6535
|
+
};
|
|
4409
6536
|
var CairnEvidenceAmbiguousError = class extends Error {
|
|
4410
6537
|
constructor(name) {
|
|
4411
6538
|
super(
|
|
@@ -4416,6 +6543,28 @@ var CairnEvidenceAmbiguousError = class extends Error {
|
|
|
4416
6543
|
};
|
|
4417
6544
|
var asRecord = (v) => typeof v === "object" && v !== null ? v : {};
|
|
4418
6545
|
var str = (v, fallback = "") => typeof v === "string" && v !== "" ? v : fallback;
|
|
6546
|
+
var own = (rec, key) => Object.hasOwn(rec, key) ? rec[key] : void 0;
|
|
6547
|
+
var MAX_ARTIFACT_BYTES = 32 * 1024 * 1024;
|
|
6548
|
+
var MAX_MCP_CASES = 5e3;
|
|
6549
|
+
async function checkSize(dir, file) {
|
|
6550
|
+
let size;
|
|
6551
|
+
try {
|
|
6552
|
+
const st = await fs7.stat(path8.join(dir, file));
|
|
6553
|
+
if (!st.isFile()) throw new CairnArtifactShapeError(file, "", "is not a regular file");
|
|
6554
|
+
size = st.size;
|
|
6555
|
+
} catch (e) {
|
|
6556
|
+
if (e instanceof CairnArtifactShapeError) throw e;
|
|
6557
|
+
return false;
|
|
6558
|
+
}
|
|
6559
|
+
if (size > MAX_ARTIFACT_BYTES) {
|
|
6560
|
+
throw new CairnArtifactShapeError(
|
|
6561
|
+
file,
|
|
6562
|
+
"",
|
|
6563
|
+
`is larger than ${MAX_ARTIFACT_BYTES / (1024 * 1024)} MiB`
|
|
6564
|
+
);
|
|
6565
|
+
}
|
|
6566
|
+
return true;
|
|
6567
|
+
}
|
|
4419
6568
|
async function readJson(file) {
|
|
4420
6569
|
try {
|
|
4421
6570
|
return JSON.parse(await fs7.readFile(file, "utf8"));
|
|
@@ -4423,6 +6572,170 @@ async function readJson(file) {
|
|
|
4423
6572
|
return void 0;
|
|
4424
6573
|
}
|
|
4425
6574
|
}
|
|
6575
|
+
var ARGS_CHARS2 = 200;
|
|
6576
|
+
var SECRET_NAME = /key|token|secret|password|passwd|auth|cookie|credential/i;
|
|
6577
|
+
var maskNamed = (v, depth = 0) => {
|
|
6578
|
+
if (depth > 16) return "[deep]";
|
|
6579
|
+
if (Array.isArray(v)) return v.slice(0, 50).map((x) => maskNamed(x, depth + 1));
|
|
6580
|
+
if (typeof v === "object" && v !== null) {
|
|
6581
|
+
const out = {};
|
|
6582
|
+
for (const [k, x] of Object.entries(v).slice(0, 50)) {
|
|
6583
|
+
out[k] = SECRET_NAME.test(k) ? "***" : maskNamed(x, depth + 1);
|
|
6584
|
+
}
|
|
6585
|
+
return out;
|
|
6586
|
+
}
|
|
6587
|
+
return v;
|
|
6588
|
+
};
|
|
6589
|
+
function describeMcpArgs(request) {
|
|
6590
|
+
let text = request.slice(0, 4096);
|
|
6591
|
+
try {
|
|
6592
|
+
text = JSON.stringify(maskNamed(JSON.parse(text)));
|
|
6593
|
+
} catch {
|
|
6594
|
+
}
|
|
6595
|
+
const masked = safeText(redactSecrets(text));
|
|
6596
|
+
return masked.length > ARGS_CHARS2 ? `${masked.slice(0, ARGS_CHARS2)} (cut)` : masked;
|
|
6597
|
+
}
|
|
6598
|
+
var MCP_STATES = /* @__PURE__ */ new Set([
|
|
6599
|
+
"passed",
|
|
6600
|
+
"failed",
|
|
6601
|
+
"not-sent",
|
|
6602
|
+
"could-not-run",
|
|
6603
|
+
"needs-review"
|
|
6604
|
+
]);
|
|
6605
|
+
async function readMcpEvidence(dir, states) {
|
|
6606
|
+
const file = "mcp-evidence.json";
|
|
6607
|
+
if (!await checkSize(dir, file)) return void 0;
|
|
6608
|
+
let raw;
|
|
6609
|
+
try {
|
|
6610
|
+
raw = JSON.parse(await fs7.readFile(path8.join(dir, file), "utf8"));
|
|
6611
|
+
} catch {
|
|
6612
|
+
throw new CairnArtifactShapeError(file, "", "is not valid JSON");
|
|
6613
|
+
}
|
|
6614
|
+
if (!Array.isArray(raw)) throw new CairnArtifactShapeError(file, "", "must be a list");
|
|
6615
|
+
if (raw.length > MAX_MCP_CASES) {
|
|
6616
|
+
throw new CairnArtifactShapeError(file, "", `lists more than ${MAX_MCP_CASES} entries`);
|
|
6617
|
+
}
|
|
6618
|
+
const byId = /* @__PURE__ */ new Map();
|
|
6619
|
+
raw.forEach((item, i) => {
|
|
6620
|
+
if (typeof item !== "object" || item === null || Array.isArray(item)) {
|
|
6621
|
+
throw new CairnArtifactShapeError(file, `[${i}]`, "must be an object");
|
|
6622
|
+
}
|
|
6623
|
+
const rec = item;
|
|
6624
|
+
const id = own(rec, "stableId");
|
|
6625
|
+
if (typeof id !== "string" || !states.has(id)) {
|
|
6626
|
+
throw new CairnArtifactShapeError(
|
|
6627
|
+
file,
|
|
6628
|
+
`[${i}].stableId`,
|
|
6629
|
+
"does not name a case of report.json"
|
|
6630
|
+
);
|
|
6631
|
+
}
|
|
6632
|
+
if (byId.has(id)) {
|
|
6633
|
+
throw new CairnArtifactShapeError(file, `[${i}].stableId`, "appears more than once");
|
|
6634
|
+
}
|
|
6635
|
+
if (own(rec, "state") !== states.get(id)) {
|
|
6636
|
+
throw new CairnArtifactShapeError(
|
|
6637
|
+
file,
|
|
6638
|
+
`[${i}].state`,
|
|
6639
|
+
"does not agree with the state in report.json"
|
|
6640
|
+
);
|
|
6641
|
+
}
|
|
6642
|
+
const request = own(rec, "request");
|
|
6643
|
+
if (request !== void 0 && typeof request !== "string") {
|
|
6644
|
+
throw new CairnArtifactShapeError(file, `[${i}].request`, "must be text");
|
|
6645
|
+
}
|
|
6646
|
+
const durationMs = own(rec, "durationMs");
|
|
6647
|
+
if (durationMs !== void 0 && typeof durationMs !== "number") {
|
|
6648
|
+
throw new CairnArtifactShapeError(file, `[${i}].durationMs`, "must be a number");
|
|
6649
|
+
}
|
|
6650
|
+
byId.set(id, {
|
|
6651
|
+
sent: typeof durationMs === "number",
|
|
6652
|
+
...request !== void 0 ? { request } : {}
|
|
6653
|
+
});
|
|
6654
|
+
});
|
|
6655
|
+
return byId;
|
|
6656
|
+
}
|
|
6657
|
+
function expectedOfMcp(type, adversarial) {
|
|
6658
|
+
if (type === "Positive") {
|
|
6659
|
+
return "The call finishes without an error, and the answer fits the tool's outputSchema when it has one.";
|
|
6660
|
+
}
|
|
6661
|
+
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.";
|
|
6662
|
+
}
|
|
6663
|
+
async function casesFromMcp(dir, report) {
|
|
6664
|
+
const list2 = own(report, "cases");
|
|
6665
|
+
if (!Array.isArray(list2))
|
|
6666
|
+
throw new CairnArtifactShapeError("report.json", "cases", "must be a list");
|
|
6667
|
+
if (list2.length > MAX_MCP_CASES) {
|
|
6668
|
+
throw new CairnArtifactShapeError(
|
|
6669
|
+
"report.json",
|
|
6670
|
+
"cases",
|
|
6671
|
+
`lists more than ${MAX_MCP_CASES} cases`
|
|
6672
|
+
);
|
|
6673
|
+
}
|
|
6674
|
+
const states = /* @__PURE__ */ new Map();
|
|
6675
|
+
const parsed2 = list2.map((raw, i) => {
|
|
6676
|
+
const at = `cases[${i}]`;
|
|
6677
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
6678
|
+
throw new CairnArtifactShapeError("report.json", at, "must be an object");
|
|
6679
|
+
}
|
|
6680
|
+
const c = raw;
|
|
6681
|
+
const text = (key) => {
|
|
6682
|
+
const v = own(c, key);
|
|
6683
|
+
if (typeof v !== "string" || v === "") {
|
|
6684
|
+
throw new CairnArtifactShapeError("report.json", `${at}.${key}`, "must be text");
|
|
6685
|
+
}
|
|
6686
|
+
return v;
|
|
6687
|
+
};
|
|
6688
|
+
const stableId = text("stableId");
|
|
6689
|
+
const name = text("name");
|
|
6690
|
+
const tool = text("tool");
|
|
6691
|
+
const type = text("type");
|
|
6692
|
+
const state = text("state");
|
|
6693
|
+
if (type !== "Positive" && type !== "Negative") {
|
|
6694
|
+
throw new CairnArtifactShapeError(
|
|
6695
|
+
"report.json",
|
|
6696
|
+
`${at}.type`,
|
|
6697
|
+
`is "${safe(type)}", not Positive or Negative`
|
|
6698
|
+
);
|
|
6699
|
+
}
|
|
6700
|
+
if (!MCP_STATES.has(state)) {
|
|
6701
|
+
throw new CairnArtifactShapeError(
|
|
6702
|
+
"report.json",
|
|
6703
|
+
`${at}.state`,
|
|
6704
|
+
`is "${safe(state)}", a state this CLI does not know`
|
|
6705
|
+
);
|
|
6706
|
+
}
|
|
6707
|
+
if (states.has(stableId)) {
|
|
6708
|
+
throw new CairnArtifactShapeError("report.json", `${at}.stableId`, "appears more than once");
|
|
6709
|
+
}
|
|
6710
|
+
states.set(stableId, state);
|
|
6711
|
+
const kind = type;
|
|
6712
|
+
const technique = own(c, "technique");
|
|
6713
|
+
return {
|
|
6714
|
+
stableId,
|
|
6715
|
+
name,
|
|
6716
|
+
tool,
|
|
6717
|
+
type: kind,
|
|
6718
|
+
state,
|
|
6719
|
+
adversarial: own(c, "adversarialStyle") !== void 0,
|
|
6720
|
+
...typeof technique === "string" ? { technique } : {}
|
|
6721
|
+
};
|
|
6722
|
+
});
|
|
6723
|
+
const evidence = await readMcpEvidence(dir, states);
|
|
6724
|
+
return parsed2.map((c) => {
|
|
6725
|
+
const e = evidence?.get(c.stableId);
|
|
6726
|
+
const verdict = c.state === "passed" ? "passed" : c.state === "failed" ? "failed" : c.state === "could-not-run" && e?.sent === true ? "blocked" : void 0;
|
|
6727
|
+
const args = e?.request !== void 0 ? ` ${describeMcpArgs(e.request)}` : "";
|
|
6728
|
+
return {
|
|
6729
|
+
stableId: c.stableId,
|
|
6730
|
+
title: safeText(c.name),
|
|
6731
|
+
execution: "auto",
|
|
6732
|
+
steps: [`tools/call ${safe(c.tool)}${args}`],
|
|
6733
|
+
expected: expectedOfMcp(c.type, c.adversarial),
|
|
6734
|
+
...verdict !== void 0 ? { verdict } : {},
|
|
6735
|
+
...c.technique !== void 0 ? { technique: safeText(c.technique) } : {}
|
|
6736
|
+
};
|
|
6737
|
+
});
|
|
6738
|
+
}
|
|
4426
6739
|
async function defaultReadEvidence(dir) {
|
|
4427
6740
|
const raw = await readJson(path8.join(dir, "api-evidence.json"));
|
|
4428
6741
|
if (!Array.isArray(raw)) return void 0;
|
|
@@ -4433,8 +6746,8 @@ async function defaultReadEvidence(dir) {
|
|
|
4433
6746
|
});
|
|
4434
6747
|
}
|
|
4435
6748
|
function casesFromDesign(report) {
|
|
4436
|
-
const
|
|
4437
|
-
return
|
|
6749
|
+
const list2 = Array.isArray(report["testCases"]) ? report["testCases"] : [];
|
|
6750
|
+
return list2.map((raw) => {
|
|
4438
6751
|
const c = asRecord(raw);
|
|
4439
6752
|
const steps = (Array.isArray(c["steps"]) ? c["steps"] : []).map((s) => str(s)).filter((s) => s !== "");
|
|
4440
6753
|
return {
|
|
@@ -4449,8 +6762,8 @@ function casesFromDesign(report) {
|
|
|
4449
6762
|
});
|
|
4450
6763
|
}
|
|
4451
6764
|
function casesFromApi(report, verdicts) {
|
|
4452
|
-
const
|
|
4453
|
-
return
|
|
6765
|
+
const list2 = Array.isArray(report["cases"]) ? report["cases"] : [];
|
|
6766
|
+
return list2.map((raw) => {
|
|
4454
6767
|
const c = asRecord(raw);
|
|
4455
6768
|
const name = str(c["name"], "unnamed operation");
|
|
4456
6769
|
const request = `${str(c["method"], "GET")} ${str(c["path"], "/")}`;
|
|
@@ -4467,6 +6780,7 @@ function casesFromApi(report, verdicts) {
|
|
|
4467
6780
|
});
|
|
4468
6781
|
}
|
|
4469
6782
|
async function readCairnRun(dir, deps = {}) {
|
|
6783
|
+
await checkSize(dir, "report.json");
|
|
4470
6784
|
const raw = await readJson(path8.join(dir, "report.json"));
|
|
4471
6785
|
if (raw === void 0) throw new CairnRunNotFoundError(dir);
|
|
4472
6786
|
const report = asRecord(raw);
|
|
@@ -4477,7 +6791,7 @@ async function readCairnRun(dir, deps = {}) {
|
|
|
4477
6791
|
throw new CairnRunPartialError(str(report["error"], "no reason recorded"));
|
|
4478
6792
|
}
|
|
4479
6793
|
const mode = report["mode"];
|
|
4480
|
-
if (mode !== "design" && mode !== "explore" && mode !== "api") {
|
|
6794
|
+
if (mode !== "design" && mode !== "explore" && mode !== "api" && mode !== "mcp") {
|
|
4481
6795
|
throw new CairnRunVersionError(
|
|
4482
6796
|
`${SUPPORTED_ARTIFACT_VERSION} (unknown run mode ${String(mode)})`
|
|
4483
6797
|
);
|
|
@@ -4491,6 +6805,8 @@ async function readCairnRun(dir, deps = {}) {
|
|
|
4491
6805
|
verdicts.set(e.name, e.error !== void 0 ? "blocked" : e.passed ? "passed" : "failed");
|
|
4492
6806
|
}
|
|
4493
6807
|
cases = casesFromApi(report, verdicts);
|
|
6808
|
+
} else if (mode === "mcp") {
|
|
6809
|
+
cases = await casesFromMcp(dir, report);
|
|
4494
6810
|
} else {
|
|
4495
6811
|
cases = casesFromDesign(report);
|
|
4496
6812
|
}
|
|
@@ -4586,7 +6902,7 @@ async function handleIngest(deps) {
|
|
|
4586
6902
|
}
|
|
4587
6903
|
}
|
|
4588
6904
|
function reportIngestFailure(err, write) {
|
|
4589
|
-
if (err instanceof IngestNotLoggedInError || err instanceof IngestTokenRejectedError || err instanceof CairnRunNotFoundError || err instanceof NoCairnRunsError || err instanceof CairnRunVersionError || err instanceof CairnRunPartialError || err instanceof CairnEvidenceAmbiguousError) {
|
|
6905
|
+
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) {
|
|
4590
6906
|
write(`${err.message}
|
|
4591
6907
|
`);
|
|
4592
6908
|
return 2;
|