@vantageos/mcp-doctor 0.16.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/dist/doctor.d.ts CHANGED
@@ -133,6 +133,13 @@ interface DetectorResult {
133
133
  interface RuntimeTool {
134
134
  /** The tool name the server actually advertises at runtime (post-startup). */
135
135
  name: string;
136
+ /** The display title served (`title`, else `annotations.title`); C-35 compares a listing kit to it. */
137
+ title?: string;
138
+ /** The two behaviour hints a directory reads, as served (C-35). Unset when the tool serves no annotations. */
139
+ annotations?: {
140
+ readOnlyHint?: boolean;
141
+ destructiveHint?: boolean;
142
+ };
136
143
  /**
137
144
  * The description the server actually SERVES over `tools/list`, post-
138
145
  * startup — the surface C-19 measures (never the source-declared string,
@@ -239,6 +246,39 @@ type ServedAuthServer = {
239
246
  url: string;
240
247
  reason: string;
241
248
  };
249
+ /**
250
+ * One sign-in started at the served `authorization_endpoint` as a known CIMD client (S-46 served half): the
251
+ * redirect URI sent (read from the client's own metadata document) and the raw answer, never followed. The
252
+ * detector classifies it; the probe only records.
253
+ */
254
+ interface ServedAuthorizeAttempt {
255
+ redirect: string;
256
+ /** HTTP status; unset when no answer came (then `detail` says why). */
257
+ status?: number;
258
+ /** The Location answered, reduced to origin + path + its `error` parameter (no state, no code). */
259
+ location?: string;
260
+ /** The first 300 characters of a 4xx/5xx body. */
261
+ body?: string;
262
+ detail?: string;
263
+ }
264
+ type ServedAuthorizeClient = {
265
+ host: string;
266
+ clientId: string;
267
+ kind: "probed";
268
+ attempts: ServedAuthorizeAttempt[];
269
+ } | {
270
+ host: string;
271
+ clientId: string;
272
+ kind: "unavailable";
273
+ reason: string;
274
+ };
275
+ type ServedAuthorize = {
276
+ kind: "not-run";
277
+ reason: string;
278
+ } | {
279
+ kind: "probed";
280
+ clients: ServedAuthorizeClient[];
281
+ };
242
282
  /** What the running server SERVES that a source-tree read can only guess at. */
243
283
  interface ServedFacts {
244
284
  /** `capabilities` of the `initialize` response, as served. */
@@ -253,6 +293,8 @@ interface ServedFacts {
253
293
  calls: ServedList[];
254
294
  versionProbe: VersionProbe;
255
295
  authServer: ServedAuthServer;
296
+ /** S-46 served half: sign-ins started as each known CIMD client. Absent on records written before it existed. */
297
+ authorize?: ServedAuthorize;
256
298
  }
257
299
  /**
258
300
  * What the RUNNING target server exposes, gathered by launching it and speaking
@@ -321,6 +363,15 @@ interface RuntimeContext {
321
363
  * recorded none: a rule reading it says could-not-judge, naming that, never a pass.
322
364
  */
323
365
  served?: ServedFacts;
366
+ /**
367
+ * Over HTTP, when the MCP handshake itself failed (a 401 before any credential): the PUBLIC authorization reads
368
+ * the runtime still made — the authorization-server metadata and the S-46 sign-in attempts. Set only beside a
369
+ * `launchError`; a detector that reads it says the handshake was refused.
370
+ */
371
+ publicAuth?: {
372
+ authServer: ServedAuthServer;
373
+ authorize?: ServedAuthorize;
374
+ };
324
375
  }
325
376
  interface Detector {
326
377
  id: string;
@@ -332,6 +383,12 @@ interface Detector {
332
383
  * (see `scripts/standard-coverage.ts`) — never from a hand-kept list.
333
384
  */
334
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;
335
392
  /** The standard commit this detector's `rule` was read against. Required
336
393
  * alongside `rule`: a rule id with no pin is unverifiable against a moving
337
394
  * doc. */
@@ -423,6 +480,101 @@ interface LiveDetector {
423
480
  */
424
481
  declare function isLiveDetector(d: Detector | LiveDetector): d is LiveDetector;
425
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
+
426
578
  /** A remote streamable-HTTP MCP server judged the way a customer reaches it (`--url`). */
427
579
  interface HttpEndpoint {
428
580
  /** The MCP endpoint. https, or http on a loopback host only (a credential never travels in clear). */
@@ -437,6 +589,14 @@ interface HttpEndpoint {
437
589
  source?: string;
438
590
  /** The full 40-hex commit the server is expected to serve; wins over one derived from `source`. */
439
591
  expectedCommit?: string;
592
+ /**
593
+ * The CIMD clients the S-46 served half signs in as. Default: the known ones (targets.ts `CIMD_CLIENTS`). A
594
+ * caller (a test) may name others, e.g. a client document served on a loopback host.
595
+ */
596
+ clients?: ReadonlyArray<{
597
+ host: string;
598
+ clientId: string;
599
+ }>;
440
600
  }
441
601
  /**
442
602
  * Every secret value an `HttpEndpoint` carries: header values (and the token of an `Authorization:
@@ -454,6 +614,71 @@ declare function redactSecrets(text: string, secrets: string[]): string;
454
614
  */
455
615
  declare function introspectEndpoint(ep: HttpEndpoint): RuntimeContext;
456
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
+
457
682
  type RunMode = "static" | "dynamic" | "both";
458
683
  interface RunDoctorOptions {
459
684
  mode?: RunMode;
@@ -494,7 +719,35 @@ declare function runDoctor(target: string, detectorList?: Detector[], opts?: Run
494
719
  declare function runDoctorReport(target: string, detectorList?: Detector[], opts?: RunDoctorOptions): {
495
720
  results: DetectorResult[];
496
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
+ };
497
747
  };
748
+ declare function readCoverage(tree: Tree): Coverage;
749
+ /** The coverage line printed under `surface:`. */
750
+ declare function renderCoverage(coverage: Coverage | undefined): string;
498
751
  /**
499
752
  * Async runner — the ADDITIVE extension for *dynamique* rules that must CALL a
500
753
  * running server. It is a superset of the sync `runDoctor` static path, never a
@@ -523,7 +776,7 @@ declare function runDoctorAsync(target: string, opts?: {
523
776
  * rendered: an empty list says "none", it is never omitted.
524
777
  */
525
778
  declare function renderSkipped(skipped: SkippedDir[]): string;
526
- declare function renderTable(surface: string, results: DetectorResult[], skipped?: SkippedDir[]): string;
779
+ declare function renderTable(surface: string, results: DetectorResult[], skipped?: SkippedDir[], coverage?: Coverage): string;
527
780
  /** Total owed human-verdict sites across the results — counted from the structured field. */
528
781
  declare function countOwedHumanVerdicts(results: DetectorResult[]): number;
529
782
  /**
@@ -537,7 +790,7 @@ declare function renderOwedVerdicts(results: DetectorResult[]): string;
537
790
  * the owed-human-verdict count, so a consumer reads "a verdict is owed" from a field and never from
538
791
  * prose.
539
792
  */
540
- 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;
541
794
  /**
542
795
  * The process exit code a run's results carry, three-way with precedence:
543
796
  * 1 — a VIOLATION: at least one detector is `non-conforming` (something IS
@@ -550,5 +803,5 @@ declare function renderJson(surface: string, results: DetectorResult[], skipped:
550
803
  */
551
804
  declare function computeExitCode(results: DetectorResult[]): number;
552
805
 
553
- export { SubjectUnreadableError, computeExitCode, countOwedHumanVerdicts, endpointSecrets, introspectEndpoint, isLiveDetector, redactSecrets, renderJson, renderOwedVerdicts, renderSkipped, renderTable, runDoctor, runDoctorAsync, runDoctorReport };
554
- 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 };