@vantageos/mcp-doctor 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,26 @@ 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.18.0 — 2026-11-02
8
+
9
+ ### Added
10
+ - **`--url URL --events-ready` probes a live server's MCP events contract (S-29 to S-33, the dynamic halves the static detectors owed).** The probe starts its own HTTPS receiver (self-signed certificate generated in memory at run time) and a loopback SSRF canary, then drives discover, `events/list`, `events/subscribe`, callback verification, signed delivery and `events/unsubscribe`. Ten checks, each present / non-conforming / could-not-judge: capability declared exactly when the methods answer (S-29); unauthenticated subscribe -32012, `http:` callback and malformed secrets -32602, the same subscription in another key order keeps its id (S-31); a signed verification envelope with a fresh challenge first, a non-echoing receiver refused with -32015 and a categorical `data.reason` without its body, no data before verification (S-32); five headers, `webhook-id` = `eventId`, `standardwebhooks` signature over the raw bytes, at most 262144 bytes, a retry with a new timestamp and signature, no replay after 410 / 413 (S-33); loopback callbacks refused and redirects never followed. With no public callback (`--events-callback-base`) or no trigger tool (`--events-trigger`) the checks that need them are could-not-judge, named. Proof: a fixture server conforming on every check and one mutation per check form (19), each red on its own check only. Adds the `standardwebhooks` dependency (MIT). (README: #added-in-0180--events-ready-probe-s-29-to-s-33-dynamic)
11
+ - **`--gate [--owed <file>]`: the publish gate a server's `prepublishOnly` calls.** It decides from the report's rows and a committed `mcp-doctor.owed.json` only: any `non-conforming` row refuses, even when declared (a declaration never waives a violation); any `could-not-judge` row whose id is not declared with its own reason refuses; a declared id that is no longer `could-not-judge`, or that no detector produced, refuses as stale; an unreadable or malformed owed file (bad JSON, a blank or shared reason, a duplicate id, an unknown key) refuses and is never read as empty. Exit 0 passed, 1 refused, 2 the gate could not run. The table gains a `gate:` block and `--json` a `gate` object (`passed`, `exitCode`, `refusals[{id, kind, reason}]`, `declared`). `--gate` with `--url` is refused. Proof: each case red-then-green (tests/publish-gate.test.ts) and a foreign-material probe on modelcontextprotocol/servers @ 76d64c82 (scripts/gate-foreign-bite-probe.sh: pass, undeclared, stale, violation, landing asserted, restore proven). (README: #publish-gate---gate)
12
+ - **DToolRoles checks agent tool roles (mcp-server-standard "Agent tool roles", rule 7).** On a server with an authenticated tier (a calling agent; a public or stdio-only server reads absent, the section does not apply), every registered tool must declare a non-empty `domain` and a `mode` of exactly `read` or `write`, in its `annotations` or its `_meta`. A tool declaring in neither place, declaring different values in the two, or with `mode: read` and no `readOnlyHint: true` (or `write` with `readOnlyHint: true`) is non-conforming, named. `decideToolRole` / `filterGrantedTools` from `@vantageos/cloud-identity` must be called by the `registerTool` wrapper or the `tools/call` handler, and by a `tools/list` handler; a tool registered before the gate is installed is non-conforming, and so is any tool the gate exempts from the decision other than the identity tool (C-33) — the exempt set is followed to its `new Set([...])`, an exemption the reader cannot follow is could-not-judge. A declaration the reader cannot resolve, and a registration in a function that does not install the gate, are could-not-judge, named. When the static half holds, the verdict is could-not-judge naming the owed scoped-identity reads: rule 7 says a run with no role fixture is never a green. The section has no rule id, so the detector declares `noNumberedRule`. Proof: one mutation per form on the vendored vantage-mcp-boilerplate 0.7.0, which is present unmutated. `withCallees` no longer treats `async (` or `function (` as a function name, so it no longer pulls in an unrelated handler body. (README: #added-in-0180--agent-tool-roles-standard-1c66e11c-mcp-server-standard-agent-tool-roles-unnumbered)
13
+
14
+ ### Fixed
15
+ - **C-29 no longer reports an unreadable skill file as missing.** In the folder comparison of a plugin package's skill copy, a file that could not be read was dropped from the listing and so reported "missing" (red) although it is there; a folder that could not be listed made every file under it "missing" too. An unread file is now kept and named could-not-judge, never compared; an unlisted folder suppresses the missing / extra verdicts on its side. A package's `SKILL.md` is called missing only when its absence is seen (the nearest existing folder above it lists); an unlistable skill folder, skills root or package folder is could-not-judge, named, and so is an unlistable served skill folder, which was skipped silently. The README already promised could-not-judge for an unreadable file; this makes it true. (README: #c-29-reports-a-plugin-package-that-does-not-ship-the-served-skills)
16
+ - **C-34 decides the const-bound reader.** A script that names a plugin family file and writes only to ANOTHER fixed path through a `const` (`const out = "report.json"; writeFileSync(out, …)`) was read as an unresolved write (could-not-judge); it is a reader, so the file is red when no other script writes it. A write that stays unresolved (`writeFileSync(pick(), …)`, `join(root, rel)` over a map's keys) keeps the script could-not-judge. A name bound by `const` more than once in a file (`const path = …` in two functions) is no longer resolved to its first binding: it has no single value at the write. (README: #c-34-reports-a-plugin-family-that-is-not-generated-from-one-source)
17
+ - **D2 declares no numbered rule, as the standard says.** mcp-standard §5.2 names D2 (the `mcp-session-id` session signal) alongside D7 as guarding a protocol property without being a numbered rule; D2 still declared `rule: "S-1"`. It now carries `noNumberedRule` citing §5.2. S-1 stays judged by D12. (README: #detectors-without-a-row-in-the-release-tables-back-filled)
18
+ - **Every detector declares the rule it judges.** DExt7 (extension eval coverage) carried no `rule`; it now names `C-5`, where the extension standard sends the eval suite and its "extension absente" case. D7 (protocol-kit adoption) carries `noNumberedRule` instead, citing mcp-standard §5.2, which declares it an implementation vector of S-2/S-3/S-4 rather than a numbered rule. `tests/detector-rule-declared.test.ts` refuses a registered detector with neither, both, or a blank value, naming it. (README: #detectors-without-a-row-in-the-release-tables-back-filled)
19
+ - **DToolRoles reads a compound gate exemption per disjunct.** `exempt.has(name) || name === "list_items"` was read as one unknown condition (could-not-judge) although its second disjunct alone exempts a non-identity tool. Each top-level `||` disjunct is now read on its own: a non-identity name in any readable disjunct is red, named, with an unread disjunct beside it noted; a top-level `&&` (which narrows) is could-not-judge, named. (README: #detectors-without-a-row-in-the-release-tables-back-filled)
20
+ - **A detector named only in a "Changes in" release note no longer counts as documented.** `tests/readme-detector-table.test.ts` now reads the kind of each table from the heading above it: rows under `## What it checks`, `### Detectors added in`, `### Added in` and `### Detectors without a row` describe a detector and cover it; rows under `### Changes in` record a release and do not; a detector row under any other heading fails, naming it. Eight detectors were covered only by a release note (S-35 to S-41, C-36) and now have a description row. (README: #detectors-without-a-row-in-the-release-tables-back-filled)
21
+ - **Every registered detector has a README row, and `npm test` keeps it so.** 42 detectors (D8–D12, C7–C22, C25, C26, A2, A7, S12, the DServer / DExt families, DDebugOptIn, DAppI18n, S42, S44) were registered with no row in any README detector table; each now has one, its rule, what the static run reads and the verdicts taken from its own source. `tests/readme-detector-table.test.ts` derives the registered ids from the registry and fails naming each id without a row, each row naming an id the registry does not hold, and any first-cell form it cannot read (single, `**A**..**B**` range and hyphenated `S-28` forms are read). (README: #detectors-without-a-row-in-the-release-tables-back-filled)
22
+ - **The Public Suffix List generator's refusals are tested.** `scripts/regen-psl-private.ts` refuses to write on a non-2xx answer, a missing VERSION, COMMIT, BEGIN or END marker, END before BEGIN, or a source older than the vendored data; each was proven only by hand. `tests/regen-psl-private.test.ts` runs the real script on a fixture for each, against a data file in a temp dir (`REGEN_PSL_OUT`, new; `REGEN_PSL_SOURCE` points the fetch at a local server for the non-2xx case), asserting exit 2 and the file untouched; the happy path and `--allow-older` prove it writes. `--allow-older` given before the file is now read as a flag, not as the source file. (README: #s-45-reports-a-distributed-server-on-a-platform-host-with-no-streamable-http-route-or-without-a-declared-hosts-verification-path)
23
+ - **The Public Suffix List generator reads the vendored version, never assumes it.** A vendored data file that existed but could not be read, or carried no `PSL_VERSION`, left the version unknown and silently disabled the older-source refusal. Now only a missing file (a first generation) has no version; an unreadable file or one without `PSL_VERSION` exits 2 naming it, unless `--allow-older`. Tested per state of the vendored file. (README: #s-45-reports-a-distributed-server-on-a-platform-host-with-no-streamable-http-route-or-without-a-declared-hosts-verification-path)
24
+ - **DServer14 reads the 401 challenge where the header is set.** Element 1 was a co-occurrence of `WWW-Authenticate`, `resource_metadata=`, `401` and `Bearer` over the whole tree. It stayed present on vantage-peers with the six lines that send the challenge commented out. It is now present only when one live site sets `WWW-Authenticate` to a Bearer `resource_metadata=` challenge with a `401` on its path. The value is read at the site (a literal, or an identifier bound once in the file to a literal). Eight set forms are read: `.header`, `.set`, `.append`, `.setHeader`, `.appendHeader`, a headers-object key, a `[name, v]` tuple, and a subscript assignment. A `Basic` challenge is not Element 1. A header name outside these forms and reads, or an unreadable value with no other challenge, is could-not-judge naming the site. (README: #dserver14-reads-the-401-challenge-where-the-header-is-set)
25
+ - **The report states how many source files and registered tools it read.** A `coverage:` line under `surface:` (and a `coverage` object in `--json`) gives the number of source files the scan read and the number of registered tools the shared tool reader read. It also names unread product-looking files and registration sites whose name could not be read. A tool count that could not be read is printed as `registered tools: NOT READ — <why>`, never as 0. (README: #the-report-states-how-many-source-files-and-registered-tools-it-read)
26
+
7
27
  ## 0.17.0 — 2026-11-02
8
28
 
9
29
  ### Added
package/README.md CHANGED
@@ -28,6 +28,7 @@ npx @vantageos/mcp-doctor ./mcp-server
28
28
 
29
29
  ```
30
30
  surface: ./mcp-server
31
+ coverage: 3 source files read (.ts/.tsx, excluding .d.ts and .test.ts); 12 registered tools read
31
32
  item | file:line | state | verdict
32
33
  -----------------------------------------------------------------------------
33
34
  D2 stateless | - | present | stateless (no mcp-session-id session-keying)
@@ -40,6 +41,8 @@ D7 protocol-kit | package.json | absent | hand-rolled bu
40
41
 
41
42
  The path is the root of the MCP server sources (the folder holding `server.ts` / `transport/` /
42
43
  `package.json`). `node_modules`, `dist`, `build`, `.git` and test folders are skipped automatically.
44
+ The `coverage:` line under `surface:` states what the run read: see
45
+ [the report states how many source files and registered tools it read](#the-report-states-how-many-source-files-and-registered-tools-it-read).
43
46
 
44
47
  ### Options
45
48
 
@@ -47,7 +50,9 @@ The binary's own `--help` is the authority; this is what it prints:
47
50
 
48
51
  ```
49
52
  usage: mcp-doctor <source-tree-path> [--mode=static|dynamic|both] [--backend=<convex-dir>] [--json]
53
+ mcp-doctor <source-tree-path> --gate [--owed <file>] [--mode=...] [--json]
50
54
  mcp-doctor --url <https url> [--bearer-env VAR] [--header "Name: value"]... [--source DIR] [--expected-commit SHA] [--json]
55
+ mcp-doctor --url <https url> [--bearer-env VAR] [--header ...] --events-ready [--events-* ...] [--json]
51
56
 
52
57
  --mode=static read the tree only (default)
53
58
  --mode=dynamic launch the server and judge what it serves
@@ -67,12 +72,31 @@ usage: mcp-doctor <source-tree-path> [--mode=static|dynamic|both] [--backend=<co
67
72
  --source DIR with --url: the server's source tree, for D8 eval counts and the C-25 expected
68
73
  commit (git rev-parse HEAD there)
69
74
  --expected-commit SHA with --url: the full commit id the server must serve (C-25)
75
+ --events-ready with --url: run ONLY the MCP events probe (S-29..S-33): discover, events/list,
76
+ events/subscribe, callback verification, signed delivery, events/unsubscribe,
77
+ against an HTTPS receiver it starts (self-signed, generated at run time)
78
+ --events-callback-base URL a public https URL forwarding to the receiver; without it the
79
+ checks that need the server to POST are could-not-judge
80
+ --events-receiver-port N the receiver's local port (the forwarder's target; default any)
81
+ --events-trigger NAME [--events-trigger-args JSON] the tool whose call causes one event;
82
+ without it the delivery checks are could-not-judge
83
+ --events-name NAME [--events-args JSON] the event subscribed to and its arguments
84
+ (default: the first event listed, {}; two keys or more to probe key order)
85
+ --events-observe-ms N how long deliveries are watched after the trigger (default 5000)
86
+ --gate the publish gate (for prepublishOnly): refuse any non-conforming row, any
87
+ could-not-judge row not declared in the owed file, and any stale declaration
88
+ (a declared id no longer could-not-judge, or no row of that id). Prints a
89
+ gate: block (--json: a gate object). Not combinable with --url / --events-ready
90
+ --owed FILE with --gate: the owed-verdicts file (default <source-tree>/mcp-doctor.owed.json);
91
+ {"owed": [{"id": "<detector id>", "reason": "<why>"}, ...]}
70
92
  --json print the report as JSON (results, owedHumanVerdicts, exitCode)
71
93
  --version print the version and exit
72
94
  --help print this and exit
73
95
 
74
96
  exit: 0 clean, 1 a violation, 2 an abstention with no violation (including a target
75
97
  that names nothing readable: missing, empty, or not a source tree)
98
+ --gate: 0 passed, 1 refused, 2 the gate could not run (unreadable owed file, unreadable
99
+ tree, a detector failure, a usage error); a violation exits 1 whatever else happened
76
100
  ```
77
101
 
78
102
  ## States and exit codes
@@ -125,15 +149,75 @@ reporting that it is broken, and silencing it would hide the fault behind a norm
125
149
  for every target, because its entrypoint guard never fired under a symlink. A CI job that has been
126
150
  green on 0.2.0 was green because nothing ran. Expect findings on the first run of 0.3.x.
127
151
 
152
+ ## Publish gate (--gate)
153
+
154
+ `--gate` is the check a server's `prepublishOnly` calls, so that a package is never published with a
155
+ violation or with an undecided row nobody answered for:
156
+
157
+ ```json
158
+ "prepublishOnly": "npm run build && mcp-doctor . --gate"
159
+ ```
160
+
161
+ The gate decides from two inputs only: the rows the report prints, and an owed-verdicts file committed in
162
+ the server's repository. It adds no rule of its own and changes no detector. It refuses when:
163
+
164
+ | kind | refused when | what to fix |
165
+ |---|---|---|
166
+ | `violation` | a row is `non-conforming` — always, even when its id is declared in the owed file | the code |
167
+ | `undeclared` | a row is `could-not-judge` and its id is not in the owed file (an owed-human row included) | make the row decidable, or declare it with its reason |
168
+ | `stale` | a declared id has no `could-not-judge` row left: it became present, absent or non-conforming, or the run produced no row with that id | remove or correct the entry |
169
+ | `unreadable-owed` | the owed file cannot be read, is not valid JSON, or breaks the format below | the file; it is never read as an empty file |
170
+
171
+ It passes only with zero violations, every `could-not-judge` row declared, and no stale declaration. A server
172
+ with no `could-not-judge` row needs no file. Exit codes: **0** passed, **1** refused, **2** the gate could not run
173
+ (an unreadable owed file, an unreadable tree, a detector failure, a usage error). A violation exits 1 whatever else
174
+ happened, as a violation takes precedence over an abstention in the report's own exit code.
175
+
176
+ **The owed-verdicts file.** Default path `<source-tree>/mcp-doctor.owed.json` (beside a single-file subject, its
177
+ directory), overridable with `--owed <file>`. A file named with `--owed` that does not exist is refused.
178
+
179
+ ```json
180
+ {
181
+ "owed": [
182
+ { "id": "C35 listing-kit", "reason": "the listing kit is generated at release from the served tools/list" },
183
+ { "id": "D8 eval-suite-coverage", "reason": "tool registration is computed; evals run against the served list in CI" }
184
+ ]
185
+ }
186
+ ```
187
+
188
+ - `id` is the detector id exactly as the report's first column prints it (`--json`: a result's `id`).
189
+ - One entry per id, one id per entry, each with its own non-empty `reason`. A duplicate id, a list of ids, a
190
+ blank or missing reason, a reason copied onto a second id, and any unknown key are refused: the file states
191
+ a reason per row, it is not a waiver list.
192
+ - An entry list rather than an object keyed by id, because a JSON parser keeps the last of two equal keys in
193
+ silence and a duplicate must be seen to be refused.
194
+
195
+ This is not the same thing as the `owedHumanVerdicts` count: that is a detector stating that a person's verdict
196
+ is due on named sites. The owed file is the maintainer's declaration, for every undecided row, of why the package
197
+ may still be published.
198
+
199
+ **Output.** The table is followed by a `gate:` block: `PASSED`, or `REFUSED` with one line per refusal
200
+ (`kind | id | what is wrong and what to fix`). Under `--json` the report gains a `gate` object:
201
+ `{ passed, exitCode, refusals: [{ id, kind, reason }], declared, owedFile, owedFileFound }`, plus `cannotRun`
202
+ (the reason) when the gate could not run. The report's own `exitCode` field keeps its meaning; the process exits
203
+ with `gate.exitCode`.
204
+
205
+ **Mode.** Static by default (a prepublish has the tree, not a running server); `--mode` passes through. `--gate`
206
+ with `--url` or `--events-ready` is refused: a `--url` run does not run the source-tree rules, so its pass would say
207
+ nothing about them.
208
+
128
209
  ## Programmatic use
129
210
 
130
211
  ```ts
131
212
  import { runDoctorReport, renderTable } from "@vantageos/mcp-doctor";
132
213
 
133
- const { results, skipped } = runDoctorReport("./mcp-server");
134
- console.log(renderTable("./mcp-server", results, skipped));
214
+ const { results, skipped, coverage } = runDoctorReport("./mcp-server");
215
+ console.log(renderTable("./mcp-server", results, skipped, coverage));
135
216
  ```
136
217
 
218
+ `coverage` is what the run read (source files, registered tools); `renderTable` prints it as the
219
+ `coverage:` line under `surface:`, and called without it prints a "NOT REPORTED" line in its place.
220
+
137
221
  `skipped` is the list of directories the run actually walked past (`node_modules`, `dist`, test
138
222
  material...), recorded by the walks as they skip them. `renderTable` prints it as the
139
223
  "skipped directories" section, so a report never reads as full coverage of a narrowed scope. Pass it
@@ -158,6 +242,63 @@ Each detector maps one standard item and is proven **bipolar** on real material:
158
242
  | **DLocalIdentity** no-local-identity | No MCP server defines its own identity primitive: resolving a caller to a tenant or agent (local JWT verify, a populated allow-list attached to a bearer), asserting org membership or role, filtering rows by caller scope (`fromAllowList`, a name allow-list, a row's `orgId` or acting-name field such as `createdBy` / `assignedTo` compared to the caller's, by `===`, `==`, `Object.is` or after `toLowerCase()`), or validating a credential (local `timingSafeEqual`, a digest of a presented value, HMAC; a hash over a static literal, or over local content — file bytes, a directory listing, a digest of them, i.e. a content fingerprint of the built tree — is not a site). A call to a binding imported from `@vantageos/cloud-identity` is not a site. Minting/signing sites (`new SignJWT`, `jwt.sign`, a private-key import) are listed as `MINTING/SIGNING` and not counted; verification and claim reads stay violations whoever issued the token (no issuer carve-out). | present (0, or EXEMPT) / non-conforming (count > ceiling, default 0) / could-not-judge |
159
243
  | **S-28** claim-forwarded | Server complement S-28 (standard `bacc54a`) — a tool forwards the verified claim of its caller (`verifiedOrg` / `verifiedPerson`) to every backend door it calls and refuses when it holds none. Reads each `<client>.query\|mutation\|action` call, the helpers it spreads, the refusal before it, and the backend source's door list (`--backend=<convex-dir>`, else the nearest `convex/` above the tree). A door that is service-account-only or declared `fleet-wide:` needs no claim; no backend found, an unknown door, a computed door name are could-not-judge. | present / non-conforming / could-not-judge / absent (no Convex client imported) |
160
244
 
245
+ ### Detectors without a row in the release tables (back-filled)
246
+
247
+ Registered detectors that no description table above or below documents, in registry order; each row is read from the detector's own source file. The last eight (S-35..S-41, C-36) were introduced in a "Changes in" release note, which records a release and does not cover a detector.
248
+
249
+ | ID | Rule | The static run reads | Verdicts |
250
+ |----|------|----------------------|----------|
251
+ | **D8** eval-suite-coverage | C-5 (the >=3-cases count half) | registered tools against the case count per tool in `evals/evals.json` | absent (no tool, or no eval file) / present / non-conforming / could-not-judge |
252
+ | **D9** semver+changelog | C-3 | `package.json` `version` against strict SemVer, and `CHANGELOG.md` beside it | absent (no `CHANGELOG.md`) / present / non-conforming / could-not-judge |
253
+ | **D10** bilingual | C-1 | `description_fr` in `package.json` or in source, `README.fr.md`, and its listing in `files[]` | present / non-conforming / could-not-judge |
254
+ | **D11** zod-schemas | C-4 | `z.any()` per line, and tool registrations against `outputSchema` occurrences tree-wide (not per tool) | absent (no tool) / present / non-conforming / could-not-judge |
255
+ | **D12** stdio-transport | S-1 | `StdioServerTransport` or a `package.json` `bin` entry, against an HTTP/Streamable transport | absent (no transport signal) / present / non-conforming / could-not-judge (unparseable `package.json`) |
256
+ | **C7** artifact-verifiable | C-7 | `README.md` / `README.fr.md`: one-command install naming a registry, version pin, two obtain channels, provenance or checksum | present / non-conforming / could-not-judge |
257
+ | **C8** authority-declared | C-8 | each registered tool's `authRead` / `authWrite` pair in the closed 5-tier set (a folded `auth` refused) | absent (no tool) / present / non-conforming / could-not-judge |
258
+ | **C9** verb-declared | C-9 | each registered tool's `annotations.verb` in the closed set (`rpc` refused) | absent (no tool) / present / non-conforming / could-not-judge |
259
+ | **C10** mechanism-declared | C-10 | each list/search tool's `annotations.searchMechanism` in the closed set (`unindexed-scan` refused) | absent (no list/search tool) / present / non-conforming / could-not-judge |
260
+ | **C11** pagination-declared-applied | C-11 | each list/search tool's cursor, default and finite max in its annotations or `inputSchema` | absent (no paginable tool) / present / non-conforming / could-not-judge |
261
+ | **C12** no-duplicates | C-12 | the (verb, table, mechanism) triplet of every tool declaring verb and table | absent (no tool) / present / non-conforming / could-not-judge |
262
+ | **C13** context-ceiling | C-13 | each tool's `tokensEstimeContexte` against the declared (global, perTool) context ceiling | absent (no tool) / present / non-conforming / could-not-judge |
263
+ | **C14** catalog-registration | C-14 | the `mcpCatalog` block in `package.json` and its required fields | absent (no block) / non-conforming / could-not-judge (complete block; registry resolution owed) |
264
+ | **C15** annotations-untrusted | C-15 | each tool's four behavioral hints and title, read/write enum parameters, and consumer auto-approval off a hint | absent (no tool) / present / non-conforming / could-not-judge |
265
+ | **C16** untrusted-output | C-16 | template interpolation into instruction positions and its trust-boundary marker, and free-body strings in event payloads | absent (no interpolation site) / present / non-conforming |
266
+ | **C17** supply-chain | C-17 | a committed lockfile, and a provenance claim (`publishConfig`, `.github/workflows/*.yml`) or a provenance record | present / non-conforming / could-not-judge |
267
+ | **C18** structure-manifest | C-18 | the root `mcp.json` / `mcp-server.json` or `extension.json`: required fields and version against `package.json` | present / non-conforming / could-not-judge |
268
+ | **C19** served-descriptions | C-19 | an inline source description on each registered tool (presence proxy; the served text is the dynamic run) | absent (no tool) / present / non-conforming / could-not-judge |
269
+ | **C20** locales-derived | C-20 | locale files under `src/i18n/` against hardcoded locale enumerations elsewhere | absent (no `src/i18n/`) / present / non-conforming |
270
+ | **C21** progressive-disclosure | C-21 | nothing: the connection load is measured only with a live session | absent (static run) |
271
+ | **C22** test-ratio-gate | C-22 | test/coverage ratios cited in `README.md`, `README.fr.md`, `CHANGELOG.md` and their passage identifier | absent (no ratio cited) / non-conforming / could-not-judge |
272
+ | **C25** build-identity | C-25 | the `new McpServer(...)` / `new Server(...)` arguments and a `/health` route: a build-fed identity field beside `version` | absent (no construction) / present / non-conforming / could-not-judge |
273
+ | **C26** subpackage-lockfile | C-26 | deployment configs (`railway.json`, `Dockerfile`, `fly.toml`, ...) and a frozen install of each targeted subpackage in isolation | absent (no deployment config, or no npm site) / present / non-conforming / could-not-judge |
274
+ | **A2** declared-domains | A-2 | network and frame targets in the UI code against the `_meta.ui.csp` lists, and the single-file bundle | absent (no `ui://` resource) / present / non-conforming / could-not-judge |
275
+ | **A7** consent-before-destructive | A-7 | the gate logic: event-origin approvals, `destructiveHint`-only skips, explicit confirmation requests | absent (no tool-call gate) / present / non-conforming / could-not-judge |
276
+ | **S12** list-pagination | S-12 | `nextCursor` in each hand-registered protocol list handler, and code that decodes a cursor | absent (no list method served) / present / non-conforming / could-not-judge |
277
+ | **DServer2** naming | C-2 | tool names (snake_case, 64-character cap) and the `package.json` name (kebab-case) | present / non-conforming / could-not-judge |
278
+ | **DServer6** secret-hygiene | C-6 | log calls referencing secrets, PII or internal detail, and raw error traces sent to the client | present / non-conforming / could-not-judge |
279
+ | **DDebugOptIn** debug-opt-in | C-6 (debug half) | `.debug(...)` calls and the env/config gate around them | absent (no debug output) / present / non-conforming / could-not-judge |
280
+ | **DServer8** ui-fallback | A-1 | each `content[]` emitting a `ui://` resource, and a sibling text/markdown entry | absent (no `ui://` emission) / present / non-conforming / could-not-judge |
281
+ | **DServer14** oauth-resource-server | S-5 | the five-element OAuth 2.1 resource-server chain and the `@vantageos/cloud-identity` dependency and range | absent (no resource-server surface) / present / non-conforming / could-not-judge |
282
+ | **DAppI18n** app-i18n | C-20 | `i18n/fr.json` keys against `i18n/en.json` | absent (no `i18n/`) / present / non-conforming / could-not-judge |
283
+ | **DExt1** identifier | E-1 | the reverse-DNS `identifier` in `extension.json` and TS factories, and vendor host-key namespaces against the registry | absent (no identifier declared) / present / non-conforming / could-not-judge |
284
+ | **DExt2** graceful-degradation | E-2 | `graceful_degradation` in `extension.json` and `gracefulDegradation` in `defineExtension` | absent (no flag found) / present / non-conforming / could-not-judge |
285
+ | **DExt3** single-type | E-3 | the extension `type` in `extension.json` and `defineExtension`: exactly one known category | absent (no type declared) / present / non-conforming / could-not-judge |
286
+ | **DExt4** lifecycle-hooks | E-4 | the manifest `lifecycle` hooks against their implementations (`hooks/` files, factory hooks) | absent (no hook declared) / present / non-conforming / could-not-judge |
287
+ | **DExt5** bilingual | C-1 | `description_fr` and `README.fr.md` beside each `extension.json`, and per-tool `description_fr` | absent (no manifest, or an FR piece missing) / present / could-not-judge |
288
+ | **DExt7** eval-coverage | C-5 | each extension's `evals/evals.json`: >=3 cases including an "extension absente" case | absent (no manifest) / present / non-conforming / could-not-judge |
289
+ | **DExt8** semver+changelog | C-3 | each extension's `package.json` `version` against strict SemVer, and `CHANGELOG.md` beside it | absent (no manifest, or no `CHANGELOG.md`) / present / non-conforming / could-not-judge |
290
+ | **DExt9** hook-timeout | E-6 | each declared lifecycle hook's timeout guard (manifest `timeouts.<hook>` or in its implementation) | absent (no hook declared) / present / non-conforming / could-not-judge |
291
+ | **S42** write-read-claims | S-42 | the verified claims each write tool forwards to its backend door against those of the read tools on the same table | absent (no backend door call) / present / non-conforming / could-not-judge |
292
+ | **S44** closed-output | S-44 | every object of each tool's output schema closed to added fields (`.strict()`, `additionalProperties: false`, ...) | absent (no tool) / present / non-conforming / could-not-judge |
293
+ | **S35** scope-in-read | S-35 | each `<client>.query\|action(<door>, <args>)` and, in the same block, a narrowing of what it returned (`scopeFilterList`, `scopeFilterGet`, a `.filter` on an organisation / namespace / recipient / owner field or the caller context, a skipping branch in a loop) | absent / present / non-conforming / could-not-judge (door named by an expression) |
294
+ | **S36** upstream-credential | S-36 | the `client_credentials` grant, where the token source is built, its cache and expiry, the 401 path, the tenancy key, secrets near logs, errors and results | absent (no outbound call, no token source) / present / non-conforming / could-not-judge (unread source) |
295
+ | **S37** upstream-settings | S-37 | environment reads against the declared variables, literal upstream addresses, URL variables, secret flags, defaults on required variables | absent (no outbound call, token source, `upstreams` declaration or `defineVariables`) / present / non-conforming / could-not-judge (unread source) |
296
+ | **S38** bounded-upstream-call | S-38 | page walks and their ceiling, page size, cursor wrapping, retry bounds and `Retry-After`, the origin check, redirect options | absent (no upstream call to bound) / present / non-conforming / could-not-judge (unread source) |
297
+ | **S39** upstream-error | S-39 | time budgets, `isError` results and what is interpolated into them, catch sites, empty-success fallbacks | absent (no outbound call) / present / non-conforming / could-not-judge (unread source) |
298
+ | **S40** upstream-rows-narrowed | S-40 | how the person is resolved, the package narrowing, the refusal paths; each tool serving upstream rows is listed as an owed human verdict (C-23) | absent (no tool serves upstream rows) / non-conforming / could-not-judge, with an owed human verdict (C-23) per tool serving upstream rows |
299
+ | **S41** lake-reader | S-41 | the reader interface, the kind of each store call, the page check, the upstream reached only on a lake miss | absent (no data-lake reader) / present / non-conforming / could-not-judge (unread source) |
300
+ | **C36** readme-npm-limit | C-36 | the size of every root `readme*` file a published package ships, against the npm truncation point | absent (not published) / present / non-conforming / could-not-judge (package.json, the package root or a README that cannot be read) |
301
+
161
302
  ### Detectors added in 0.7.0 (standard `b714129a`, ElPi-Corp #243)
162
303
 
163
304
  One detector per rule that #243 added, plus the S-5 elements (f)..(l), each implementing the
@@ -235,6 +376,99 @@ an error message) it counts only as code or as a quoted property key.
235
376
  | **C34** plugin-families | C-34 | each Agent Plugins, Claude or Cursor plugin file, the script that writes it, and its `--check` drift refusal | absent (no plugin family) / present / non-conforming / could-not-judge |
236
377
  | **C35** listing-kit | C-35 | `listing/listing.json`: description, tools, test prompts and reviewer note against their sources; served half: titles and hints against the served `tools/list` | absent (not listed) / present / non-conforming / could-not-judge |
237
378
 
379
+ ### Added in 0.18.0 — agent tool roles (standard `1c66e11c`, mcp-server-standard "Agent tool roles", unnumbered)
380
+
381
+ The section carries no rule id, so the detector declares `noNumberedRule` and the id has no number. It reads rule 7, the checks the section assigns to mcp-doctor.
382
+
383
+ | ID | Rule | The static run reads | Verdicts |
384
+ |----|------|----------------------|----------|
385
+ | **DToolRoles** tool-roles | "Agent tool roles" rule 7 (unnumbered) | on a tree with an authenticated tier (a calling agent; otherwise the section does not apply): each registered tool's `domain` and `mode` in its `annotations` and its `_meta` (neither, a conflict, a mode other than `read` / `write`, or `read` without `readOnlyHint: true` is red); `decideToolRole` / `filterGrantedTools` from `@vantageos/cloud-identity` called by the `registerTool` wrapper or `tools/call` handler and by a `tools/list` handler, every registration after the gate is installed, and no tool exempt from the gate but the identity tool (C-33) | absent (no tool, or no authenticated tier) / non-conforming / could-not-judge — including when the static half holds, because rule 7 says a run with no role fixture (grants nothing / read-only / full grant) is never a green |
386
+
387
+ ### Added in 0.18.0 — events-ready probe (S-29 to S-33, dynamic)
388
+
389
+ The static S-29..S-33 detectors read what the code must carry and leave the behaviour owed. `--url URL
390
+ --events-ready` runs that behaviour against the live server, the way an events host does: `server/discover`
391
+ (else `initialize`), `events/list`, `events/subscribe`, callback verification, signed delivery,
392
+ `events/unsubscribe`. The probe starts its own HTTPS receiver (a self-signed certificate generated in memory at
393
+ run time; no key is stored) and a loopback SSRF canary. Signatures are checked with `standardwebhooks` on the raw
394
+ bytes received. It prints ten rows and runs nothing else; the exit code follows the usual convention.
395
+
396
+ ```bash
397
+ mcp-doctor --url https://mcp.example.com/mcp --bearer-env MCP_TOKEN --events-ready \
398
+ --events-callback-base https://abc123.tunnel.example --events-receiver-port 8443 \
399
+ --events-trigger create_item --events-trigger-args '{"title":"probe"}' \
400
+ --events-name item.created --events-args '{"project":"alpha","kind":"note"}'
401
+ ```
402
+
403
+ | ID | Rule | What the probe does | Red when |
404
+ |----|------|---------------------|----------|
405
+ | `ER-a` events-declared | S-29 | reads `capabilities.events`, calls the three methods | declared and a method answers -32601, or not declared and a method answers |
406
+ | `ER-b` unauth-subscribe | S-31 | subscribes with none of the caller's headers or URL query | anything but -32012, or the callback is contacted first |
407
+ | `ER-c` subscribe-params | S-31 | an `http:` callback; secrets of 8 bytes and without `whsec_` | not -32602 (a -32015 on the `http:` URL means it was tried) |
408
+ | `ER-d` subscription-id | S-31 | subscribes twice, `arguments` keys in reverse order | the two ids differ |
409
+ | `ER-e` callback-verify | S-32 | reads the first envelope; a receiver that answers 200 without the challenge | envelope unsigned or without challenge/`webhook-id`, a challenge reused, the non-echoing receiver accepted, a -32015 without a categorical `data.reason` or carrying the receiver's body, an event reaching it |
410
+ | `ER-f` no-data-first | S-32 | the order of POSTs on every callback | an event before the verification envelope |
411
+ | `ER-g` signed-delivery | S-33 | every delivery; a receiver that answers 500 once | a header missing, `webhook-id` ≠ `eventId`, a signature that does not verify, a body over 262144 bytes, a retry with the same timestamp or signature or a new `eventId` |
412
+ | `ER-h` no-replay-410-413 | S-33 | receivers answering 410 and 413 | an event delivered twice to either |
413
+ | `ER-i` ssrf-refused | S-32 (callback rules) | callbacks to `127.0.0.1`, `localhost`, `2130706433` on the canary port | accepted, -32015 (a connection was attempted), or the canary is hit |
414
+ | `ER-j` no-redirect | S-32 (callback rules) | a receiver answering 307 to another path | the redirect target receives anything |
415
+
416
+ Could-not-judge, always named, never a pass:
417
+
418
+ - **No public callback** (`--events-callback-base`): a server that refuses a loopback callback cannot reach the
419
+ receiver, so ER-c's secret half, ER-d, ER-e, ER-f, ER-g, ER-h and ER-j are could-not-judge. The base must
420
+ forward to `--events-receiver-port` on the machine running the probe.
421
+ - **No trigger** (`--events-trigger`): the protocol has no method that causes an event, so ER-g, ER-h and the
422
+ "no event after a failed verification" half of ER-e are could-not-judge.
423
+ - **Fewer than two argument keys** (`--events-args`): ER-d has no key order to permute.
424
+ - **No retry within `--events-observe-ms`** (default 5000): the retry half of ER-g. "Never redelivered" (ER-h) is
425
+ judged within that window only.
426
+ - **HTTP 401/403 before JSON-RPC** on the unauthenticated call: what `events/subscribe` itself answers is not
427
+ observable (ER-b).
428
+ - **The conforming receiver refused**: the receiver echoes `{"challenge": "<value>"}` with HTTP 200; a server
429
+ that reads another echo form leaves ER-e could-not-judge, naming the answer.
430
+
431
+ Not probed: `data` against `payloadSchema` (S-33), another principal and restart survival (S-31), descriptors
432
+ (S-30), access recheck (S-34). The SSRF canary listens on the probe's own loopback, so a hit is seen only for a
433
+ server on the same host; for a remote server the answer decides (-32602 passes, -32015 or a result is red).
434
+
435
+ ### Changes in 0.18.0 — the report states what it read; DServer14 reads the challenge where it is set
436
+
437
+ #### The report states how many source files and registered tools it read
438
+
439
+ A `coverage:` line now follows `surface:` in the table, and a `coverage` object is in the `--json` report.
440
+ It gives the number of source files the scan read (the same files every detector reads: `.ts`/`.tsx`, without
441
+ `.d.ts` and `.test.ts`, outside the skipped directories). It also gives the number of registered tools the
442
+ shared tool reader read (the reader D8 and the per-tool rules use). Product-looking files the scan does not read
443
+ (`.js`, `.mjs`...) are counted and named on the same line. So are registration sites whose tool name could not
444
+ be read. When no tool could be read on a tree that serves tools (an SDK-first server with computed names, or a
445
+ tool surface with no located registration), the line says `registered tools: NOT READ — <why>`. It never prints
446
+ 0 as if it counted. `0 registered tools read` appears only when the tree has no tool surface. Under `--url`
447
+ the line says no source tree was read. In JSON, `coverage.tools` is `{ read, unresolvedSites }` or
448
+ `{ unreadable }`.
449
+
450
+ #### DServer14 reads the 401 challenge where the header is set
451
+
452
+ Element 1 (the `401` + `WWW-Authenticate: Bearer … resource_metadata=…` challenge) used to be four tokens found
453
+ anywhere in the tree. It stayed present when every line that sets the header was commented out: the tokens
454
+ were still in an unused constant, in other 401 responses, and in the token endpoint's `Basic` challenge. It is
455
+ now present only when one live site sets the header to a Bearer challenge carrying `resource_metadata=`, with
456
+ a `401` in the same block within a few lines (6 before, 8 after).
457
+
458
+ The value is read at the site: a string or template literal, or an identifier bound once in the same file to
459
+ one (`const wwwAuthHeader = \`Bearer resource_metadata=…\`` then `c.header("WWW-Authenticate", wwwAuthHeader)`).
460
+ The set forms read are `.header(name, v)` (Hono, Express), `.set` / `.append` (Fetch `Headers`, Express),
461
+ `.setHeader` / `.appendHeader` (Node), a `"WWW-Authenticate": v` key in a headers object (Response init,
462
+ `writeHead`, `c.text(body, status, headers)`), a `["WWW-Authenticate", v]` tuple, and `headers["WWW-Authenticate"] = v`.
463
+ A `Basic` or other non-Bearer challenge is not Element 1. Reads (`.get`, a one-argument `.header(name)`, a
464
+ subscript read) and CORS header-name lists are not set sites.
465
+
466
+ The rule is could-not-judge, naming the site, in two cases. One: the header name sits anywhere else, such
467
+ as a constant holding the name or a helper taking it as an argument. Two: no site qualifies and a set
468
+ site's value cannot be read (a call, an imported identifier, several bindings). A challenge delegated to
469
+ `@vantageos/cloud-identity` and forwarded is read as before. The non-conforming verdict lists every
470
+ header-set site read and why it did not count.
471
+
238
472
  ### Changes in 0.17.0 — S-47 (standard `1c66e11c` = mcp-server-standard v2.11, PR #311)
239
473
 
240
474
  #### S-47 reports a server whose events are not delivered by signed webhook
@@ -287,7 +521,9 @@ the `io.modelcontextprotocol/skills` extension and publishes plugin packages (a
287
521
  `.claude-plugin/plugin.json`, `.cursor-plugin/plugin.json`, or an Agent Plugins `plugin.json`), each package must
288
522
  carry `skills/<name>/` for every skill in the tree, the whole folder byte-equal to the served copy: `SKILL.md` and
289
523
  every file beside it (`references/`, `scripts/`, assets). A missing skill, or a file missing, differing or extra in
290
- the copy, is red and named; a file that cannot be read is could-not-judge. A package at the repository root whose `skills/` is the
524
+ the copy, is red and named; a file that cannot be read, or a folder that cannot be listed, on either side is
525
+ could-not-judge, named, and is never counted as missing, extra or different; a `SKILL.md` is called missing only
526
+ when the folder above it can be listed. A package at the repository root whose `skills/` is the
291
527
  served folder satisfies it as is.
292
528
  ### Changes in 0.17.0 — C-34 (standard `1c66e11c` = mcp-standard v2.8, PR #311)
293
529
 
package/dist/doctor.d.ts CHANGED
@@ -383,6 +383,12 @@ interface Detector {
383
383
  * (see `scripts/standard-coverage.ts`) — never from a hand-kept list.
384
384
  */
385
385
  rule?: string;
386
+ /**
387
+ * Set INSTEAD of `rule` on a detector the standard itself declares as answering no numbered rule, with the reason
388
+ * and where the standard says so. A detector carries exactly one of `rule` / `noNumberedRule`
389
+ * (tests/detector-rule-declared.test.ts); never both, never neither.
390
+ */
391
+ noNumberedRule?: string;
386
392
  /** The standard commit this detector's `rule` was read against. Required
387
393
  * alongside `rule`: a rule id with no pin is unverifiable against a moving
388
394
  * doc. */
@@ -474,6 +480,101 @@ interface LiveDetector {
474
480
  */
475
481
  declare function isLiveDetector(d: Detector | LiveDetector): d is LiveDetector;
476
482
 
483
+ /**
484
+ * `--gate`: the publish gate a server's `prepublishOnly` calls.
485
+ *
486
+ * It decides ONLY from two inputs: the rows this run produced (exactly the rows the table prints) and
487
+ * the server's committed owed-verdicts file. It has no opinion of its own and changes no detector.
488
+ *
489
+ * - every `non-conforming` row refuses, always; nothing in the owed file can waive it (kind `violation`);
490
+ * - every `could-not-judge` row refuses unless its detector id is declared, with a reason, in the owed
491
+ * file (kind `undeclared`);
492
+ * - every declared id refuses when no row of that id is `could-not-judge` any more — the row became
493
+ * present, absent or non-conforming, or the run produced no row with that id (kind `stale`), so the
494
+ * file can never drift into a silent waiver list;
495
+ * - an owed file that cannot be read, or that breaks the format below, refuses naming what it could
496
+ * not read (kind `unreadable-owed`); it is NEVER read as an empty file.
497
+ *
498
+ * How the owed file relates to `owedVerdict` / `owedHumanVerdicts`: those are a DETECTOR's statement
499
+ * that a person's verdict is due on named sites (C-23), and `computeExitCode` lets such a row exit 0
500
+ * when its mechanical half is complete. The owed file is the MAINTAINER's committed declaration, one
501
+ * per could-not-judge row, of why that row is acceptable to publish with. The gate grants no exception
502
+ * for `mechanicalHalfComplete`: an owed-human row is a could-not-judge row and is declared like any
503
+ * other — the declaration is where the person records that the verdict was given.
504
+ */
505
+ /** Default owed-verdicts file, at the root of the source tree; `--owed <file>` overrides it. */
506
+ declare const OWED_FILE_NAME = "mcp-doctor.owed.json";
507
+ type GateRefusalKind = "violation" | "undeclared" | "stale" | "unreadable-owed";
508
+ interface GateRefusal {
509
+ /** The detector id (the table's first column), or the owed file's path when the whole file is unreadable. */
510
+ id: string;
511
+ kind: GateRefusalKind;
512
+ /** What is wrong and what to fix. */
513
+ reason: string;
514
+ }
515
+ interface GateVerdict {
516
+ passed: boolean;
517
+ refusals: GateRefusal[];
518
+ /** The ids the owed file declares (empty when there is no file, or it could not be read). */
519
+ declared: string[];
520
+ /** The owed file read, or looked for (`null` only when the gate could not run at all). */
521
+ owedFile: string | null;
522
+ /** Whether that file exists (a missing DEFAULT file is no declaration, never an error). */
523
+ owedFileFound: boolean;
524
+ /** Set when the gate could not run (unreadable subject, detector failure): what stopped it. */
525
+ cannotRun?: string;
526
+ }
527
+ /** One declaration: a detector id and the reason the row may be published undecided. */
528
+ interface OwedEntry {
529
+ id: string;
530
+ reason: string;
531
+ }
532
+ type OwedRead = {
533
+ kind: "none";
534
+ path: string;
535
+ } | {
536
+ kind: "ok";
537
+ path: string;
538
+ entries: OwedEntry[];
539
+ } | {
540
+ kind: "unreadable";
541
+ path: string;
542
+ problems: {
543
+ id: string;
544
+ what: string;
545
+ }[];
546
+ };
547
+ /**
548
+ * Read and validate the owed-verdicts file.
549
+ *
550
+ * Format (strict; every deviation refuses, never ignored):
551
+ *
552
+ * { "owed": [ { "id": "C35 listing-kit", "reason": "..." }, ... ] }
553
+ *
554
+ * An array of entries rather than an id-keyed object, because `JSON.parse` keeps the last of two equal
555
+ * keys in silence: a duplicate id must be refused, and only an array lets the reader see it. One id per
556
+ * entry (never a list), a non-empty reason per entry, and no reason text shared by two entries — a
557
+ * reason copied across ids is a blanket waiver. Unknown keys refuse: a misspelt key would otherwise
558
+ * read as a declaration that says nothing.
559
+ *
560
+ * A missing DEFAULT file is `none`: a server with no could-not-judge row needs no file. A missing file
561
+ * named explicitly (`--owed`) is unreadable: the caller said where the declarations are and they are not there.
562
+ */
563
+ declare function readOwedFile(path: string, opts: {
564
+ explicit: boolean;
565
+ }): OwedRead;
566
+ /** Judge one run's rows against the owed file. Pure: the rows and the file are its only inputs. */
567
+ declare function evaluateGate(results: DetectorResult[], owed: OwedRead): GateVerdict;
568
+ /**
569
+ * The gate's exit code, on the repository's convention (`computeExitCode`): 0 passed; 1 refused;
570
+ * 2 the gate could not run in full (an unreadable owed file, an unreadable subject). A violation takes
571
+ * precedence over "could not run", exactly as a violation takes precedence over an abstention in
572
+ * `computeExitCode`: the run already proves the server may not publish.
573
+ */
574
+ declare function gateExitCode(v: GateVerdict): number;
575
+ /** The `gate:` block printed under the table. */
576
+ declare function renderGate(v: GateVerdict): string;
577
+
477
578
  /** A remote streamable-HTTP MCP server judged the way a customer reaches it (`--url`). */
478
579
  interface HttpEndpoint {
479
580
  /** The MCP endpoint. https, or http on a loopback host only (a credential never travels in clear). */
@@ -513,6 +614,71 @@ declare function redactSecrets(text: string, secrets: string[]): string;
513
614
  */
514
615
  declare function introspectEndpoint(ep: HttpEndpoint): RuntimeContext;
515
616
 
617
+ /**
618
+ * The events-ready probe: the DYNAMIC half the static S-29..S-33 detectors name as `owed:`
619
+ * (src/detectors/s29-events-declared.ts .. s33-signed-delivery.ts). It drives a running server the
620
+ * way an events host does — discover -> events/list -> events/subscribe -> callback verification ->
621
+ * signed delivery -> events/unsubscribe — against an HTTPS receiver it starts itself (a self-signed
622
+ * certificate generated in memory at run time, see selfSignedCert.ts), plus an SSRF canary listener.
623
+ *
624
+ * Contract read: mcp-server-standard.md @ STANDARD_PIN, S-29 (l.80) .. S-33 (l.84) and S-47 (l.121);
625
+ * protocol detail from the events analysis §2.2-2.6 (subscribe params `{name, arguments, delivery:
626
+ * {mode: "webhook", url, secret}, cursor, ttlMs}`, result `{id, refreshBefore, cursor, truncated}`,
627
+ * the `{"type": "verification", "challenge"}` envelope, -32602 / -32012 / -32015 with a categorical
628
+ * `data.reason`, the Standard Webhooks headers).
629
+ *
630
+ * Each check answers exactly one of present (pass), non-conforming (violation) or could-not-judge
631
+ * (named); `absent` only when the server neither declares nor serves events (S-30..S-34 n/a).
632
+ *
633
+ * DECLARED CHOICES (the places where the standard leaves the probe a decision, written here so the
634
+ * reader of a verdict can find them):
635
+ * - TRIGGER. The protocol has no method that causes an event. The caller names a tool that does
636
+ * (`trigger`, CLI `--events-trigger NAME --events-trigger-args JSON`); without it, the delivery
637
+ * checks (g, h) and the "no event to a failed receiver" half of (e) are could-not-judge, named.
638
+ * - PUBLIC CALLBACK. A real server must refuse a loopback callback (that is check i), so the
639
+ * receiver is reachable only through a caller-supplied public https URL that forwards to it
640
+ * (`callbackBase`, CLI `--events-callback-base URL`, with `--events-receiver-port` fixing the
641
+ * port the forwarder targets). Without it every check that needs the server to POST to the
642
+ * receiver (d, e, f, g, h, j, and the malformed-secret half of c) is could-not-judge, named.
643
+ * - ECHO FORM. The receiver echoes a challenge as `{"challenge": "<value>"}` with HTTP 200. A
644
+ * server that reads another echo form and refuses the conforming receiver makes (e) and the
645
+ * checks that need a live subscription could-not-judge, naming the refusal — never a violation.
646
+ * - OBSERVATION WINDOW. "Never redelivered" (h) and "a retry keeps eventId" (g) are judged within
647
+ * `observeMs` after the trigger (CLI `--events-observe-ms`, default 5000). A retry that does not
648
+ * arrive within the window leaves the retry half of (g) could-not-judge.
649
+ * - TRANSPORT REFUSAL. An unauthenticated request refused with HTTP 401/403 before the JSON-RPC
650
+ * layer says nothing about what events/subscribe answers: (b) is could-not-judge, named.
651
+ * - SSRF. The canary listens on the probe host's loopback. Over a remote URL the server's loopback
652
+ * is not the probe's, so a hit is observable only for a server on the same host; the decisive
653
+ * reading is the answer: -32602 (refused) passes, a result (accepted) or -32015 (the server tried
654
+ * to connect toward a loopback address) is red.
655
+ * - NOT PROBED (outside checks a..j): `data` against `payloadSchema` (S-33), another principal
656
+ * yielding another id and state surviving a restart (S-31), descriptors (S-30), access recheck
657
+ * (S-34). The probe holds one credential and no restart control; no verdict claims them.
658
+ */
659
+ interface EventsReadyOptions {
660
+ endpoint: HttpEndpoint;
661
+ /** The tool whose call causes one event (there is no standard trigger method). */
662
+ trigger?: {
663
+ tool: string;
664
+ arguments: Record<string, unknown>;
665
+ };
666
+ /** The event subscribed to and its arguments; default: the first event events/list serves, `{}`. */
667
+ event?: {
668
+ name: string;
669
+ arguments: Record<string, unknown>;
670
+ };
671
+ /** A public https URL that forwards to the receiver (no trailing slash needed). */
672
+ callbackBase?: string;
673
+ /** The receiver's local port (0: any free port). */
674
+ receiverPort?: number;
675
+ /** How long deliveries are observed after the trigger, in ms (default 5000). */
676
+ observeMs?: number;
677
+ /** Per JSON-RPC request deadline, in ms (default 10000). */
678
+ requestTimeoutMs?: number;
679
+ }
680
+ declare function runEventsReady(opts: EventsReadyOptions): Promise<DetectorResult[]>;
681
+
516
682
  type RunMode = "static" | "dynamic" | "both";
517
683
  interface RunDoctorOptions {
518
684
  mode?: RunMode;
@@ -553,7 +719,35 @@ declare function runDoctor(target: string, detectorList?: Detector[], opts?: Run
553
719
  declare function runDoctorReport(target: string, detectorList?: Detector[], opts?: RunDoctorOptions): {
554
720
  results: DetectorResult[];
555
721
  skipped: SkippedDir[];
722
+ coverage: Coverage;
723
+ };
724
+ /**
725
+ * What a run READ, stated beside what it concluded. Without it a verdict over 300 files and
726
+ * 108 tools reads the same as one over 2 files and none.
727
+ *
728
+ * `tree` mode: the source files the scan read (the same `tree.files` every detector reads) and
729
+ * the registered tools the shared tool reader read (`findRegisteredTools`, the reader D8 and the
730
+ * per-tool rules use). A tool count the reader could not establish is `unreadable` with the
731
+ * reason, never 0: an SDK-first or tool-serving tree where no registration was located has tools
732
+ * the reader did not see. `0` is printed only when the tree shows no tool surface at all.
733
+ * `endpoint` mode (`--url`): no source tree is read.
734
+ */
735
+ type Coverage = {
736
+ mode: "endpoint";
737
+ } | {
738
+ mode: "tree";
739
+ sourceFiles: number;
740
+ unscannedSource: string[];
741
+ tools: {
742
+ read: number;
743
+ unresolvedSites: string[];
744
+ } | {
745
+ unreadable: string;
746
+ };
556
747
  };
748
+ declare function readCoverage(tree: Tree): Coverage;
749
+ /** The coverage line printed under `surface:`. */
750
+ declare function renderCoverage(coverage: Coverage | undefined): string;
557
751
  /**
558
752
  * Async runner — the ADDITIVE extension for *dynamique* rules that must CALL a
559
753
  * running server. It is a superset of the sync `runDoctor` static path, never a
@@ -582,7 +776,7 @@ declare function runDoctorAsync(target: string, opts?: {
582
776
  * rendered: an empty list says "none", it is never omitted.
583
777
  */
584
778
  declare function renderSkipped(skipped: SkippedDir[]): string;
585
- declare function renderTable(surface: string, results: DetectorResult[], skipped?: SkippedDir[]): string;
779
+ declare function renderTable(surface: string, results: DetectorResult[], skipped?: SkippedDir[], coverage?: Coverage): string;
586
780
  /** Total owed human-verdict sites across the results — counted from the structured field. */
587
781
  declare function countOwedHumanVerdicts(results: DetectorResult[]): number;
588
782
  /**
@@ -596,7 +790,7 @@ declare function renderOwedVerdicts(results: DetectorResult[]): string;
596
790
  * the owed-human-verdict count, so a consumer reads "a verdict is owed" from a field and never from
597
791
  * prose.
598
792
  */
599
- declare function renderJson(surface: string, results: DetectorResult[], skipped: SkippedDir[]): string;
793
+ declare function renderJson(surface: string, results: DetectorResult[], skipped: SkippedDir[], coverage?: Coverage, gate?: GateVerdict): string;
600
794
  /**
601
795
  * The process exit code a run's results carry, three-way with precedence:
602
796
  * 1 — a VIOLATION: at least one detector is `non-conforming` (something IS
@@ -609,5 +803,5 @@ declare function renderJson(surface: string, results: DetectorResult[], skipped:
609
803
  */
610
804
  declare function computeExitCode(results: DetectorResult[]): number;
611
805
 
612
- export { SubjectUnreadableError, computeExitCode, countOwedHumanVerdicts, endpointSecrets, introspectEndpoint, isLiveDetector, redactSecrets, renderJson, renderOwedVerdicts, renderSkipped, renderTable, runDoctor, runDoctorAsync, runDoctorReport };
613
- export type { HttpEndpoint, LiveDetector, RunDoctorOptions, RunMode, Session };
806
+ export { OWED_FILE_NAME, SubjectUnreadableError, computeExitCode, countOwedHumanVerdicts, endpointSecrets, evaluateGate, gateExitCode, introspectEndpoint, isLiveDetector, readCoverage, readOwedFile, redactSecrets, renderCoverage, renderGate, renderJson, renderOwedVerdicts, renderSkipped, renderTable, runDoctor, runDoctorAsync, runDoctorReport, runEventsReady };
807
+ export type { Coverage, EventsReadyOptions, GateVerdict, HttpEndpoint, LiveDetector, RunDoctorOptions, RunMode, Session };