@eidonze/mcpdoctor 0.1.2 → 0.1.4

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 xka0085-byte (Eidon)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 xka0085-byte (Eidon)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # mcpdoctor
2
2
 
3
+ > ⚠️ **Official package notice**: this is the official `mcpdoctor`, published by npm user [`eidonze`](https://www.npmjs.com/~eidonze), repo [`xka0085-byte/mcp-doctor`](https://github.com/xka0085-byte/mcp-doctor). We are **NOT affiliated** with **mcpdoctor.dev** — that is a *different* product (an MCP **server-auditing** tool). This `mcpdoctor` is an independent, read-only **402/x402 payment-endpoint inspector CLI**. Same name, different tool. Verify the package by its scope: `@eidonze/mcpdoctor`.
4
+
3
5
  **mcpdoctor is a read-only CLI for inspecting MCP and x402 endpoints.**
4
6
 
5
7
  Point it at a URL, get one `PASS / FAIL / UNKNOWN` report:
@@ -24,6 +26,46 @@ npm install -g @eidonze/mcpdoctor # or run without installing:
24
26
  npx @eidonze/mcpdoctor inspect <url>
25
27
  ```
26
28
 
29
+ Current release: `0.1.4`. The CLI is read-only: it does not sign, pay, retry payment, invoke MCP tools, or accept private keys.
30
+
31
+ ## GitHub Actions
32
+
33
+ Run the check in pull requests without installing a package or storing a key:
34
+
35
+ ```yaml
36
+ name: MCP Trust Check
37
+ on: [pull_request]
38
+
39
+ jobs:
40
+ mcp-trust:
41
+ runs-on: ubuntu-latest
42
+ steps:
43
+ - uses: xka0085-byte/mcpdoctor@v1
44
+ with:
45
+ endpoint: https://your-mcp-server.example/mcp
46
+ mode: schema
47
+ format: markdown
48
+ ```
49
+
50
+ `schema` performs read-only `initialize` and `tools/list` checks. Use `mode: inspect`
51
+ for a read-only x402 HTTP 402 preflight. A non-zero exit means the observed result
52
+ was `FAIL` or `UNKNOWN`; this is a CI gate, not a security certification.
53
+
54
+ ## Why
55
+
56
+ Shipping an x402 service ourselves ([ReceiptRail](https://github.com/xka0085-byte/agenttoll)),
57
+ we hit every way a paid endpoint can silently break:
58
+
59
+ - an endpoint that validates the request body **before** returning the 402
60
+ challenge is invisible to every x402 client — they only react to `402`;
61
+ - payment documents arrive in **four different places** (`Payment-Required` /
62
+ `X-Payment-Required` / `WWW-Authenticate` headers, or the response body) and
63
+ in **two different shapes** (v1 top-level `accepts[]`, v2 nested `x402.accepts`);
64
+ parsers that only look at one place report false failures;
65
+ - vendor hint headers without `accepts[]` can shadow the real payment document.
66
+
67
+ Each check in mcpdoctor maps to a failure mode we actually hit in production.
68
+
27
69
  ## Usage
28
70
 
29
71
  ```bash
@@ -38,8 +80,19 @@ mcpdoctor inspect <url> [--method=GET|POST] [--format=json|markdown]
38
80
 
39
81
  Exit codes: `0` PASS · `1` FAIL · `2` UNKNOWN (network/timeout) · `3` usage error.
40
82
 
83
+ ## Tool schema checks
84
+
85
+ Inspect MCP initialization and `tools/list` without calling tools:
86
+
87
+ ```bash
88
+ node mcpdoctor/bin/mcpdoctor.mjs schema https://your-mcp-server.example/mcp --json
89
+ ```
90
+
91
+ This is deterministic static lint, not a prediction of model tool selection or a cross-client certification. See [`SCHEMA-MVP.md`](./SCHEMA-MVP.md).
92
+
41
93
  ## Real examples (captured 2026-09-29, against live endpoints)
42
94
 
95
+
43
96
  Inspecting an MCP endpoint that is free (no payment gate) — the tool reports
44
97
  the 200 instead of a 402, and still verifies the discovery manifests:
45
98
 
package/bin/mcpdoctor.mjs CHANGED
@@ -3,7 +3,7 @@ import { createHash } from 'node:crypto';
3
3
 
4
4
  const MAX_BODY = 1024 * 1024;
5
5
  const TIMEOUT = 10_000;
6
- const VERSION = '0.1.2';
6
+ const VERSION = '0.1.4';
7
7
 
8
8
  const help = `mcpdoctor ${VERSION}
9
9
 
@@ -11,6 +11,7 @@ Read-only MCP/x402 endpoint diagnostics.
11
11
 
12
12
  Usage:
13
13
  mcpdoctor inspect <url> [--method=GET|POST] [--format=json|markdown]
14
+ mcpdoctor schema <url> [--format=json|markdown]
14
15
  mcpdoctor --help
15
16
 
16
17
  This MVP never signs, pays, retries payment, or accepts a private key.`;
@@ -126,9 +127,47 @@ function markdown(report) {
126
127
  return lines.join('\n');
127
128
  }
128
129
 
130
+ async function schemaCommand(url, format) {
131
+ const findings = [];
132
+ const add = (code, severity, message) => findings.push({ code, severity, message });
133
+ const response = await fetch(url, { method: 'POST', redirect: 'manual', signal: AbortSignal.timeout(TIMEOUT), headers: { 'content-type': 'application/json', accept: 'application/json, text/event-stream', 'MCP-Protocol-Version': '2025-03-26' }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2025-03-26', capabilities: {}, clientInfo: { name: 'mcpdoctor', version: VERSION } } }) });
134
+ const initText = await readBody(response);
135
+ if (!response.ok) throw new Error(`MCP initialize returned HTTP ${response.status}`);
136
+ const init = json(initText);
137
+ if (!init?.result?.protocolVersion) add('INITIALIZE_RESPONSE_INVALID', 'FAIL', 'Initialize response did not include result.protocolVersion');
138
+ const headers = { 'content-type': 'application/json', accept: 'application/json, text/event-stream', 'MCP-Protocol-Version': init?.result?.protocolVersion ?? '2025-03-26' };
139
+ const list = await fetch(url, { method: 'POST', redirect: 'manual', signal: AbortSignal.timeout(TIMEOUT), headers, body: JSON.stringify({ jsonrpc: '2.0', id: 2, method: 'tools/list', params: {} }) });
140
+ const listText = await readBody(list);
141
+ if (!list.ok) throw new Error(`tools/list returned HTTP ${list.status}`);
142
+ const parsed = json(listText);
143
+ const tools = parsed?.result?.tools;
144
+ if (!Array.isArray(tools)) add('TOOLS_LIST_INVALID', 'FAIL', 'tools/list response did not contain result.tools[]');
145
+ else if (!tools.length) add('NO_TOOLS', 'WARN', 'Server exposes an empty tool list');
146
+ else for (const [i, tool] of tools.entries()) {
147
+ const at = `tools[${i}]`;
148
+ if (typeof tool.name !== 'string' || !tool.name.trim()) add('TOOL_NAME_MISSING', 'FAIL', `${at} has no name`);
149
+ if (typeof tool.description !== 'string' || !tool.description.trim()) add('TOOL_DESCRIPTION_MISSING', 'WARN', `${at} has no description`);
150
+ const schema = tool.inputSchema;
151
+ if (!schema || schema.type !== 'object') add('INPUT_SCHEMA_NOT_OBJECT', 'FAIL', `${at}.inputSchema must declare type: object`);
152
+ const props = schema?.properties;
153
+ if (props !== undefined && (!props || typeof props !== 'object' || Array.isArray(props))) add('PROPERTIES_INVALID', 'FAIL', `${at}.inputSchema.properties must be an object`);
154
+ for (const req of schema?.required ?? []) if (!props?.[req]) add('REQUIRED_PROPERTY_UNDEFINED', 'FAIL', `${at} requires undeclared property ${req}`);
155
+ for (const [key, property] of Object.entries(props ?? {})) if (typeof property?.description !== 'string' || !property.description.trim()) add('PROPERTY_DESCRIPTION_MISSING', 'WARN', `${at}.${key} has no description`);
156
+ }
157
+ if (!findings.length) add('STATIC_SCHEMA_CHECKS_PASSED', 'INFO', `${tools.length} tools passed deterministic schema checks`);
158
+ const report = { reportVersion: 1, inspectorVersion: VERSION, mode: 'read-only MCP initialize + tools/list', checkedAt: new Date().toISOString(), endpoint: url.toString(), finalStatus: findings.some(x => x.severity === 'FAIL') ? 'FAIL' : 'PASS', mcp: { protocolVersion: init?.result?.protocolVersion ?? null, serverInfo: init?.result?.serverInfo ?? null, toolCount: Array.isArray(tools) ? tools.length : null }, findings, limitations: ['Static schema checks do not predict model tool selection or prove behavior across all clients.', 'No tool was called; side effects, authorization, data quality and security were not tested.'] };
159
+ console.log(format === 'json' ? JSON.stringify(report, null, 2) : `# MCP Tool Schema Report\n\n- Status: **${report.finalStatus}**\n- Endpoint: ${report.endpoint}\n- Protocol: ${report.mcp.protocolVersion ?? 'unknown'}\n- Tools: ${report.mcp.toolCount ?? 'unknown'}\n\n${findings.map(x => `- **${x.severity}** \`${x.code}\`: ${x.message}`).join('\n')}\n\n${report.limitations.map(x => `- ${x}`).join('\n')}`);
160
+ process.exitCode = report.finalStatus === 'PASS' ? 0 : 1;
161
+ }
162
+
129
163
  const args = process.argv.slice(2);
130
164
  if (args.includes('--help') || args.length === 0) { console.log(help); process.exitCode = args.length ? 0 : 3; }
131
- else if (args[0] !== 'inspect') die('only the inspect command is available in this MVP');
165
+ else if (args[0] === 'schema') {
166
+ let url; try { url = new URL(args[1]); if (!['http:', 'https:'].includes(url.protocol)) throw new Error('only http(s) URLs are supported'); } catch (error) { die(error.message); }
167
+ const format = args.includes('--json') || args.includes('--format=json') ? 'json' : 'markdown';
168
+ if (url) schemaCommand(url, format).catch((error) => { console.error(`UNKNOWN: ${redact(error.message)}`); process.exitCode = 2; });
169
+ }
170
+ else if (args[0] !== 'inspect') die('only inspect and schema commands are available in this MVP');
132
171
  else {
133
172
  const rawUrl = args[1];
134
173
  const method = (args.find((arg) => arg.startsWith('--method='))?.split('=')[1] ?? 'GET').toUpperCase();
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@eidonze/mcpdoctor",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "mcpName": "io.github.xka0085-byte/mcpdoctor",
5
- "description": "CLI for inspecting MCP and x402 endpoints: parses the HTTP 402 payment document (v1/v2 accepts[]), checks /.well-known/mcp and /.well-known/x402 discovery manifests, returns a response SHA-256 digest. Read-only endpoint inspector and preflight debugging tool for AI-agent payment endpoints. Not an MCP server. Zero dependencies.",
5
+ "description": "Read-only MCP and x402 endpoint preflight checks: 402 challenge shape, payment document parsing, accepts[] conformance, discovery manifests, response digest. Zero dependencies.",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "bin": { "mcpdoctor": "bin/mcpdoctor.mjs" },
package/test/smoke.mjs CHANGED
@@ -8,7 +8,7 @@ import path from 'node:path';
8
8
 
9
9
  const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
10
10
  const cli = path.join(root, 'bin', 'mcpdoctor.mjs');
11
- const server = createServer((request, response) => {
11
+ const server = createServer(async (request, response) => {
12
12
  if (request.url === '/good') {
13
13
  response.writeHead(402, { 'content-type': 'application/json', 'payment-required': JSON.stringify({ x402Version: 2, accepts: [{ scheme: 'exact', network: 'eip155:8453', asset: 'USDC', amount: '10000', payTo: '0x1234567890123456789012345678901234567890' }] }) });
14
14
  response.end(JSON.stringify({ x402Version: 2, accepts: [{ scheme: 'exact', network: 'eip155:8453', asset: 'USDC', amount: '10000', payTo: '0x1234567890123456789012345678901234567890' }] }));
@@ -21,6 +21,14 @@ const server = createServer((request, response) => {
21
21
  response.end(JSON.stringify({ x402Version: 2, resource: { url: 'x', description: 'd', mimeType: 'application/json' }, accepts: [{ scheme: 'exact', network: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1', amount: '1000', asset: 'MINT', payTo: 'PayToAddr' }] }));
22
22
  return;
23
23
  }
24
+ if (request.url === '/mcp') {
25
+ let incoming = ''; for await (const chunk of request) incoming += chunk;
26
+ const rpc = JSON.parse(incoming || '{}');
27
+ if (rpc.method === 'initialize') {
28
+ response.writeHead(200, { 'content-type': 'application/json' }); response.end(JSON.stringify({ jsonrpc: '2.0', id: rpc.id, result: { protocolVersion: '2025-06-18', serverInfo: { name: 'fixture', version: '1' }, capabilities: {} } })); return;
29
+ }
30
+ response.writeHead(200, { 'content-type': 'application/json' }); response.end(JSON.stringify({ jsonrpc: '2.0', id: rpc.id, result: { tools: [{ name: 'hello', description: 'Returns a greeting.', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name.' } }, required: ['name'] } }] } })); return;
31
+ }
24
32
  // regression (our original production bug): body validation must not shadow the 402
25
33
  if (request.url === '/bad-400') {
26
34
  response.writeHead(400, { 'content-type': 'application/json' });
@@ -43,6 +51,15 @@ function run(url, ...args) {
43
51
  child.on('close', (code) => resolve({ code, stdout, stderr }));
44
52
  });
45
53
  }
54
+ function runSchema(url) {
55
+ return new Promise((resolve) => {
56
+ const child = spawn(process.execPath, [cli, 'schema', url, '--format=json'], { stdio: ['ignore', 'pipe', 'pipe'] });
57
+ let stdout = ''; let stderr = '';
58
+ child.stdout.on('data', (chunk) => { stdout += chunk; });
59
+ child.stderr.on('data', (chunk) => { stderr += chunk; });
60
+ child.on('close', (code) => resolve({ code, stdout, stderr }));
61
+ });
62
+ }
46
63
 
47
64
  try {
48
65
  const good = await run(`http://127.0.0.1:${port}/good`);
@@ -61,6 +78,11 @@ try {
61
78
  const bad400Report = JSON.parse(bad400.stdout);
62
79
  assert.equal(bad400Report.finalStatus, 'FAIL');
63
80
  assert.ok(bad400Report.findings.some((f) => f.code === 'NO_402'), 'must flag 400-instead-of-402');
81
+ const schema = await runSchema(`http://127.0.0.1:${port}/mcp`);
82
+ assert.equal(schema.code, 0, schema.stderr);
83
+ const schemaReport = JSON.parse(schema.stdout);
84
+ assert.equal(schemaReport.finalStatus, 'PASS', JSON.stringify(schemaReport.findings));
85
+ assert.equal(schemaReport.mcp.toolCount, 1);
64
86
  const help = await new Promise((resolve) => {
65
87
  const child = spawn(process.execPath, [cli, '--help'], { stdio: ['ignore', 'pipe', 'pipe'] });
66
88
  let stdout = ''; child.stdout.on('data', (chunk) => { stdout += chunk; }); child.on('close', (code) => resolve({ code, stdout }));