codex-plugin-doctor 1.62.0 → 1.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -81,35 +81,48 @@ Runtime MCP validation with `--runtime`:
81
81
  - optional runtime approval gating with a precomputed `doctor runtime-plan` digest
82
82
  - optional Docker isolation for local Node.js stdio servers with `--sandbox docker`
83
83
 
84
- ### MCP Protocol Discovery
85
-
86
- Inspect an HTTP MCP endpoint's advertised protocol versions using a bounded MCP
87
- 2026-07-28 `server/discover` request:
88
-
89
- ```bash
90
- codex-plugin-doctor doctor discover https://mcp.example.com/mcp --allow-network
91
- codex-plugin-doctor doctor discover https://mcp.example.com/mcp --allow-network --json
92
- ```
93
-
94
- This is an opt-in discovery-only check. A successful result validates the discovery
95
- response, not full protocol conformance, tool behavior, or compatibility with a
96
- particular client. Existing `check --runtime` remains on its 2025-11-25 baseline.
97
- See [MCP Discovery](docs/guides/mcp-discovery.md) for consent, scope, and exit codes.
98
-
99
- ### HTTP MCP Tool Catalog
100
-
101
- Inspect a modern HTTP MCP server's tool definitions without invoking them:
102
-
103
- ```bash
104
- codex-plugin-doctor doctor tools https://mcp.example.com/mcp --allow-network --json
105
- ```
106
-
107
- This opt-in command performs discovery and bounded `tools/list` pagination. It
108
- reports tool-definition and root-schema shape findings, explicit completion state,
109
- and partial inspection limits. It does not claim full schema validation, tool
110
- execution, or client compatibility. Existing `doctor discover` behavior is unchanged.
111
- See [HTTP MCP Tool Catalog](docs/guides/mcp-tool-catalog.md).
112
-
84
+ ### MCP Protocol Discovery
85
+
86
+ Inspect an HTTP MCP endpoint's advertised protocol versions using a bounded MCP
87
+ 2026-07-28 `server/discover` request:
88
+
89
+ ```bash
90
+ codex-plugin-doctor doctor discover https://mcp.example.com/mcp --allow-network
91
+ codex-plugin-doctor doctor discover https://mcp.example.com/mcp --allow-network --json
92
+ ```
93
+
94
+ This is an opt-in discovery-only check. A successful result validates the discovery
95
+ response, not full protocol conformance, tool behavior, or compatibility with a
96
+ particular client. Existing `check --runtime` remains on its 2025-11-25 baseline.
97
+ See [MCP Discovery](docs/guides/mcp-discovery.md) for consent, scope, and exit codes.
98
+
99
+ ### Offline MCP Tool Definitions
100
+
101
+ Inspect a saved MCP 2026-07-28 `tools/list` response without contacting a server:
102
+
103
+ ```bash
104
+ codex-plugin-doctor doctor tools-file ./tools-list.json --json
105
+ ```
106
+
107
+ This checks the supplied tool definitions and root-schema shapes within fixed file,
108
+ tool, and finding limits. It does not establish server inventory completeness or
109
+ execute tools. See [Offline MCP Tool Definitions](docs/guides/offline-tool-definitions.md)
110
+ for the accepted input format, coverage, and exit codes.
111
+
112
+ ### HTTP MCP Tool Catalog
113
+
114
+ Inspect a modern HTTP MCP server's tool definitions without invoking them:
115
+
116
+ ```bash
117
+ codex-plugin-doctor doctor tools https://mcp.example.com/mcp --allow-network --json
118
+ ```
119
+
120
+ This opt-in command performs discovery and bounded `tools/list` pagination. It
121
+ reports tool-definition and root-schema shape findings, explicit completion state,
122
+ and partial inspection limits. It does not claim full schema validation, tool
123
+ execution, or client compatibility. Existing `doctor discover` behavior is unchanged.
124
+ See [HTTP MCP Tool Catalog](docs/guides/mcp-tool-catalog.md).
125
+
113
126
  ### Remote MCP Readiness
114
127
 
115
128
  Remote MCP runtime probing is disabled until you explicitly pass `--runtime --allow-network`. Loopback endpoints also require `--allow-local-network`:
@@ -528,9 +541,9 @@ jobs:
528
541
  runs-on: ubuntu-latest
529
542
  steps:
530
543
  - uses: actions/checkout@v5
531
- - uses: Esquetta/CodexPluginDoctor@v1.62.0
544
+ - uses: Esquetta/CodexPluginDoctor@v1.63.0
532
545
  with:
533
- version: "1.62.0"
546
+ version: "1.63.0"
534
547
  path: .
535
548
  runtime: "true"
536
549
  policy: codex-publish
@@ -0,0 +1,27 @@
1
+ import type { CatalogFinding } from "./mcp-tool-definition.js";
2
+ export interface McpToolFileReport {
3
+ schemaVersion: 1;
4
+ scope: "tool-definitions-file";
5
+ status: "pass" | "warn" | "fail" | "incomplete" | "blocked";
6
+ source: {
7
+ kind: "file";
8
+ format: "mcp-tools-list-response";
9
+ bytesRead: number;
10
+ };
11
+ inspection: {
12
+ complete: boolean;
13
+ toolsChecked: number;
14
+ hasNextCursor: boolean | null;
15
+ reason: string | null;
16
+ };
17
+ coverage: {
18
+ schema: "root-shape-only";
19
+ discovery: "not-tested";
20
+ serverCatalog: "not-tested";
21
+ toolExecution: "not-tested";
22
+ fullConformance: "not-tested";
23
+ customHeaderAnnotations: "not-tested";
24
+ };
25
+ findings: CatalogFinding[];
26
+ }
27
+ export declare function inspectMcpToolFile(filePath: string): Promise<McpToolFileReport>;
@@ -0,0 +1,241 @@
1
+ import { constants } from "node:fs";
2
+ import { lstat, open } from "node:fs/promises";
3
+ import { inspectMcpToolDefinition } from "./mcp-tool-definition.js";
4
+ const MAX_FILE_BYTES = 1024 * 1024;
5
+ const MAX_TOOLS = 500;
6
+ const MAX_FINDINGS = 100;
7
+ function isJsonObject(value) {
8
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9
+ }
10
+ function hasOwn(object, key) {
11
+ return Object.hasOwn(object, key);
12
+ }
13
+ function sameFile(left, right) {
14
+ return left.dev === right.dev && left.ino === right.ino;
15
+ }
16
+ function sameSnapshot(left, right) {
17
+ return sameFile(left, right)
18
+ && left.size === right.size
19
+ && left.mtimeMs === right.mtimeMs
20
+ && left.ctimeMs === right.ctimeMs;
21
+ }
22
+ function isBlockedOfflinePath(filePath) {
23
+ return /^[A-Za-z][A-Za-z0-9+.-]+:/u.test(filePath)
24
+ || /^[A-Za-z]:\/\//u.test(filePath)
25
+ || /^[\\/]{2}/u.test(filePath);
26
+ }
27
+ function baseReport(bytesRead) {
28
+ return {
29
+ schemaVersion: 1,
30
+ scope: "tool-definitions-file",
31
+ source: { kind: "file", format: "mcp-tools-list-response", bytesRead },
32
+ coverage: {
33
+ schema: "root-shape-only",
34
+ discovery: "not-tested",
35
+ serverCatalog: "not-tested",
36
+ toolExecution: "not-tested",
37
+ fullConformance: "not-tested",
38
+ customHeaderAnnotations: "not-tested"
39
+ }
40
+ };
41
+ }
42
+ function report(bytesRead, status, inspection, findings) {
43
+ return { ...baseReport(bytesRead), status, inspection, findings };
44
+ }
45
+ function fileFinding(id, severity, message, impact, suggestedFix) {
46
+ return { id, severity, message, impact, suggestedFix };
47
+ }
48
+ function incompleteFileReport(bytesRead, reason, finding) {
49
+ return report(bytesRead, "incomplete", {
50
+ complete: false,
51
+ toolsChecked: 0,
52
+ hasNextCursor: null,
53
+ reason
54
+ }, [finding]);
55
+ }
56
+ function blockedFileReport(reason, finding) {
57
+ return report(0, "blocked", {
58
+ complete: false,
59
+ toolsChecked: 0,
60
+ hasNextCursor: null,
61
+ reason
62
+ }, [finding]);
63
+ }
64
+ function finalStatus(findings) {
65
+ if (findings.some((finding) => finding.severity === "fail"))
66
+ return "fail";
67
+ return findings.some((finding) => finding.severity === "warn") ? "warn" : "pass";
68
+ }
69
+ function parseToolsResult(value) {
70
+ if (!isJsonObject(value)
71
+ || value.jsonrpc !== "2.0"
72
+ || !hasOwn(value, "id")
73
+ || !(typeof value.id === "string" || (typeof value.id === "number" && Number.isFinite(value.id)))
74
+ || !hasOwn(value, "result")
75
+ || hasOwn(value, "error")
76
+ || !isJsonObject(value.result)
77
+ || value.result.resultType !== "complete"
78
+ || !Array.isArray(value.result.tools)
79
+ || typeof value.result.ttlMs !== "number"
80
+ || !Number.isFinite(value.result.ttlMs)
81
+ || value.result.ttlMs < 0
82
+ || (value.result.cacheScope !== "public" && value.result.cacheScope !== "private")) {
83
+ return null;
84
+ }
85
+ const hasNextCursor = hasOwn(value.result, "nextCursor");
86
+ if (hasNextCursor && typeof value.result.nextCursor !== "string")
87
+ return null;
88
+ return { tools: value.result.tools, hasNextCursor };
89
+ }
90
+ async function readBoundedRegularFile(filePath) {
91
+ let initial;
92
+ try {
93
+ initial = await lstat(filePath);
94
+ }
95
+ catch {
96
+ return { kind: "unavailable", bytesRead: 0 };
97
+ }
98
+ if (initial.isSymbolicLink())
99
+ return { kind: "symlink", bytesRead: 0 };
100
+ if (!initial.isFile())
101
+ return { kind: "not-regular", bytesRead: 0 };
102
+ if (!Number.isSafeInteger(initial.size) || initial.size < 0 || initial.size > MAX_FILE_BYTES) {
103
+ return { kind: "too-large", bytesRead: 0 };
104
+ }
105
+ const flags = process.platform === "win32"
106
+ ? constants.O_RDONLY
107
+ : constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK;
108
+ let fileHandle = null;
109
+ let bytesRead = 0;
110
+ try {
111
+ fileHandle = await open(filePath, flags);
112
+ const opened = await fileHandle.stat();
113
+ const current = await lstat(filePath);
114
+ if (!opened.isFile() || current.isSymbolicLink() || !current.isFile() || !sameSnapshot(initial, opened) || !sameSnapshot(opened, current)) {
115
+ return { kind: "changed", bytesRead };
116
+ }
117
+ if (!Number.isSafeInteger(opened.size) || opened.size < 0 || opened.size > MAX_FILE_BYTES) {
118
+ return { kind: "too-large", bytesRead };
119
+ }
120
+ const content = Buffer.alloc(opened.size);
121
+ while (bytesRead < content.length) {
122
+ const read = await fileHandle.read(content, bytesRead, content.length - bytesRead, bytesRead);
123
+ if (read.bytesRead === 0)
124
+ return { kind: "changed", bytesRead };
125
+ bytesRead += read.bytesRead;
126
+ }
127
+ const probe = Buffer.alloc(1);
128
+ const extra = await fileHandle.read(probe, 0, 1, bytesRead);
129
+ bytesRead += extra.bytesRead;
130
+ if (extra.bytesRead !== 0)
131
+ return { kind: "changed", bytesRead };
132
+ const completed = await fileHandle.stat();
133
+ const final = await lstat(filePath);
134
+ if (!final.isFile() || final.isSymbolicLink() || !sameSnapshot(opened, completed) || !sameSnapshot(completed, final)) {
135
+ return { kind: "changed", bytesRead };
136
+ }
137
+ return { kind: "content", content, bytesRead };
138
+ }
139
+ catch {
140
+ return { kind: "unavailable", bytesRead };
141
+ }
142
+ finally {
143
+ await fileHandle?.close().catch(() => undefined);
144
+ }
145
+ }
146
+ export async function inspectMcpToolFile(filePath) {
147
+ if (isBlockedOfflinePath(filePath)) {
148
+ return blockedFileReport("offline-path-blocked", fileFinding("plugin.tools_file.path.blocked", "fail", "The local tool definition path is not permitted for offline inspection.", "The offline tool definition inspection does not access remote or device paths.", "Provide a local regular file path."));
149
+ }
150
+ const file = await readBoundedRegularFile(filePath);
151
+ if (file.kind === "unavailable") {
152
+ return incompleteFileReport(file.bytesRead, "file-unavailable", fileFinding("plugin.tools_file.file.unavailable", "fail", "The local tool definition file could not be read.", "The offline tool definition inspection could not start.", "Provide a readable local regular file."));
153
+ }
154
+ if (file.kind === "too-large") {
155
+ return incompleteFileReport(file.bytesRead, "file-size-limit", fileFinding("plugin.tools_file.file.too_large", "fail", "The local tool definition file exceeds the one MiB inspection limit.", "The offline tool definition inspection cannot safely read this file within its byte limit.", "Provide a tool definition file no larger than one MiB."));
156
+ }
157
+ if (file.kind === "changed") {
158
+ return incompleteFileReport(file.bytesRead, "file-changed", fileFinding("plugin.tools_file.file.changed", "fail", "The local tool definition file changed during inspection.", "The offline tool definition inspection cannot rely on an inconsistent file snapshot.", "Retry after the file is stable."));
159
+ }
160
+ if (file.kind === "symlink") {
161
+ return blockedFileReport("final-symlink", fileFinding("plugin.tools_file.file.symlink", "fail", "The local tool definition target is a symbolic link.", "The offline tool definition inspection does not follow final symbolic links.", "Provide a regular file directly."));
162
+ }
163
+ if (file.kind === "not-regular") {
164
+ return blockedFileReport("non-regular-file", fileFinding("plugin.tools_file.file.not_regular", "fail", "The local tool definition target is not a regular file.", "The offline tool definition inspection reads only bounded regular files.", "Provide a regular file directly."));
165
+ }
166
+ let decoded;
167
+ try {
168
+ decoded = new TextDecoder("utf-8", { fatal: true }).decode(file.content);
169
+ }
170
+ catch {
171
+ return incompleteFileReport(file.bytesRead, "invalid-utf8", fileFinding("plugin.tools_file.encoding.invalid", "fail", "The local tool definition file is not valid UTF-8.", "The offline tool definition inspection cannot parse the file safely.", "Save the tools/list response as UTF-8 JSON."));
172
+ }
173
+ let value;
174
+ try {
175
+ value = JSON.parse(decoded);
176
+ }
177
+ catch {
178
+ return incompleteFileReport(file.bytesRead, "invalid-json", fileFinding("plugin.tools_file.json.invalid", "fail", "The local tool definition file is not valid JSON.", "The offline tool definition inspection cannot parse the file safely.", "Provide one UTF-8 JSON-RPC tools/list response."));
179
+ }
180
+ const parsed = parseToolsResult(value);
181
+ if (parsed === null) {
182
+ return incompleteFileReport(file.bytesRead, "response-invalid", fileFinding("plugin.tools_file.response.invalid", "fail", "The local JSON value is not a supported complete tools/list response.", "The offline tool definition inspection cannot identify a valid tool list.", "Provide one JSON-RPC 2.0 complete tools/list result with valid cache metadata."));
183
+ }
184
+ const findings = [];
185
+ const names = new Map();
186
+ let reason = null;
187
+ let toolsChecked = 0;
188
+ const addFindings = (items) => {
189
+ const remaining = MAX_FINDINGS - findings.length;
190
+ if (items.length > remaining) {
191
+ findings.push(...items.slice(0, remaining));
192
+ reason = "finding-limit";
193
+ return false;
194
+ }
195
+ findings.push(...items);
196
+ return true;
197
+ };
198
+ for (const tool of parsed.tools) {
199
+ if (toolsChecked >= MAX_TOOLS) {
200
+ reason = "tool-limit";
201
+ break;
202
+ }
203
+ toolsChecked += 1;
204
+ const location = { page: 1, toolIndex: toolsChecked };
205
+ if (!addFindings(inspectMcpToolDefinition(tool, location)))
206
+ break;
207
+ if (isJsonObject(tool) && typeof tool.name === "string") {
208
+ const previous = names.get(tool.name);
209
+ if (previous !== undefined && !addFindings([fileFinding("plugin.catalog.tool.name.duplicate", "warn", "Two enumerated tools use the same name.", "Duplicate tool names can make client selection ambiguous.", "Use a unique MCP tool name for each definition.")])) {
210
+ break;
211
+ }
212
+ if (previous !== undefined) {
213
+ findings[findings.length - 1] = {
214
+ ...findings[findings.length - 1],
215
+ location: { ...location, relatedToolIndex: previous }
216
+ };
217
+ }
218
+ else {
219
+ names.set(tool.name, toolsChecked);
220
+ }
221
+ }
222
+ }
223
+ if (reason === null && parsed.tools.length > MAX_TOOLS)
224
+ reason = "tool-limit";
225
+ if (reason === null && parsed.hasNextCursor)
226
+ reason = "more-pages-present";
227
+ if (reason !== null) {
228
+ return report(file.bytesRead, "incomplete", {
229
+ complete: false,
230
+ toolsChecked,
231
+ hasNextCursor: parsed.hasNextCursor,
232
+ reason
233
+ }, findings);
234
+ }
235
+ return report(file.bytesRead, finalStatus(findings), {
236
+ complete: true,
237
+ toolsChecked,
238
+ hasNextCursor: false,
239
+ reason: null
240
+ }, findings);
241
+ }
@@ -714,6 +714,57 @@ const publicSchemaDefinitions = [
714
714
  }
715
715
  }
716
716
  }
717
+ },
718
+ {
719
+ id: "doctor.tools.file.json",
720
+ command: "codex-plugin-doctor doctor tools-file <path> --json",
721
+ required: ["schemaVersion", "scope", "status", "source", "inspection", "coverage", "findings"],
722
+ properties: {
723
+ schemaVersion: { const: 1 },
724
+ scope: { const: "tool-definitions-file" },
725
+ status: { enum: ["pass", "warn", "fail", "incomplete", "blocked"] },
726
+ source: {
727
+ type: "object", required: ["kind", "format", "bytesRead"],
728
+ properties: {
729
+ kind: { const: "file" }, format: { const: "mcp-tools-list-response" },
730
+ bytesRead: { type: "integer", minimum: 0, maximum: 1048577 }
731
+ }, additionalProperties: false
732
+ },
733
+ inspection: {
734
+ type: "object", required: ["complete", "toolsChecked", "hasNextCursor", "reason"],
735
+ properties: {
736
+ complete: { type: "boolean" }, toolsChecked: { type: "integer", minimum: 0, maximum: 500 },
737
+ hasNextCursor: { type: ["boolean", "null"] }, reason: { type: ["string", "null"] }
738
+ }, additionalProperties: false
739
+ },
740
+ coverage: {
741
+ type: "object", required: ["schema", "discovery", "serverCatalog", "toolExecution", "fullConformance", "customHeaderAnnotations"],
742
+ properties: {
743
+ schema: { const: "root-shape-only" }, discovery: { const: "not-tested" },
744
+ serverCatalog: { const: "not-tested" }, toolExecution: { const: "not-tested" },
745
+ fullConformance: { const: "not-tested" }, customHeaderAnnotations: { const: "not-tested" }
746
+ }, additionalProperties: false
747
+ },
748
+ findings: {
749
+ type: "array", maxItems: 100,
750
+ items: {
751
+ type: "object", required: ["id", "severity", "message", "impact", "suggestedFix"],
752
+ properties: {
753
+ id: { type: "string", pattern: "^plugin\\.(tools_file|catalog)\\." },
754
+ severity: { enum: ["warn", "fail"] },
755
+ message: { type: "string" }, impact: { type: "string" }, suggestedFix: { type: "string" },
756
+ location: {
757
+ type: "object", required: ["page", "toolIndex"],
758
+ properties: {
759
+ page: { const: 1 }, toolIndex: { type: "integer", minimum: 1, maximum: 500 },
760
+ schema: { enum: ["inputSchema", "outputSchema"] },
761
+ relatedToolIndex: { type: "integer", minimum: 1, maximum: 500 }
762
+ }, additionalProperties: false
763
+ }
764
+ }, additionalProperties: false
765
+ }
766
+ }
767
+ }
717
768
  }
718
769
  ];
719
770
  function sha256(value) {
@@ -0,0 +1,2 @@
1
+ import type { McpToolFileReport } from "../core/mcp-tool-file.js";
2
+ export declare function renderMcpToolFileReport(report: McpToolFileReport): string;
@@ -0,0 +1,26 @@
1
+ export function renderMcpToolFileReport(report) {
2
+ return [
3
+ "Offline MCP Tool Definitions",
4
+ "============================",
5
+ `Status: ${report.status}`,
6
+ `Scope: ${report.scope}`,
7
+ `Source: ${report.source.kind} (${report.source.format})`,
8
+ `Bytes read: ${report.source.bytesRead}`,
9
+ `Inspection complete: ${report.inspection.complete}`,
10
+ `Tools checked: ${report.inspection.toolsChecked}`,
11
+ `More pages advertised: ${report.inspection.hasNextCursor ?? "unknown"}`,
12
+ ...(report.inspection.reason === null ? [] : [`Reason: ${report.inspection.reason}`]),
13
+ `Schema coverage: ${report.coverage.schema}`,
14
+ `Discovery: ${report.coverage.discovery}`,
15
+ `Server catalog: ${report.coverage.serverCatalog}`,
16
+ `Tool execution: ${report.coverage.toolExecution}`,
17
+ `Full conformance: ${report.coverage.fullConformance}`,
18
+ `Custom header annotations: ${report.coverage.customHeaderAnnotations}`,
19
+ "Only the supplied file was inspected. Its provenance and server completeness are not established.",
20
+ ...report.findings.map((finding) => {
21
+ const location = finding.location;
22
+ const locator = location ? ` [tool ${location.toolIndex}${location.schema ? `, ${location.schema}` : ""}${location.relatedToolIndex ? `, related tool ${location.relatedToolIndex}` : ""}]` : "";
23
+ return `${finding.severity.toUpperCase()} ${finding.id}${locator}: ${finding.message}\n ${finding.suggestedFix}`;
24
+ })
25
+ ].join("\n");
26
+ }
package/dist/run-cli.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { discoverMcpServer } from "./core/mcp-discovery.js";
2
2
  import { inspectMcpToolCatalog } from "./core/mcp-tool-catalog.js";
3
+ import { inspectMcpToolFile } from "./core/mcp-tool-file.js";
3
4
  import { buildCorpusQualityMetricsDiffReport, buildCorpusQualityMetricsReport } from "./core/corpus-quality-metrics.js";
4
5
  import { runCheck } from "./index.js";
5
6
  import { writeRawDoctorConfig } from "./index.js";
@@ -15,6 +16,7 @@ export interface CliTerminalContext {
15
16
  platform?: NodeJS.Platform;
16
17
  }
17
18
  export interface RunCliOptions {
19
+ inspectMcpToolFileImpl?: typeof inspectMcpToolFile;
18
20
  inspectMcpToolCatalogImpl?: typeof inspectMcpToolCatalog;
19
21
  discoverMcpServerImpl?: typeof discoverMcpServer;
20
22
  terminalContext?: CliTerminalContext;
package/dist/run-cli.js CHANGED
@@ -23,6 +23,8 @@ import { buildSubmissionArchivePreflight, submissionArchiveExitCode } from "./co
23
23
  import { buildSubmissionPreflight } from "./core/submission-preflight.js";
24
24
  import { discoverMcpServer } from "./core/mcp-discovery.js";
25
25
  import { inspectMcpToolCatalog } from "./core/mcp-tool-catalog.js";
26
+ import { inspectMcpToolFile } from "./core/mcp-tool-file.js";
27
+ import { renderMcpToolFileReport } from "./reporting/render-mcp-tool-file-report.js";
26
28
  import { renderMcpToolCatalogReport } from "./reporting/render-mcp-tool-catalog-report.js";
27
29
  import { renderMcpDiscoveryReport } from "./reporting/render-mcp-discovery-report.js";
28
30
  import { buildDoctorValidationCorpusReport, renderDoctorValidationCorpusJson, renderDoctorValidationCorpusReport } from "./core/validation-corpus.js";
@@ -103,6 +105,7 @@ function writeExactStdout(io, message) {
103
105
  }
104
106
  class CliUsageError extends Error {
105
107
  }
108
+ const toolsFileUsage = "Usage: codex-plugin-doctor doctor tools-file <path> [--json]";
106
109
  const toolsUsage = "Usage: codex-plugin-doctor doctor tools <url> --allow-network [--allow-local-network] [--json]";
107
110
  const discoveryUsage = "Usage: codex-plugin-doctor doctor discover <url> --allow-network [--allow-local-network] [--json]";
108
111
  function parseRuntimeSandbox(flags, options = { requireRuntime: true }) {
@@ -189,6 +192,7 @@ function printUsage(io) {
189
192
  io.writeStderr("Usage: codex-plugin-doctor check <path|--installed> [filter] [--policy codex-publish|mcp-strict|security] [--compat] [--json|--markdown|--badge-json|--badge-markdown] [--output <path>] [--history <path>] [--runtime [--allow-network [--allow-local-network]]] [--sandbox docker] [--require-runtime-approval --runtime-approval-digest <digest>] [--verbose-runtime] [--explain] [--no-animations] [--ascii] [--changed-since <ref>] [--fail-on <rule-id>]\n codex-plugin-doctor audit --installed [filter] [--policy codex-publish|mcp-strict|security] [--security] [--compat] [--json] [--output <path>] [--cache] [--changed]\n codex-plugin-doctor audit deps <path> [--policy codex-publish|mcp-strict|security] [--recommend] [--json|--sarif] [--output <path>]\n codex-plugin-doctor mcp <path> [--runtime [--allow-network [--allow-local-network]]] [--json] [--output <path>]\n codex-plugin-doctor security <path> [--policy security] [--json|--scorecard]\n codex-plugin-doctor compat <path> [--all|--client <client>] [--json] [--scorecard] [--output <path>] [--install-preview|--apply --backup]\n codex-plugin-doctor suppress add <path> [--fingerprint <sha256> --reason <text> --expires-at YYYY-MM-DD] [--config <path>] [--json]\n codex-plugin-doctor suppress list <path> [--config <path>] [--json]\n codex-plugin-doctor suppress remove <path> [--fingerprint <sha256>|--index <n>] [--config <path>] [--json]\n codex-plugin-doctor fix <path> (--dry-run|--interactive --backup|--apply --backup)\n codex-plugin-doctor history <history.jsonl> [--json] [--fail-on-regression]\n codex-plugin-doctor watch <path> [--runtime] [--json] [--output <path>] [--debounce-ms <ms>] [--max-iterations <n>] [--fail-fast] [--accumulate-json <path>]\n codex-plugin-doctor doctor [npm <package>|contract|corpus [--manifest <corpus.json>] [--json] [--output <path>]|corpus metrics --manifest <corpus.json> [--json|--markdown] [--output <path>] [--min-precision <0..1>] [--min-recall <0..1>] [--max-false-positive-rate <0..1>]|runtime-plan <path> [--sandbox docker] [--json|--markdown] [--output <path>]|runtime-policy <path> [--sandbox docker] [--json] [--output <path>]|review-bundle <path> --output <dir> --sign-key-env NAME [--json] [--allow-dirty] [--allow-untagged]|review-bundle verify <bundle-dir> --target <path> --sign-key-env NAME [--json] [--output <path>] [--failures-only]|review-bundle diff --before <dir> --after <dir> [--json]|attest <path> [--sign-key-env NAME]|attest verify <attestation.json> --target <path> --sign-key-env NAME|release-evidence <path> --sign-key-env NAME [--runtime [--allow-network [--allow-local-network]]] [--sandbox docker] [--allow-dirty] [--allow-untagged] [--require-runtime-approval --runtime-approval-digest <digest>]|release-evidence verify <evidence.json> --target <path> --sign-key-env NAME|release-evidence asset <path> --tag <tag> --output <evidence.json> --sign-key-env NAME [--runtime [--allow-network [--allow-local-network]]] [--sandbox docker] [--allow-dirty] [--allow-untagged] [--require-runtime-approval --runtime-approval-digest <digest>] [--upload]|mcp <path> [--runtime [--allow-network [--allow-local-network]]]|inspector <path>|diff --before <path> --after <path>|recommend <path>|trust <path>|perf <path> [--max-total-ms <ms>] [--max-stage-ms stage=ms]|export --bundle <path>|snapshot|clients|--json|--update-check]\n codex-plugin-doctor init [path] [--template skill-only|mcp-stdio|mcp-http|full-runtime]\n codex-plugin-doctor init-ci [path]\n codex-plugin-doctor init-git-hooks [path] [--force] [--json]\n codex-plugin-doctor init-git-hooks [path] --remove [--json]\n codex-plugin-doctor completion bash|zsh|fish\n codex-plugin-doctor config validate <path> [--json]\n codex-plugin-doctor release check <path> [--json] [--runtime [--allow-network [--allow-local-network]]] [--sandbox docker]\n codex-plugin-doctor self-test\n codex-plugin-doctor list --installed\n codex-plugin-doctor explain <finding-id>\n codex-plugin-doctor --version\n\nFirst run:\n codex-plugin-doctor doctor\n codex-plugin-doctor self-test\n codex-plugin-doctor init my-plugin\n codex-plugin-doctor check . --runtime --explain");
190
193
  io.writeStderr(discoveryUsage);
191
194
  io.writeStderr(toolsUsage);
195
+ io.writeStderr(toolsFileUsage);
192
196
  io.writeStderr("Registry readiness: codex-plugin-doctor registry check <server.json|directory> [--json] [--output <path>] [--require-registry-readiness]\n"
193
197
  + " codex-plugin-doctor registry inspect <server-name> --allow-network [--json] [--output <path>] [--require-registry-readiness]\n"
194
198
  + "Registry publication preflight: codex-plugin-doctor registry preflight <server.json|directory> [--allow-network] [--json] [--output <path>] [--require-publish-ready]");
@@ -1199,6 +1203,23 @@ export async function runCli(args, io = defaultIo, options = {}) {
1199
1203
  return 0;
1200
1204
  }
1201
1205
  if (command === "doctor") {
1206
+ if (maybePath === "tools-file") {
1207
+ if (remainingArgs.length === 1 && remainingArgs[0] === "--help") {
1208
+ io.writeStdout(`${toolsFileUsage}\nInspects one saved UTF-8 MCP tools/list response. No server connection or tool execution.`);
1209
+ return 0;
1210
+ }
1211
+ const [filePath, ...flags] = remainingArgs;
1212
+ if (!filePath || filePath.startsWith("-") || flags.some((flag) => flag !== "--json") || flags.length > 1) {
1213
+ io.writeStderr(`Invalid file inspection arguments. ${toolsFileUsage}`);
1214
+ return 2;
1215
+ }
1216
+ const report = await (options.inspectMcpToolFileImpl ?? inspectMcpToolFile)(filePath);
1217
+ io.writeStdout(flags.includes("--json")
1218
+ ? JSON.stringify(report, null, 2)
1219
+ : renderMcpToolFileReport(report));
1220
+ return report.status === "pass" ? 0
1221
+ : report.status === "warn" || report.status === "fail" ? 1 : 2;
1222
+ }
1202
1223
  if (maybePath === "tools") {
1203
1224
  if (remainingArgs.length === 1 && remainingArgs[0] === "--help") {
1204
1225
  io.writeStdout(`${toolsUsage}\nHTTP tool catalog structure only; tools are not executed.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-plugin-doctor",
3
- "version": "1.62.0",
3
+ "version": "1.63.0",
4
4
  "description": "CLI-first validator for Codex plugins, skills, and MCP package surfaces with runtime MCP protocol validation.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",