@vantageos/mcp-doctor 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to `@vantageos/mcp-doctor` are documented here.
4
4
  This project adheres to [Semantic Versioning](https://semver.org/).
5
5
  Unreleased changes live as one fragment per pull request in `changelog.d/`, folded in here at release time.
6
6
 
7
+ ## 0.22.0 — 2026-11-24
8
+
9
+ ### Changed
10
+ - **C-40 (8) reads the description's Returns clause against the outputSchema's top-level properties.** An object literal ("Returns { a, b }", with its ", or { … }" alternatives and "plus x" additions) is the result's shape: a name the schema lacks is red. A top-level property the literal leaves out is a note printed under the tool, never red, and the criterion stays green. A field list ("Returns the row as JSON (a, b)") is red only on a name the schema lacks. A clause in prose that names no field is out of the check, and so is a description with no Returns clause. An outputSchema with no top-level properties object, a literal inside prose, a group mixing names and prose, an unread member or an unbalanced bracket is could-not-judge, named. A name found only deeper in the schema is named with its path. On Manufact's per-tool review of vantage-peers (92 tools, vendored in `fixtures/manufact-vantage-peers-2026-11-09-per-tool/`), the check reds none and notes 12 tools, 9 of the 20 Manufact asks to align. `scripts/manufact-per-tool-compare.ts` prints the doctor and Manufact verdicts per tool and per dimension, with the disagreements counted in both directions, and a closing Returns line: how many of Manufact's "align" flags the check reds, and how many tools carry the note. (README: #what-it-checks-mcp-2026-07-28)
11
+ - **S-5 (f)..(l) is read on the wire under `--url`.** The introspector now records both Protected Resource Metadata copies (path-suffixed and bare) and the OIDC discovery at the same-origin issuer: (f) is judged (`resource` equals the MCP URL, path included, at both copies; a copy not served is red; an unreadable copy is could-not-judge naming its URL), (j) and (k) are read when served (unestablished when absent, never red), and a handshake refused with 401 is judged from the public reads. Only (h), (i) and `iss` on every authorization response stay named as not read (they need an authorization-request probe or a human verdict). (README: #detectors-added-in-070-standard-b714129a-elpi-corp-243)
12
+
7
13
  ## 0.21.0 — 2026-11-15
8
14
 
9
15
  ### Added
package/README.md CHANGED
@@ -64,7 +64,7 @@ usage: mcp-doctor <source-tree-path> [--mode=static|dynamic|both] [--backend=<co
64
64
  default: the nearest convex/ above the tree
65
65
  --url URL judge a REMOTE streamable-HTTP server the way a customer reaches it (implies
66
66
  dynamic; no launch target; https, or http on loopback only). Only the rules that
67
- judge what a running server serves run (incl. S5 (g)(l), D3, D4, S10, S12, S23);
67
+ judge what a running server serves run (incl. S5 (f)..(l), D3, D4, S10, S12, S23);
68
68
  source-tree rules are not run
69
69
  --bearer-env VAR send the token held in environment variable VAR as 'Authorization: Bearer'
70
70
  (the token never appears on a command line or in output)
@@ -414,7 +414,7 @@ where the tree contradicts the rule, and otherwise `could-not-judge` naming the
414
414
  | **C32** host-key-additive | C-32 | `_meta` objects (followed through spreads and consts): `openai/outputTemplate` needs `ui.resourceUri`, `openai/visibility` needs `ui.visibility` | absent / non-conforming / could-not-judge (served `tools/list` owed) |
415
415
  | **C33** identity-tool | C-33 | on an authenticated server, the identity tool: no argument, `readOnlyHint: true`, an `outputSchema` that declares `id` (inline or a same-tree const) | absent / non-conforming / could-not-judge |
416
416
  | **S29**..**S34** | S-29..S-34 | the `events` capability and the three `events/*` handler literals; descriptors (`name`, bilingual description, non-empty `delivery`, `inputSchema`, `payloadSchema`); the `-32012`/`-32602`/`whsec_`, `-32015`/`verification`, five-header/`standardwebhooks`/262144-byte/410-413 evidence; `events.accessRecheckSeconds > 0` in the server manifest | absent (no events surface) / non-conforming / could-not-judge (dynamic half named) |
417
- | **S5** authz-elements (f)-(l) | S-5 (f)..(l) | PRM `resource` and its path-suffixed route, CIMD + `"none"`, `iss` flag, `/authorize` handler (auto-approval, organisation from a query parameter), jwt-bearer, OIDC discovery | absent (out of S-5's scope: not an MCP server, or stdio only) / non-conforming / could-not-judge (sites exposed in `owedVerdict`; probes owed; or the S-5 scope unread) |
417
+ | **S5** authz-elements (f)-(l) | S-5 (f)..(l) | PRM `resource` and path-suffixed route, CIMD + `"none"`, `iss` flag, `/authorize` (auto-approval, organisation in the query), jwt-bearer, OIDC discovery | absent (out of S-5's scope: not an MCP server, or stdio only) / non-conforming / could-not-judge (sites in `owedVerdict`; probes owed: over `--url` (h), (i), `iss`; or S-5's scope unread) |
418
418
  | **E7** middleware-events | E-7 | writes to `delivery`/`arguments`/`id`/`refreshBefore`/`cursor` and replacement of `ctx.output` inside an `events/*` branch of a hook | absent / present / non-conforming |
419
419
  | **E8** official-ext-declared | E-8 | `capabilities.extensions` as an object, each official key's MUST methods registered | absent / present / non-conforming / could-not-judge (unknown official extension) |
420
420
  | **E9** host-invoked-tools | E-9 | `openai/settings.readTool`, `openai/mentions.searchTool`: registered, `readOnlyHint: true`, `outputSchema`, no required input, `"app"` visibility, ResourceLink | absent / present / non-conforming |
package/dist/doctor.d.ts CHANGED
@@ -235,6 +235,26 @@ type ServedDiscovery = {
235
235
  cards: ServedGet[];
236
236
  landing: ServedGet;
237
237
  };
238
+ /**
239
+ * S-5 (f)(k): the public documents read beside the authorization-server metadata, with NO credential, on the MCP
240
+ * endpoint's own origin. `mcpUrl` is the endpoint as a client types it (origin + path, no query): the value the PRM
241
+ * `resource` must equal. `prm.suffixed` is absent when the MCP URL has no path (the two copies are then one URL).
242
+ * `oidc` is the OIDC discovery read at the authorization server's issuer, or why none was made.
243
+ */
244
+ type ServedAuthDocs = {
245
+ kind: "not-run";
246
+ reason: string;
247
+ } | {
248
+ kind: "probed";
249
+ mcpUrl: string;
250
+ prm: {
251
+ suffixed?: ServedGet;
252
+ bare: ServedGet;
253
+ };
254
+ oidc: ServedGet | {
255
+ skipped: string;
256
+ };
257
+ };
238
258
  /** What the running server SERVES that a source-tree read can only guess at. */
239
259
  interface ServedFacts {
240
260
  /** `capabilities` of the `initialize` response, as served. */
@@ -251,6 +271,8 @@ interface ServedFacts {
251
271
  authServer: ServedAuthServer;
252
272
  /** S-46 served half: sign-ins started as each known CIMD client. Absent on records written before it existed. */
253
273
  authorize?: ServedAuthorize;
274
+ /** S-5 (f)(k): the PRM copies and the OIDC discovery as served. Absent on records written before it existed. */
275
+ authDocs?: ServedAuthDocs;
254
276
  /**
255
277
  * The `initialize` result beside `serverInfo` and `capabilities` (S-49, C-38): its keys and its `instructions` value
256
278
  * as served (any JSON kind; unset when the key is absent). Absent on records written before it existed, which a rule
@@ -396,6 +418,8 @@ interface RuntimeContext {
396
418
  publicAuth?: {
397
419
  authServer: ServedAuthServer;
398
420
  authorize?: ServedAuthorize;
421
+ /** S-5 (f)(k): the PRM copies and the OIDC discovery, public like the metadata. */
422
+ authDocs?: ServedAuthDocs;
399
423
  /** S-50's public reads, made even when the handshake was refused (a 401 is exactly what a visitor gets). */
400
424
  discovery?: ServedDiscovery;
401
425
  };
package/dist/doctor.js CHANGED
@@ -14969,15 +14969,192 @@ function sourced(d, served) {
14969
14969
  if (/["'`][^"'`\s]{1,64}["'`]/.test(d)) return true;
14970
14970
  return /\b(name|ID)\b/.test(d);
14971
14971
  }
14972
- function listedReturns(d) {
14972
+ var IDENT3 = "[A-Za-z_$][A-Za-z0-9_$]*";
14973
+ var OPEN2 = { "{": "}", "[": "]", "(": ")" };
14974
+ function closeOf2(s, i) {
14975
+ const stack = [];
14976
+ for (let j = i; j < s.length; j++) {
14977
+ const c = s[j];
14978
+ if (OPEN2[c]) stack.push(OPEN2[c]);
14979
+ else if (c === "}" || c === "]" || c === ")") {
14980
+ if (stack.pop() !== c) return -1;
14981
+ if (stack.length === 0) return j;
14982
+ }
14983
+ }
14984
+ return -1;
14985
+ }
14986
+ function splitTop2(s) {
14973
14987
  const out = [];
14974
- for (const m of d.matchAll(/Returns[^.;]*?(?:\(([^)]*)\)|\{([^}]*)\})/g)) {
14975
- for (const w of (m[1] ?? m[2] ?? "").split(/[,|]/)) {
14976
- const k = w.trim();
14977
- if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(k)) out.push(k);
14988
+ let depth = 0;
14989
+ let cur = "";
14990
+ for (const c of s) {
14991
+ if (OPEN2[c]) depth++;
14992
+ else if (c === "}" || c === "]" || c === ")") depth--;
14993
+ if (c === "," && depth === 0) {
14994
+ out.push(cur);
14995
+ cur = "";
14996
+ } else cur += c;
14997
+ }
14998
+ out.push(cur);
14999
+ return out.map((x) => x.trim()).filter((x) => x.length > 0);
15000
+ }
15001
+ function clauseEnd(d, from) {
15002
+ for (let j = from; j < d.length; j++) {
15003
+ const c = d[j];
15004
+ if (OPEN2[c]) {
15005
+ const k = closeOf2(d, j);
15006
+ if (k === -1) return -1;
15007
+ j = k;
15008
+ continue;
14978
15009
  }
15010
+ if (c === ";") return j;
15011
+ if ((c === "." || c === ":") && (j + 1 === d.length || /\s/.test(d[j + 1]))) return j;
14979
15012
  }
14980
- return [...new Set(out)];
15013
+ return d.length;
15014
+ }
15015
+ function literalNames(inner) {
15016
+ const names2 = [];
15017
+ const unread2 = [];
15018
+ const member = new RegExp(`^(${IDENT3})\\??((?:\\s+or\\s+${IDENT3}\\??)*)\\s*([:[{].*)?$`, "s");
15019
+ for (const m of splitTop2(inner)) {
15020
+ const r = member.exec(m);
15021
+ if (!r) {
15022
+ unread2.push(`member "${m}" is not a field name`);
15023
+ continue;
15024
+ }
15025
+ names2.push(r[1]);
15026
+ for (const alt of (r[2] ?? "").matchAll(new RegExp(`or\\s+(${IDENT3})`, "g")))
15027
+ names2.push(alt[1]);
15028
+ }
15029
+ return { names: names2, unread: unread2 };
15030
+ }
15031
+ var plusNames = (s) => [...s.matchAll(new RegExp(`\\bplus\\s+(${IDENT3})`, "g"))].map((m) => m[1]);
15032
+ function returnsClauses(d) {
15033
+ const out = [];
15034
+ for (const m of d.matchAll(/\bReturns\b/g)) {
15035
+ const at = m.index;
15036
+ const before = d.slice(0, at);
15037
+ if (!(before.trim() === "" || /[.;:]\s+$/.test(before))) {
15038
+ out.push({
15039
+ form: "prose",
15040
+ text: d.slice(at, at + 60),
15041
+ names: [],
15042
+ literalRead: false,
15043
+ unread: [
15044
+ `"Returns" at "${d.slice(Math.max(0, at - 20), at + 20)}" does not open a sentence`
15045
+ ]
15046
+ });
15047
+ continue;
15048
+ }
15049
+ const start = at + "Returns".length;
15050
+ const end = clauseEnd(d, start);
15051
+ const body = d.slice(start, end === -1 ? d.length : end);
15052
+ const text = `Returns${body}`;
15053
+ if (end === -1) {
15054
+ out.push({
15055
+ form: "prose",
15056
+ text,
15057
+ names: [],
15058
+ literalRead: false,
15059
+ unread: [`"${text}": unbalanced bracket`]
15060
+ });
15061
+ continue;
15062
+ }
15063
+ const names2 = [];
15064
+ const unread2 = [];
15065
+ if (/^\s*\{/.test(body)) {
15066
+ let first = true;
15067
+ for (let j = 0; j < body.length; j++) {
15068
+ const c = body[j];
15069
+ if (!OPEN2[c]) continue;
15070
+ const k = closeOf2(body, j);
15071
+ if (c === "{") {
15072
+ if (!first && !/\bor\s*$/.test(body.slice(0, j)))
15073
+ unread2.push(`"${body.slice(j, k + 1)}": a second literal not introduced by "or"`);
15074
+ else {
15075
+ const r = literalNames(body.slice(j + 1, k));
15076
+ names2.push(...r.names);
15077
+ unread2.push(...r.unread.map((u) => `"${text}": ${u}`));
15078
+ }
15079
+ first = false;
15080
+ }
15081
+ j = k;
15082
+ }
15083
+ names2.push(...plusNames(body.replace(/\{[\s\S]*\}/, "")));
15084
+ out.push({
15085
+ form: "object-literal",
15086
+ text,
15087
+ names: [...new Set(names2)],
15088
+ // A member it could not read may be any property: the "left out" direction is then not judged.
15089
+ literalRead: unread2.length === 0,
15090
+ unread: unread2
15091
+ });
15092
+ continue;
15093
+ }
15094
+ let literal = false;
15095
+ let list = false;
15096
+ for (let j = 0; j < body.length; j++) {
15097
+ const c = body[j];
15098
+ if (!OPEN2[c]) continue;
15099
+ const k = closeOf2(body, j);
15100
+ const group = body.slice(j, k + 1);
15101
+ if (c === "{") {
15102
+ literal = true;
15103
+ unread2.push(
15104
+ `"${text}": an object literal inside prose (${group}) cannot be placed at the top level`
15105
+ );
15106
+ } else if (c === "(") {
15107
+ const members3 = splitTop2(group.slice(1, -1));
15108
+ const named = new RegExp(`^(${IDENT3})\\??(?:\\s*\\{[\\s\\S]*\\})?$`);
15109
+ const isName = members3.map((x) => named.exec(x)?.[1]);
15110
+ if (isName.every((x) => x !== void 0)) {
15111
+ list = true;
15112
+ names2.push(...isName);
15113
+ } else if (isName.some((x) => x !== void 0))
15114
+ unread2.push(
15115
+ `"${text}": the group ${group} mixes field names and prose (${members3.filter((_, i) => isName[i] === void 0).join(", ")})`
15116
+ );
15117
+ }
15118
+ j = k;
15119
+ }
15120
+ names2.push(...plusNames(body));
15121
+ out.push({
15122
+ form: literal ? "literal-in-prose" : list ? "field-list" : "prose",
15123
+ text,
15124
+ names: [...new Set(names2)],
15125
+ literalRead: false,
15126
+ unread: unread2
15127
+ });
15128
+ }
15129
+ return out;
15130
+ }
15131
+ function returnsAlignment(d, top, fields) {
15132
+ const clauses = returnsClauses(d);
15133
+ if (top === null) {
15134
+ const given = clauses.flatMap((c) => c.names);
15135
+ return {
15136
+ bad: [],
15137
+ notes: [],
15138
+ cnj: [
15139
+ ...given.length > 0 ? [
15140
+ `outputSchema has no top-level properties object: the Returns clause names (${given.join(", ")}) and cannot be aligned`
15141
+ ] : [],
15142
+ ...clauses.flatMap((c) => c.unread)
15143
+ ]
15144
+ };
15145
+ }
15146
+ const named = new Set(clauses.flatMap((c) => c.names));
15147
+ const bad = [...named].filter((k) => !top.includes(k)).map((k) => {
15148
+ const deeper = fields.find((f) => f.key === k)?.path;
15149
+ return deeper ? `${k}: named as returned, not in outputSchema at the top level (it is ${deeper})` : `${k}: named as returned, not in outputSchema`;
15150
+ });
15151
+ const left = new Set(
15152
+ clauses.filter((c) => c.literalRead).flatMap((c) => top.filter((p) => !c.names.includes(p)))
15153
+ );
15154
+ const notes = [...left].map(
15155
+ (p) => `${p} is a top-level property of the outputSchema that the Returns { \u2026 } literal does not name`
15156
+ );
15157
+ return { bad, notes, cnj: clauses.flatMap((c) => c.unread) };
14981
15158
  }
14982
15159
  var HINTS = ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"];
14983
15160
  function scoreTools(tools) {
@@ -15041,13 +15218,18 @@ function scoreTools(tools) {
15041
15218
  );
15042
15219
  else {
15043
15220
  const fields = fieldsOf(output);
15044
- const keys = new Set(fields.map((f) => f.key));
15045
- out.push(
15046
- v("output-described-aligned", [
15221
+ const top = isObj3(output.properties) ? Object.keys(output.properties) : null;
15222
+ const aligned = returnsAlignment(t.description ?? "", top, fields);
15223
+ const verdict3 = v(
15224
+ "output-described-aligned",
15225
+ [
15047
15226
  ...fields.filter((f) => !f.node || !desc(f.node).trim()).map((f) => `${f.path}: no description`),
15048
- ...listedReturns(t.description ?? "").filter((k) => !keys.has(k)).map((k) => `${k}: named as returned, not in outputSchema`)
15049
- ])
15227
+ ...aligned.bad
15228
+ ],
15229
+ aligned.cnj
15050
15230
  );
15231
+ if (aligned.notes.length > 0) verdict3.notes = aligned.notes;
15232
+ out.push(verdict3);
15051
15233
  }
15052
15234
  }
15053
15235
  return out;
@@ -15095,6 +15277,10 @@ function runServed4(runtime) {
15095
15277
  const head = `${runtime.tools.length} served tool(s) x ${CRITERIA.length} criteria \u2014 ${tally.join(" | ")}`;
15096
15278
  const reds = lines2("non-conforming");
15097
15279
  const unread2 = lines2("could-not-judge");
15280
+ const noted = verdicts.filter((x) => (x.notes ?? []).length > 0).map((x) => `${x.tool} ${x.criterion}: note: ${(x.notes ?? []).join("; ")}`);
15281
+ const noteBlock = noted.length > 0 ? `
15282
+ notes (not defects):
15283
+ ${noted.join("\n")}` : "";
15098
15284
  if (reds.length > 0)
15099
15285
  return {
15100
15286
  id: ID8,
@@ -15103,12 +15289,12 @@ function runServed4(runtime) {
15103
15289
  verdict: `${RULE8}: ${head}
15104
15290
  ${reds.join("\n")}${unread2.length > 0 ? `
15105
15291
  could not judge:
15106
- ${unread2.join("\n")}` : ""}`
15292
+ ${unread2.join("\n")}` : ""}${noteBlock}`
15107
15293
  };
15108
15294
  if (unread2.length > 0)
15109
15295
  return couldNotJudge(ID8, anchor, `${head}
15110
- ${unread2.join("\n")} (${RULE8})`);
15111
- return { id: ID8, anchor, state: "present", verdict: `${head} (${RULE8})` };
15296
+ ${unread2.join("\n")}${noteBlock} (${RULE8})`);
15297
+ return { id: ID8, anchor, state: "present", verdict: `${head}${noteBlock} (${RULE8})` };
15112
15298
  }
15113
15299
  var c40ToolDocumentation = {
15114
15300
  id: ID8,
@@ -21948,73 +22134,291 @@ var s5AuthzElements = {
21948
22134
  );
21949
22135
  },
21950
22136
  /**
21951
- * SERVED half (S-5 (g)(l)): the authorization-server metadata the PRM names, read on the wire.
21952
- * (g): `client_id_metadata_document_supported` is the boolean true AND `token_endpoint_auth_methods_supported`
21953
- * is an array listing "none". (l): `authorization_response_iss_parameter_supported` is the boolean true.
21954
- * The other elements, and `iss` on every authorization response, are not readable from a metadata
21955
- * document: the result says so and stays could-not-judge unless an element is contradicted.
22137
+ * SERVED half (--url, or a launched server): every element the wire can answer is READ; every other is NAMED with
22138
+ * the reason it is not read. See `judgeServed` for the decision per element.
21956
22139
  */
21957
22140
  runServed(runtime) {
21958
- const got = servedOrCouldNotJudge(this.id, "S-5", runtime);
21959
- if ("cnj" in got) return got.cnj;
21960
- const as = got.served.authServer;
21961
- const anchor = `${runtime.root} (served authorization-server metadata)`;
21962
- if (as.kind !== "document") {
21963
- return couldNotJudge(
21964
- this.id,
21965
- anchor,
21966
- `the authorization-server metadata was not read: ${as.kind === "not-run" ? as.reason : `${as.url}: ${as.reason}`} (S-5 (g)(l))`
21967
- );
22141
+ return judgeServed(this.id, runtime);
22142
+ }
22143
+ };
22144
+ var JWT_BEARER = "urn:ietf:params:oauth:grant-type:jwt-bearer";
22145
+ function unreadGet(g) {
22146
+ if (g.status === void 0) return g.detail ?? "no answer";
22147
+ if (g.status >= 200 && g.status < 300)
22148
+ return g.json ? void 0 : `HTTP ${g.status} with no JSON object`;
22149
+ return `HTTP ${g.status}`;
22150
+ }
22151
+ var isNotServed = (g) => g.status !== void 0 && g.status >= 400 && g.status < 500;
22152
+ function noPrmAt(g) {
22153
+ if (isNotServed(g)) return `HTTP ${g.status}`;
22154
+ if (unreadGet(g) !== void 0) return void 0;
22155
+ const doc = g.json;
22156
+ return "resource" in doc || "authorization_servers" in doc ? void 0 : `HTTP ${g.status}, a JSON object with neither resource nor authorization_servers`;
22157
+ }
22158
+ function prmElements(docs) {
22159
+ if (!docs)
22160
+ return [
22161
+ {
22162
+ id: "f",
22163
+ status: "unread",
22164
+ text: "(f) the PRM copies were not recorded by this run (a runtime record that predates the read)"
22165
+ }
22166
+ ];
22167
+ if (docs.kind === "not-run")
22168
+ return [{ id: "f", status: "unread", text: `(f) the PRM was not read: ${docs.reason}` }];
22169
+ const copies = [docs.prm.suffixed, docs.prm.bare].filter((g) => g !== void 0);
22170
+ if (copies.every((g) => noPrmAt(g) !== void 0))
22171
+ return [
22172
+ {
22173
+ id: "f",
22174
+ status: "unread",
22175
+ text: `(f) no PRM is served (${copies.map((g) => `${noPrmAt(g)} at ${g.url}`).join(", ")}): whether S-5 applies to this server, ${S5_CONDITION}, is a statement of its source tree, not of the wire`
22176
+ }
22177
+ ];
22178
+ const out = [];
22179
+ for (const g of copies) {
22180
+ const none = noPrmAt(g);
22181
+ if (none !== void 0) {
22182
+ out.push({ id: "f", status: "red", text: `(f) the PRM is not served at ${g.url} (${none})` });
22183
+ continue;
21968
22184
  }
21969
- const doc = as.document;
21970
- const at = `served at ${as.url}`;
21971
- const reds = [];
21972
- const oks = [];
21973
- const unreadable2 = [];
21974
- const cimd = doc.client_id_metadata_document_supported;
21975
- if (cimd === true) oks.push("client_id_metadata_document_supported true");
21976
- else
21977
- reds.push(
21978
- `(g) the served AS metadata ${cimd === void 0 ? "does not announce" : `announces ${JSON.stringify(cimd)} for`} client_id_metadata_document_supported: true`
21979
- );
21980
- const methods = doc.token_endpoint_auth_methods_supported;
21981
- if (Array.isArray(methods)) {
21982
- if (methods.includes("none"))
21983
- oks.push(`"none" in token_endpoint_auth_methods_supported ${JSON.stringify(methods)}`);
21984
- else
21985
- reds.push(
21986
- `(g) the served AS metadata lists ${JSON.stringify(methods)} in token_endpoint_auth_methods_supported, without "none"`
21987
- );
21988
- } else if (methods === void 0) {
21989
- reds.push(
21990
- '(g) the served AS metadata has no token_endpoint_auth_methods_supported (so no "none")'
21991
- );
21992
- } else {
21993
- unreadable2.push(
21994
- `token_endpoint_auth_methods_supported is served as ${JSON.stringify(methods)}, not an array`
21995
- );
22185
+ const why = unreadGet(g);
22186
+ if (why) {
22187
+ out.push({ id: "f", status: "unread", text: `(f) the PRM at ${g.url} was not read: ${why}` });
22188
+ continue;
21996
22189
  }
21997
- const iss = doc.authorization_response_iss_parameter_supported;
21998
- if (iss === true) oks.push("authorization_response_iss_parameter_supported true");
22190
+ const resource = g.json.resource;
22191
+ if (typeof resource !== "string")
22192
+ out.push({
22193
+ id: "f",
22194
+ status: "red",
22195
+ text: `(f) the PRM served at ${g.url} has no string resource (${JSON.stringify(resource) ?? "absent"})`
22196
+ });
22197
+ else if (resource !== docs.mcpUrl)
22198
+ out.push({
22199
+ id: "f",
22200
+ status: "red",
22201
+ text: `(f) the PRM served at ${g.url} names resource ${JSON.stringify(resource)}, not the MCP URL ${docs.mcpUrl} (path included)`
22202
+ });
22203
+ }
22204
+ if (out.length === 0)
22205
+ out.push({
22206
+ id: "f",
22207
+ status: "ok",
22208
+ text: `(f) the PRM resource equals the MCP URL ${docs.mcpUrl} at ${copies.map((g) => g.url).join(" and at ")}`
22209
+ });
22210
+ return out;
22211
+ }
22212
+ function asElements(as) {
22213
+ if (as.kind !== "document") {
22214
+ const why = `the authorization-server metadata was not read: ${as.kind === "not-run" ? as.reason : `${as.url}: ${as.reason}`}`;
22215
+ return ["g", "j", "l"].map((id) => ({ id, status: "unread", text: `(${id}) ${why}` }));
22216
+ }
22217
+ const doc = as.document;
22218
+ const out = [];
22219
+ const g = [];
22220
+ const cimd = doc.client_id_metadata_document_supported;
22221
+ if (cimd === true) g.push("client_id_metadata_document_supported true");
22222
+ else
22223
+ out.push({
22224
+ id: "g",
22225
+ status: "red",
22226
+ text: `(g) the served AS metadata ${cimd === void 0 ? "does not announce" : `announces ${JSON.stringify(cimd)} for`} client_id_metadata_document_supported: true`
22227
+ });
22228
+ const methods = doc.token_endpoint_auth_methods_supported;
22229
+ if (Array.isArray(methods)) {
22230
+ if (methods.includes("none"))
22231
+ g.push(`"none" in token_endpoint_auth_methods_supported ${JSON.stringify(methods)}`);
21999
22232
  else
22000
- reds.push(
22001
- `(l) the served AS metadata ${iss === void 0 ? "does not announce" : `announces ${JSON.stringify(iss)} for`} authorization_response_iss_parameter_supported: true (RFC 9207)`
22002
- );
22003
- if (reds.length > 0) {
22004
- return {
22005
- id: this.id,
22006
- anchor,
22007
- state: "non-conforming",
22008
- verdict: `${reds.join("; ")} (${at}) (S-5 (g)(l), read on the wire)`
22009
- };
22010
- }
22011
- return couldNotJudge(
22012
- this.id,
22013
- anchor,
22014
- `(g) and (l) hold on the served metadata (${at}): ${oks.join("; ")}${unreadable2.length > 0 ? `; unreadable: ${unreadable2.join("; ")}` : ""}. Not read over this surface: (f) PRM binding, (h) redirects, (i) /authorize sign-in, (j) jwt-bearer, (k) OIDC/UserInfo, and \`iss\` on every authorization response (probes or human verdicts) (S-5 (f)..(l))`
22015
- );
22233
+ out.push({
22234
+ id: "g",
22235
+ status: "red",
22236
+ text: `(g) the served AS metadata lists ${JSON.stringify(methods)} in token_endpoint_auth_methods_supported, without "none"`
22237
+ });
22238
+ } else if (methods === void 0) {
22239
+ out.push({
22240
+ id: "g",
22241
+ status: "red",
22242
+ text: '(g) the served AS metadata has no token_endpoint_auth_methods_supported (so no "none")'
22243
+ });
22244
+ } else {
22245
+ out.push({
22246
+ id: "g",
22247
+ status: "unread",
22248
+ text: `(g) token_endpoint_auth_methods_supported is served as ${JSON.stringify(methods)}, not an array`
22249
+ });
22016
22250
  }
22251
+ if (g.length === 2)
22252
+ out.push({ id: "g", status: "ok", text: `(g) served at ${as.url}: ${g.join(", ")}` });
22253
+ const grants = doc.grant_types_supported;
22254
+ if (Array.isArray(grants) && grants.includes(JWT_BEARER))
22255
+ out.push({
22256
+ id: "j",
22257
+ status: "unread",
22258
+ text: `(j) the jwt-bearer grant is announced at ${as.url}: whether it keeps trusted issuers PER TENANT is served by no metadata (a human verdict)`
22259
+ });
22260
+ else if (grants === void 0 || Array.isArray(grants))
22261
+ out.push({
22262
+ id: "j",
22263
+ status: "unestablished",
22264
+ text: "(j) no jwt-bearer grant announced in the served AS metadata, owed only to a server offered to Team/Enterprise clients, which no source states"
22265
+ });
22266
+ else
22267
+ out.push({
22268
+ id: "j",
22269
+ status: "unread",
22270
+ text: `(j) grant_types_supported is served as ${JSON.stringify(grants)}, not an array`
22271
+ });
22272
+ const iss = doc.authorization_response_iss_parameter_supported;
22273
+ if (iss === true)
22274
+ out.push({
22275
+ id: "l",
22276
+ status: "ok",
22277
+ text: `(l) authorization_response_iss_parameter_supported true at ${as.url}`
22278
+ });
22279
+ else
22280
+ out.push({
22281
+ id: "l",
22282
+ status: "red",
22283
+ text: `(l) the served AS metadata ${iss === void 0 ? "does not announce" : `announces ${JSON.stringify(iss)} for`} authorization_response_iss_parameter_supported: true (RFC 9207)`
22284
+ });
22285
+ return out;
22286
+ }
22287
+ function oidcElements(docs) {
22288
+ if (!docs || docs.kind === "not-run")
22289
+ return [
22290
+ {
22291
+ id: "k",
22292
+ status: "unread",
22293
+ text: `(k) the OIDC discovery was not read: ${docs ? docs.reason : "a runtime record that predates the read"}`
22294
+ }
22295
+ ];
22296
+ const o = docs.oidc;
22297
+ if ("skipped" in o)
22298
+ return [
22299
+ { id: "k", status: "unread", text: `(k) the OIDC discovery was not read: ${o.skipped}` }
22300
+ ];
22301
+ if (isNotServed(o))
22302
+ return [
22303
+ {
22304
+ id: "k",
22305
+ status: "unestablished",
22306
+ text: `(k) no OIDC discovery published at ${o.url} (HTTP ${o.status}), owed only to a server aimed at a host that binds enterprise accounts, which no source states`
22307
+ }
22308
+ ];
22309
+ const why = unreadGet(o);
22310
+ if (why)
22311
+ return [
22312
+ {
22313
+ id: "k",
22314
+ status: "unread",
22315
+ text: `(k) the OIDC discovery at ${o.url} was not read: ${why}`
22316
+ }
22317
+ ];
22318
+ const doc = o.json;
22319
+ const out = [];
22320
+ const scopes = doc.scopes_supported;
22321
+ if (Array.isArray(scopes)) {
22322
+ const missing = ["openid", "email"].filter((x) => !scopes.includes(x));
22323
+ if (missing.length > 0)
22324
+ out.push({
22325
+ id: "k",
22326
+ status: "red",
22327
+ text: `(k) OIDC discovery served at ${o.url} lacks ${missing.map((x) => JSON.stringify(x)).join(" and ")} in scopes_supported`
22328
+ });
22329
+ } else {
22330
+ out.push({
22331
+ id: "k",
22332
+ status: "unread",
22333
+ text: `(k) OIDC discovery served at ${o.url} states no scopes_supported array, so openid and email are unread`
22334
+ });
22335
+ }
22336
+ const userinfo = doc.userinfo_endpoint;
22337
+ if (typeof userinfo !== "string")
22338
+ out.push({
22339
+ id: "k",
22340
+ status: "red",
22341
+ text: `(k) OIDC discovery served at ${o.url} lacks a userinfo_endpoint`
22342
+ });
22343
+ if (out.length > 0) return out;
22344
+ const claims = doc.claims_supported;
22345
+ if (Array.isArray(claims) && claims.includes("email") && claims.includes("email_verified"))
22346
+ return [
22347
+ {
22348
+ id: "k",
22349
+ status: "ok",
22350
+ text: `(k) OIDC discovery served at ${o.url} with openid and email, userinfo_endpoint ${userinfo}, claims email and email_verified`
22351
+ }
22352
+ ];
22353
+ return [
22354
+ {
22355
+ id: "k",
22356
+ status: "unread",
22357
+ text: `(k) OIDC discovery served at ${o.url} with openid and email and userinfo_endpoint ${userinfo}, but claims_supported does not list email and email_verified (an inexhaustive list): what UserInfo returns needs an authenticated GET`
22358
+ }
22359
+ ];
22360
+ }
22361
+ var H_UNREAD = {
22362
+ id: "h",
22363
+ status: "unread",
22364
+ text: "(h) needs an authorization-request probe: only a request the AS answers proves it accepts https://claude.ai/api/mcp/auth_callback and a loopback redirect on any port, and no known client document lists the claude.ai callback"
22017
22365
  };
22366
+ var I_UNREAD = {
22367
+ id: "i",
22368
+ status: "unread",
22369
+ text: "(i) whether /authorize authenticates a person is a human verdict plus a sign-in probe with a test client on a development deployment, stated by no metadata"
22370
+ };
22371
+ var ISS_UNREAD = {
22372
+ id: "l",
22373
+ status: "unread",
22374
+ text: "(l) `iss` on every authorization response, error responses included, needs an authorization-request probe"
22375
+ };
22376
+ function judgeServed(id, runtime) {
22377
+ let facts;
22378
+ let note = "";
22379
+ if (!runtime.served && runtime.publicAuth) {
22380
+ facts = runtime.publicAuth;
22381
+ note = ` [the MCP handshake failed: ${runtime.launchError ?? "no reason given"}; the public authorization reads were made]`;
22382
+ } else {
22383
+ const got = servedOrCouldNotJudge(id, "S-5", runtime);
22384
+ if ("cnj" in got) return got.cnj;
22385
+ facts = got.served;
22386
+ }
22387
+ const anchor = `${runtime.root} (served authorization-server metadata)`;
22388
+ const els = [
22389
+ ...prmElements(facts.authDocs),
22390
+ ...asElements(facts.authServer),
22391
+ H_UNREAD,
22392
+ I_UNREAD,
22393
+ ...oidcElements(facts.authDocs),
22394
+ ISS_UNREAD
22395
+ ].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
22396
+ const of = (st) => els.filter((e) => e.status === st).map((e) => e.text);
22397
+ const [reds, oks, uns, unread2] = [of("red"), of("ok"), of("unestablished"), of("unread")];
22398
+ if (reds.length > 0)
22399
+ return {
22400
+ id,
22401
+ anchor,
22402
+ state: "non-conforming",
22403
+ verdict: `${reds.join("; ")} (S-5 (f)..(l), read on the wire)${unread2.length > 0 ? `; also not read on the wire: ${unread2.join("; ")}` : ""}${note}`
22404
+ };
22405
+ const parts = [
22406
+ oks.length > 0 ? `established: ${oks.join("; ")}` : "",
22407
+ uns.length > 0 ? `unestablished condition: ${uns.join("; ")}` : ""
22408
+ ].filter(Boolean);
22409
+ if (unread2.length === 0)
22410
+ return {
22411
+ id,
22412
+ anchor,
22413
+ state: "present",
22414
+ verdict: `${parts.join(". ")} (S-5 (f)..(l), read on the wire)${note}`
22415
+ };
22416
+ return couldNotJudge(
22417
+ id,
22418
+ anchor,
22419
+ `no element (f)..(l) is contradicted on the wire. ${parts.length > 0 ? `${parts.join(". ")}. ` : ""}not read on the wire: ${unread2.join("; ")} (S-5 (f)..(l))${note}`
22420
+ );
22421
+ }
22018
22422
 
22019
22423
  // src/detectors/s8-token-passthrough.ts
22020
22424
  var INCOMING_RE = new RegExp(
@@ -24671,12 +25075,12 @@ function lineAt2(text, offset) {
24671
25075
  for (let i = 0; i < offset && i < text.length; i++) if (text.charCodeAt(i) === 10) n++;
24672
25076
  return n;
24673
25077
  }
24674
- var OPEN2 = { "(": ")", "[": "]", "{": "}" };
25078
+ var OPEN3 = { "(": ")", "[": "]", "{": "}" };
24675
25079
  function matchClose2(m, open) {
24676
25080
  const stack = [];
24677
25081
  for (let i = open; i < m.length; i++) {
24678
25082
  const ch = m[i];
24679
- if (OPEN2[ch] !== void 0) stack.push(OPEN2[ch]);
25083
+ if (OPEN3[ch] !== void 0) stack.push(OPEN3[ch]);
24680
25084
  else if (ch === ")" || ch === "]" || ch === "}") {
24681
25085
  if (stack.pop() !== ch) return -1;
24682
25086
  if (stack.length === 0) return i;
@@ -24684,13 +25088,13 @@ function matchClose2(m, open) {
24684
25088
  }
24685
25089
  return -1;
24686
25090
  }
24687
- function splitTop2(m, from, to) {
25091
+ function splitTop3(m, from, to) {
24688
25092
  const parts = [];
24689
25093
  let depth = 0;
24690
25094
  let start = from;
24691
25095
  for (let i = from; i < to; i++) {
24692
25096
  const ch = m[i];
24693
- if (OPEN2[ch] !== void 0) depth++;
25097
+ if (OPEN3[ch] !== void 0) depth++;
24694
25098
  else if (ch === ")" || ch === "]" || ch === "}") depth--;
24695
25099
  else if (ch === "," && depth === 0) {
24696
25100
  parts.push([start, i]);
@@ -24820,7 +25224,7 @@ function definitionOf(name, files) {
24820
25224
  let depth = 0;
24821
25225
  for (let i = hit.index + hit[0].length; i < f.m.length; i++) {
24822
25226
  const ch = f.m[i];
24823
- if (OPEN2[ch] !== void 0) {
25227
+ if (OPEN3[ch] !== void 0) {
24824
25228
  depth++;
24825
25229
  } else if (ch === ")" || ch === "]" || ch === "}") {
24826
25230
  depth--;
@@ -24853,7 +25257,7 @@ function readHelper(name, files, seen = /* @__PURE__ */ new Set(), depth = 0) {
24853
25257
  }
24854
25258
  return { forwards, optional };
24855
25259
  }
24856
- var IDENT3 = /^\s*([A-Za-z_$][\w$]*)\s*(?:as\s+[\w$.<>[\]]+\s*)?$/;
25260
+ var IDENT4 = /^\s*([A-Za-z_$][\w$]*)\s*(?:as\s+[\w$.<>[\]]+\s*)?$/;
24857
25261
  function esc6(name) {
24858
25262
  return name.replace(/\$/g, "\\$");
24859
25263
  }
@@ -24885,7 +25289,7 @@ function enclosingCall(m, offset) {
24885
25289
  return void 0;
24886
25290
  const close2 = matchClose2(m, i);
24887
25291
  if (close2 < 0) return void 0;
24888
- const index = splitTop2(m, i + 1, close2).findIndex(([a, b]) => offset >= a && offset < b);
25292
+ const index = splitTop3(m, i + 1, close2).findIndex(([a, b]) => offset >= a && offset < b);
24889
25293
  return index < 0 ? void 0 : { callee: callee[1], index };
24890
25294
  }
24891
25295
  }
@@ -24902,7 +25306,7 @@ function paramOf(callee, index, files) {
24902
25306
  const open = hit.index + hit[0].length - 1;
24903
25307
  const close2 = matchClose2(fr.m, open);
24904
25308
  if (close2 < 0) return { file: fr, text: void 0 };
24905
- const part = splitTop2(fr.m, open + 1, close2)[index];
25309
+ const part = splitTop3(fr.m, open + 1, close2)[index];
24906
25310
  return part ? { file: fr, text: fr.m.slice(part[0], part[1]).trim(), span: part } : { file: fr, text: void 0 };
24907
25311
  }
24908
25312
  return void 0;
@@ -24970,8 +25374,8 @@ function readFetchers(files, scan, onCall) {
24970
25374
  const open = hit.index + hit[0].length - 1;
24971
25375
  const close2 = matchClose2(fr.m, open);
24972
25376
  if (close2 < 0) continue;
24973
- const parts = splitTop2(fr.m, open + 1, close2);
24974
- const first = parts[0] ? IDENT3.exec(fr.m.slice(parts[0][0], parts[0][1])) : null;
25377
+ const parts = splitTop3(fr.m, open + 1, close2);
25378
+ const first = parts[0] ? IDENT4.exec(fr.m.slice(parts[0][0], parts[0][1])) : null;
24975
25379
  if (!first) continue;
24976
25380
  const fn = enclosingFn(fr.m, hit.index, first[1]);
24977
25381
  if (!fn) continue;
@@ -25049,7 +25453,7 @@ function readFetchers(files, scan, onCall) {
25049
25453
  cnj(at, o, "has a call here that could not be read");
25050
25454
  continue;
25051
25455
  }
25052
- const cp = splitTop2(at.m, po + 1, pc);
25456
+ const cp = splitTop3(at.m, po + 1, pc);
25053
25457
  const raw = cp[0] ? at.text.slice(cp[0][0], cp[0][1]) : "";
25054
25458
  const lit = /^\s*(?:\/\/[^\n]*\n\s*)*["'`]([\w/]+:[\w]+)["'`]/.exec(raw);
25055
25459
  const ref = /^\s*(?:api|internal)\.([\w]+)\.([\w]+)/.exec(raw);
@@ -25271,7 +25675,7 @@ function scanS28(tree) {
25271
25675
  scan.calls++;
25272
25676
  const line = lineAt2(text, hit.index);
25273
25677
  const tool = toolNameBefore(text, hit.index);
25274
- const parts = splitTop2(m, open + 1, close2);
25678
+ const parts = splitTop3(m, open + 1, close2);
25275
25679
  let door;
25276
25680
  if (parts[0]) {
25277
25681
  const rawFirst = text.slice(parts[0][0], parts[0][1]);
@@ -25719,7 +26123,7 @@ function matchClose3(m, open) {
25719
26123
  }
25720
26124
  return -1;
25721
26125
  }
25722
- function splitTop3(m, from, to) {
26126
+ function splitTop4(m, from, to) {
25723
26127
  const out = [];
25724
26128
  let depth = 0;
25725
26129
  let start = from;
@@ -25810,7 +26214,7 @@ function inlineNarrowing(m, start, close2, end) {
25810
26214
  const open = p + chain[0].length - 1;
25811
26215
  const cbClose = matchClose3(m, open);
25812
26216
  if (cbClose < 0) return { unreadable: `a .${chain[1]}( whose closing paren is not found` };
25813
- const argSpans = splitTop3(m, open + 1, cbClose);
26217
+ const argSpans = splitTop4(m, open + 1, cbClose);
25814
26218
  const cbSpan = argSpans[0];
25815
26219
  const cb = cbSpan ? m.slice(cbSpan[0], cbSpan[1]) : "";
25816
26220
  if (chain[1] === "filter") {
@@ -25903,7 +26307,7 @@ function scanS35(tree) {
25903
26307
  if (close2 < 0) continue;
25904
26308
  res.calls++;
25905
26309
  const anchor = `${file.rel}:${lineAt3(m, start)}`;
25906
- const parts = splitTop3(m, open + 1, close2);
26310
+ const parts = splitTop4(m, open + 1, close2);
25907
26311
  const first = parts[0] ? raw.slice(parts[0][0], parts[0][1]) : "";
25908
26312
  const cast = String.raw`(?:\s+as\s+[\w$.<>[\] ]+)?\s*$`;
25909
26313
  const lit = new RegExp(String.raw`^\s*["'\x60]([\w/]+:[\w]+)["'\x60]${cast}`).exec(first);
@@ -28369,7 +28773,7 @@ function scanS42(tree) {
28369
28773
  if (close2 < 0) continue;
28370
28774
  const at = `${f.rel}:${lineAt2(text, hit.index)}`;
28371
28775
  const tool = toolNameBefore(text, hit.index).name ?? "(unnamed tool)";
28372
- const parts = splitTop2(m, open + 1, close2);
28776
+ const parts = splitTop3(m, open + 1, close2);
28373
28777
  const first = parts[0] ? text.slice(parts[0][0], parts[0][1]) : "";
28374
28778
  const lit = /^\s*["'`]([\w/]+:[\w]+)["'`]/.exec(first);
28375
28779
  const ref = /^\s*(?:api|internal)\.([\w]+)\.([\w]+)/.exec(first);
@@ -32428,7 +32832,7 @@ function judgeAttempt(a) {
32428
32832
  return { kind: "unread", text: `${at} (neither accepted nor refused)` };
32429
32833
  }
32430
32834
  function runServed5(runtime) {
32431
- const r = judgeServed(runtime);
32835
+ const r = judgeServed2(runtime);
32432
32836
  if (!runtime.launchError || !runtime.publicAuth) return r;
32433
32837
  const note = ` [the MCP handshake failed: ${runtime.launchError}; the public authorization reads were made]`;
32434
32838
  return {
@@ -32437,7 +32841,7 @@ function runServed5(runtime) {
32437
32841
  ...r.reason !== void 0 ? { reason: `${r.reason}${note}` } : {}
32438
32842
  };
32439
32843
  }
32440
- function judgeServed(runtime) {
32844
+ function judgeServed2(runtime) {
32441
32845
  let facts;
32442
32846
  if (!runtime.served && runtime.publicAuth) facts = runtime.publicAuth;
32443
32847
  else {
@@ -36784,10 +37188,10 @@ let transport;
36784
37188
  const publicAuthAfterFailure = async () => {
36785
37189
  if (plan.kind !== "http") return undefined;
36786
37190
  try {
36787
- const authServer = await readAuthServer();
37191
+ const { authServer, authDocs } = await readAuth();
36788
37192
  const authorize = authServer.kind === "document" ? await probeAuthorize(authServer.document) : { kind: "not-run", reason: "the authorization-server metadata was not read, so no authorization_endpoint is known" };
36789
37193
  const discovery = await readDiscovery().catch((e) => ({ kind: "not-run", reason: "the discovery reads failed: " + (e && e.message ? e.message : String(e)) }));
36790
- return { authServer, authorize, discovery };
37194
+ return { authServer, authDocs, authorize, discovery };
36791
37195
  } catch (e) { return { authServer: { kind: "unavailable", url: plan.url, reason: "the public read failed: " + (e && e.message ? e.message : String(e)) } }; }
36792
37196
  };
36793
37197
  const fail = (msg) => { if (settled) return; settled = true; Promise.resolve(transport && transport.close()).then(() => publicAuthAfterFailure()).catch(() => undefined).then((publicAuth) => done({ launchError: msg, ...(publicAuth ? { publicAuth } : {}) })); };
@@ -36962,22 +37366,29 @@ const getPublicJson = async (url) => {
36962
37366
  // The authorization server the PRM names (RFC 9728), then its metadata (RFC 8414). The doctor fetches
36963
37367
  // ONLY a URL on the endpoint's own origin (so the scheme the caller already vetted): a server that names another origin never makes the
36964
37368
  // doctor request it (no SSRF from the audit tool); that case is reported as unavailable, naming it.
36965
- const readAuthServer = async () => {
37369
+ // S-5 (f)(k): the two PRM copies (path-suffixed, bare) are RECORDED as served, whatever they answer, and the OIDC
37370
+ // discovery is read at the same-origin issuer (OIDC Discovery 1.0: the issuer, then /.well-known/openid-configuration).
37371
+ const readAuth = async () => {
36966
37372
  const ep = new URL(plan.url);
36967
- const prmUrls = [ep.origin + "/.well-known/oauth-protected-resource" + (ep.pathname === "/" ? "" : ep.pathname), ep.origin + "/.well-known/oauth-protected-resource"];
37373
+ const mcpUrl = ep.origin + ep.pathname;
37374
+ const bareUrl = ep.origin + "/.well-known/oauth-protected-resource";
37375
+ const suffixedUrl = ep.pathname === "/" ? undefined : bareUrl + ep.pathname;
37376
+ const [suffixed, bare] = await Promise.all([suffixedUrl ? publicGet(suffixedUrl, "application/json") : Promise.resolve(undefined), publicGet(bareUrl, "application/json")]);
37377
+ const prm = { ...(suffixed ? { suffixed } : {}), bare };
37378
+ const docs = (oidc) => ({ kind: "probed", mcpUrl, prm, oidc });
36968
37379
  let issuer;
36969
- for (const u of prmUrls) {
36970
- const r = await getPublicJson(u);
36971
- const names = r.ok && Array.isArray(r.doc.authorization_servers) ? r.doc.authorization_servers.filter((x) => typeof x === "string") : [];
37380
+ for (const r of [suffixed, bare]) {
37381
+ const names = r && r.status === 200 && r.json && Array.isArray(r.json.authorization_servers) ? r.json.authorization_servers.filter((x) => typeof x === "string") : [];
36972
37382
  if (names.length > 0) { issuer = names[0]; break; }
36973
37383
  }
36974
- if (!issuer) return { kind: "unavailable", url: prmUrls[0], reason: "the protected-resource metadata names no authorization server (read at the suffixed and the bare path)" };
36975
- let iu; try { iu = new URL(issuer); } catch { return { kind: "unavailable", url: prmUrls[0], reason: "the protected-resource metadata names an authorization server that is not a URL" }; }
36976
- if (iu.origin !== ep.origin) return { kind: "unavailable", url: iu.origin, reason: "the authorization server is on another origin (" + iu.host + "): not fetched from here, only a same-origin authorization server is read" };
37384
+ if (!issuer) return { authServer: { kind: "unavailable", url: suffixedUrl || bareUrl, reason: "the protected-resource metadata names no authorization server (read at the suffixed and the bare path)" }, authDocs: docs({ skipped: "the protected-resource metadata names no authorization server, so no issuer is known" }) };
37385
+ let iu; try { iu = new URL(issuer); } catch { return { authServer: { kind: "unavailable", url: suffixedUrl || bareUrl, reason: "the protected-resource metadata names an authorization server that is not a URL" }, authDocs: docs({ skipped: "the authorization server named is not a URL" }) }; }
37386
+ if (iu.origin !== ep.origin) return { authServer: { kind: "unavailable", url: iu.origin, reason: "the authorization server is on another origin (" + iu.host + "): not fetched from here, only a same-origin authorization server is read" }, authDocs: docs({ skipped: "the authorization server is on another origin (" + iu.host + "): its OIDC discovery is not fetched from here" }) };
36977
37387
  const url = iu.origin + "/.well-known/oauth-authorization-server" + (iu.pathname === "/" ? "" : iu.pathname);
36978
- const r = await getPublicJson(url);
36979
- if (!r.ok) return { kind: "unavailable", url, reason: r.reason };
36980
- return { kind: "document", url, status: r.status, document: r.doc };
37388
+ const [r, oidc] = await Promise.all([getPublicJson(url), publicGet(iu.origin + iu.pathname.replace(/\/$/, "") + "/.well-known/openid-configuration", "application/json")]);
37389
+ const authDocs = docs(oidc);
37390
+ if (!r.ok) return { authServer: { kind: "unavailable", url, reason: r.reason }, authDocs };
37391
+ return { authServer: { kind: "document", url, status: r.status, document: r.doc }, authDocs };
36981
37392
  };
36982
37393
  // S-46 served half: for each known CIMD client, read ITS metadata document (the redirect URIs as the client sends
36983
37394
  // them), then start one authorization request per redirect at the served authorization_endpoint. NO credential is
@@ -37053,9 +37464,10 @@ const extras = async (served) => {
37053
37464
  served.versionProbe = { kind: "not-run", reason: "stdio transport: the MCP-Protocol-Version header exists on HTTP only" };
37054
37465
  served.authServer = { kind: "not-run", reason: "stdio transport: no authorization-server metadata is served" };
37055
37466
  served.authorize = { kind: "not-run", reason: "stdio transport: no authorization endpoint is served" };
37467
+ served.authDocs = { kind: "not-run", reason: "stdio transport: no protected-resource metadata is served" };
37056
37468
  return;
37057
37469
  }
37058
- const [vp, as, discovery] = await Promise.all([
37470
+ const [vp, auth, discovery] = await Promise.all([
37059
37471
  (async () => {
37060
37472
  const v = transport.negotiatedVersion();
37061
37473
  if (!v) return { kind: "not-run", reason: "no protocol version was negotiated, so no supported-version control request can be sent" };
@@ -37065,12 +37477,14 @@ const extras = async (served) => {
37065
37477
  return { kind: "statuses", supportedVersion: v, supported, unsupported };
37066
37478
  } catch (e) { return { kind: "not-run", reason: "the header probe failed: " + (e && e.message ? e.message : String(e)) }; }
37067
37479
  })(),
37068
- readAuthServer().catch((e) => ({ kind: "unavailable", url: plan.url, reason: "the read failed: " + (e && e.message ? e.message : String(e)) })),
37480
+ readAuth().catch((e) => ({ authServer: { kind: "unavailable", url: plan.url, reason: "the read failed: " + (e && e.message ? e.message : String(e)) }, authDocs: { kind: "not-run", reason: "the read failed: " + (e && e.message ? e.message : String(e)) } })),
37069
37481
  readDiscovery().catch((e) => ({ kind: "not-run", reason: "the discovery reads failed: " + (e && e.message ? e.message : String(e)) })),
37070
37482
  ]);
37071
37483
  served.discovery = discovery;
37072
37484
  served.versionProbe = vp;
37485
+ const as = auth.authServer;
37073
37486
  served.authServer = as;
37487
+ served.authDocs = auth.authDocs;
37074
37488
  served.authorize = as.kind === "document"
37075
37489
  ? await probeAuthorize(as.document).catch((e) => ({ kind: "not-run", reason: "the sign-in probe failed: " + (e && e.message ? e.message : String(e)) }))
37076
37490
  : { kind: "not-run", reason: "the authorization-server metadata was not read, so no authorization_endpoint is known" };
@@ -37349,6 +37763,7 @@ function readServed(raw) {
37349
37763
  reason: isObj6(as) && as.kind === "not-run" && typeof as.reason === "string" ? as.reason : "unreadable authorization-server record"
37350
37764
  };
37351
37765
  const authorize = readAuthorize(raw.authorize);
37766
+ const authDocs = readAuthDocs(raw.authDocs);
37352
37767
  const init = isObj6(raw.initialize) ? raw.initialize : void 0;
37353
37768
  const discovery = readDiscovery(raw.discovery);
37354
37769
  return {
@@ -37359,6 +37774,7 @@ function readServed(raw) {
37359
37774
  versionProbe,
37360
37775
  authServer,
37361
37776
  ...authorize ? { authorize } : {},
37777
+ ...authDocs ? { authDocs } : {},
37362
37778
  ...init ? {
37363
37779
  initialize: {
37364
37780
  resultKeys: Array.isArray(init.resultKeys) ? init.resultKeys.map(String) : [],
@@ -37412,19 +37828,39 @@ function readToolCall(raw) {
37412
37828
  if (r.kind === "no-answer") return { tool, kind: "no-answer", reason };
37413
37829
  return { tool, kind: "no-answer", reason: "unreadable tool-call record" };
37414
37830
  }
37415
- function readDiscovery(raw) {
37831
+ function readGet(g) {
37832
+ const r = isObj6(g) ? g : {};
37833
+ return {
37834
+ url: typeof r.url === "string" ? r.url : "<unnamed url>",
37835
+ ...typeof r.status === "number" ? { status: r.status } : {},
37836
+ ...typeof r.contentType === "string" ? { contentType: r.contentType } : {},
37837
+ ...isObj6(r.json) ? { json: r.json } : {},
37838
+ ...typeof r.text === "string" ? { text: r.text } : {},
37839
+ ...typeof r.detail === "string" ? { detail: r.detail } : isObj6(g) ? {} : { detail: "unreadable GET record" }
37840
+ };
37841
+ }
37842
+ function readAuthDocs(raw) {
37416
37843
  if (raw === void 0) return void 0;
37417
- const get = (g) => {
37418
- const r = isObj6(g) ? g : {};
37844
+ if (isObj6(raw) && raw.kind === "probed" && typeof raw.mcpUrl === "string" && isObj6(raw.prm) && isObj6(raw.prm.bare)) {
37845
+ const oidc = isObj6(raw.oidc) && typeof raw.oidc.skipped === "string" ? { skipped: raw.oidc.skipped } : readGet(raw.oidc);
37419
37846
  return {
37420
- url: typeof r.url === "string" ? r.url : "<unnamed url>",
37421
- ...typeof r.status === "number" ? { status: r.status } : {},
37422
- ...typeof r.contentType === "string" ? { contentType: r.contentType } : {},
37423
- ...isObj6(r.json) ? { json: r.json } : {},
37424
- ...typeof r.text === "string" ? { text: r.text } : {},
37425
- ...typeof r.detail === "string" ? { detail: r.detail } : isObj6(g) ? {} : { detail: "unreadable GET record" }
37847
+ kind: "probed",
37848
+ mcpUrl: raw.mcpUrl,
37849
+ prm: {
37850
+ ...raw.prm.suffixed !== void 0 ? { suffixed: readGet(raw.prm.suffixed) } : {},
37851
+ bare: readGet(raw.prm.bare)
37852
+ },
37853
+ oidc
37426
37854
  };
37855
+ }
37856
+ return {
37857
+ kind: "not-run",
37858
+ reason: isObj6(raw) && raw.kind === "not-run" && typeof raw.reason === "string" ? raw.reason : "unreadable protected-resource record"
37427
37859
  };
37860
+ }
37861
+ function readDiscovery(raw) {
37862
+ if (raw === void 0) return void 0;
37863
+ const get = readGet;
37428
37864
  if (isObj6(raw) && raw.kind === "probed" && Array.isArray(raw.cards) && isObj6(raw.landing))
37429
37865
  return { kind: "probed", cards: raw.cards.map(get), landing: get(raw.landing) };
37430
37866
  return {
@@ -37639,6 +38075,7 @@ function introspect(plan, root, evalSource, expectedCommit, evalsNote, secrets)
37639
38075
  publicAuth: {
37640
38076
  authServer: pub.authServer,
37641
38077
  ...pub.authorize ? { authorize: pub.authorize } : {},
38078
+ ...pub.authDocs ? { authDocs: pub.authDocs } : {},
37642
38079
  ...pub.discovery ? { discovery: pub.discovery } : {}
37643
38080
  }
37644
38081
  } : {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vantageos/mcp-doctor",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Static MCP conformance checker: audits an MCP server source tree against the MCP 2026-07-28 standard and emits a conformance-diff table (file:line | present | absent | non-conforming | verdict).",
5
5
  "type": "module",
6
6
  "main": "./dist/doctor.js",