@eidonze/mcpdoctor 0.1.1 → 0.1.3

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 ADDED
@@ -0,0 +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.
package/README.md CHANGED
@@ -1,29 +1,30 @@
1
1
  # mcpdoctor
2
2
 
3
- Read-only preflight checks for **x402 payment endpoints** and **MCP servers**.
4
- One command tells you whether your paid endpoint answers the way agent clients
5
- actually expect — before a real buyer (human or AI) hits it.
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`.
6
4
 
7
- Zero dependencies. Runs anywhere Node ≥ 18 runs. Never touches your keys.
5
+ **mcpdoctor is a read-only CLI for inspecting MCP and x402 endpoints.**
8
6
 
9
- ```bash
10
- npx @eidonze/mcpdoctor inspect https://your-endpoint/v1/paid --method=POST
11
- ```
7
+ Point it at a URL, get one `PASS / FAIL / UNKNOWN` report:
12
8
 
13
- ## Why
9
+ - the **HTTP 402 payment document** — parsed from the known locations
10
+ (`Payment-Required` / `X-Payment-Required` / `WWW-Authenticate` headers or
11
+ the response body), in both x402 v1 (`accepts[]`) and v2 (`x402.accepts`)
12
+ shapes, with every `scheme / network / asset / amount / payTo` field checked;
13
+ - the **discovery manifests** — whether `/.well-known/mcp/server.json` and
14
+ `/.well-known/x402` are reachable, with a SHA-256 of each;
15
+ - a **SHA-256 digest** of the response body, plus latency and size.
14
16
 
15
- Shipping an x402 service ourselves ([ReceiptRail](https://github.com/xka0085-byte/agenttoll)),
16
- we hit every way a paid endpoint can silently break:
17
+ mcpdoctor is **not an MCP server** and does not implement the MCP protocol.
18
+ It is the endpoint inspector you run *before* pointing an MCP client or an
19
+ x402 buyer at an endpoint — a preflight/debugging tool for AI-agent payment
20
+ infrastructure. Zero dependencies. Node ≥ 18. Never touches keys, never pays.
17
21
 
18
- - an endpoint that validates the request body **before** returning the 402
19
- challenge is invisible to every x402 client — they only react to `402`;
20
- - payment documents arrive in **four different places** (`Payment-Required` /
21
- `X-Payment-Required` / `WWW-Authenticate` headers, or the response body) and
22
- in **two different shapes** (v1 top-level `accepts[]`, v2 nested `x402.accepts`);
23
- parsers that only look at one place report false failures;
24
- - vendor hint headers without `accepts[]` can shadow the real payment document.
22
+ ## Install
25
23
 
26
- Each check in mcpdoctor maps to a failure mode we actually hit in production.
24
+ ```bash
25
+ npm install -g @eidonze/mcpdoctor # or run without installing:
26
+ npx @eidonze/mcpdoctor inspect <url>
27
+ ```
27
28
 
28
29
  ## Usage
29
30
 
@@ -35,47 +36,75 @@ mcpdoctor inspect <url> [--method=GET|POST] [--format=json|markdown]
35
36
  |---|---|---|
36
37
  | `--method` | `GET` | HTTP verb for the probe (`POST` sends `{}`) |
37
38
  | `--format` | `markdown` | `json` for CI / machine-readable reports |
39
+ | `--json` | — | shorthand for `--format=json` |
40
+
41
+ Exit codes: `0` PASS · `1` FAIL · `2` UNKNOWN (network/timeout) · `3` usage error.
42
+
43
+ ## Real examples (captured 2026-09-29, against live endpoints)
44
+
45
+ Inspecting an MCP endpoint that is free (no payment gate) — the tool reports
46
+ the 200 instead of a 402, and still verifies the discovery manifests:
47
+
48
+ ```json
49
+ {
50
+ "endpoint": "https://agenttoll-receipts.app.workbuddy.host/mcp",
51
+ "method": "POST",
52
+ "finalStatus": "FAIL",
53
+ "http": { "status": 200, "elapsedMs": 2830, "bodyBytes": 82,
54
+ "bodySha256": "598dc097dcca1e573c742100863899c00724a021b421a5bb49952d49fec6b4f4" },
55
+ "findings": [
56
+ { "status": "FAIL", "code": "NO_402", "message": "Expected HTTP 402, received 200" }
57
+ ],
58
+ "metadata": [
59
+ { "path": "/.well-known/mcp/server.json", "status": 200, "reachable": true }
60
+ ]
61
+ }
62
+ ```
38
63
 
39
- The report includes the observed HTTP status, the parsed payment requirements
40
- (`accepts[]` with scheme / network / asset / amount / payTo / timeout), response
41
- latency, size, a SHA-256 digest of the response bytes (tamper-evident record),
42
- and reachability of `/.well-known/mcp/server.json` and `/.well-known/x402`.
43
-
44
- ## Exit codes
45
-
46
- | Code | Meaning |
47
- |---|---|
48
- | `0` | PASS — parseable 402 payment document with required fields |
49
- | `1` | FAIL — endpoint responded but is not 402 / document incomplete |
50
- | `2` | UNKNOWN — endpoint could not be observed within limits |
51
- | `3` | invalid command |
64
+ Inspecting the official x402 demo endpoint — it does return 402, but ships a
65
+ payment document mcpdoctor cannot parse, which is exactly the class of silent
66
+ breakage this CLI exists to catch:
67
+
68
+ ```json
69
+ {
70
+ "endpoint": "https://x402.org/protected",
71
+ "finalStatus": "FAIL",
72
+ "http": { "status": 402 },
73
+ "headers": { "paymentRequired": true },
74
+ "findings": [
75
+ { "status": "FAIL", "code": "NO_ACCEPTS",
76
+ "message": "No recognizable payment requirement found" }
77
+ ]
78
+ }
79
+ ```
52
80
 
53
- ## Verified, not vibes
81
+ ## What it does NOT do
54
82
 
55
- - **Positive control**: passes against a production x402 service that itself
56
- survived x402scan's auditor (ReceiptRail, dual-network settlement).
57
- - **Negative control**: the test suite spins up a server that returns `400`
58
- instead of `402` — the exact production bug that inspired this tool — and
59
- asserts mcpdoctor flags it (`NO_402`), plus a header-hint-shadowing case.
83
+ - No MCP protocol session: no `initialize`, no `tools/list` — mcpdoctor
84
+ checks what an endpoint *advertises* (402 documents, discovery manifests),
85
+ not a full MCP handshake.
86
+ - No wallet, signing, settlement, or retries. Read-only preflight only.
87
+ - `PASS` means the observed 402 document had recognizable, complete fields —
88
+ it is not a security or payment-success certification.
60
89
 
61
- ```bash
62
- npm test
63
- ```
90
+ ## Why
64
91
 
65
- ## Safety boundary
92
+ We ship an x402 service ourselves ([ReceiptRail](https://github.com/xka0085-byte/agenttoll))
93
+ and hit every way a paid endpoint can silently break:
66
94
 
67
- Read-only. mcpdoctor never signs, pays, retries payment, calls a facilitator,
68
- or accepts a private key. A `PASS` is not a security audit, payment-success
69
- certificate, or compliance decision — it means the observed 402 document had
70
- recognizable, well-formed fields.
95
+ - an endpoint that validates the request body **before** returning the 402
96
+ challenge is invisible to every x402 client — they only react to `402`;
97
+ - payment documents arrive in **four different places** and **two different
98
+ shapes**; parsers that only look at one place report false failures;
99
+ - vendor hint headers without `accepts[]` can shadow the real payment document.
71
100
 
72
- ## Roadmap
101
+ Each check in mcpdoctor maps to a failure mode we actually hit in production.
73
102
 
74
- - `extensions.bazaar` schema conformance (x402 Bazaar discovery listings)
75
- - `x-payment-info.protocols` object-array check
76
- - MCP streamable-HTTP `initialize` handshake check
77
- - `/.well-known/mcp/server-card.json` (Smithery SEP-1649) validation
103
+ ## Part of the Agent / Chain Evidence Tools suite
78
104
 
79
- ## License
105
+ Read-only diagnostics for AI agents on Web3 —
106
+ [hub & docs](https://xka0085-byte.github.io/evidence-tools/) ·
107
+ [ReceiptRail (live MCP service)](https://github.com/xka0085-byte/agenttoll) ·
108
+ [npm: @eidonze/mcpdoctor](https://www.npmjs.com/package/@eidonze/mcpdoctor)
80
109
 
81
- MIT
110
+ MIT licensed. Known limitations are documented, not hidden.
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.0';
6
+ const VERSION = '0.1.3';
7
7
 
8
8
  const help = `mcpdoctor ${VERSION}
9
9
 
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@eidonze/mcpdoctor",
3
- "version": "0.1.1",
4
- "description": "Read-only MCP and x402 endpoint preflight checks: 402 challenge shape, payment document parsing, accepts[] conformance, discovery manifests, response digest. Zero dependencies.",
3
+ "version": "0.1.3",
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
6
  "license": "MIT",
6
7
  "type": "module",
7
8
  "bin": { "mcpdoctor": "bin/mcpdoctor.mjs" },
8
9
  "main": "bin/mcpdoctor.mjs",
10
+ "files": ["bin", "test", "README.md", "LICENSE"],
9
11
  "engines": { "node": ">=18" },
10
12
  "scripts": { "test": "node test/smoke.mjs" },
11
- "keywords": ["mcp", "x402", "model-context-protocol", "developer-tools", "diagnostics", "web3", "solana", "usdc", "agent-payments", "linter"],
13
+ "keywords": ["mcp", "model-context-protocol", "mcp-cli", "mcp-inspector", "mcp-endpoint-inspector", "mcp-debugging", "x402", "cli", "developer-tools", "diagnostics"],
12
14
  "repository": { "type": "git", "url": "git+https://github.com/xka0085-byte/mcp-doctor.git" },
13
15
  "bugs": { "url": "https://github.com/xka0085-byte/mcp-doctor/issues" },
14
- "homepage": "https://github.com/xka0085-byte/mcp-doctor#readme"
16
+ "homepage": "https://xka0085-byte.github.io/evidence-tools/"
15
17
  }
package/test/smoke.mjs CHANGED
@@ -1,73 +1,73 @@
1
- #!/usr/bin/env node
2
- import assert from 'node:assert/strict';
3
- import { createServer } from 'node:http';
4
- import { spawn } from 'node:child_process';
5
- import { once } from 'node:events';
6
- import { fileURLToPath } from 'node:url';
7
- import path from 'node:path';
8
-
9
- const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
10
- const cli = path.join(root, 'bin', 'mcpdoctor.mjs');
11
- const server = createServer((request, response) => {
12
- if (request.url === '/good') {
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
- response.end(JSON.stringify({ x402Version: 2, accepts: [{ scheme: 'exact', network: 'eip155:8453', asset: 'USDC', amount: '10000', payTo: '0x1234567890123456789012345678901234567890' }] }));
15
- return;
16
- }
17
- // regression (found against production ReceiptRail): a hint header WITHOUT accepts[]
18
- // must not shadow the real payment document in the body
19
- if (request.url === '/header-hint') {
20
- response.writeHead(402, { 'content-type': 'application/json', 'x-payment-required': JSON.stringify({ vendor: 'VendorHintNoAccepts', amount: '1000', decimals: 6 }) });
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
- return;
23
- }
24
- // regression (our original production bug): body validation must not shadow the 402
25
- if (request.url === '/bad-400') {
26
- response.writeHead(400, { 'content-type': 'application/json' });
27
- response.end(JSON.stringify({ error: 'missing body param' }));
28
- return;
29
- }
30
- response.writeHead(404, { 'content-type': 'application/json' });
31
- response.end(JSON.stringify({ error: 'not found' }));
32
- });
33
- server.listen(0, '127.0.0.1');
34
- await once(server, 'listening');
35
- const port = server.address().port;
36
-
37
- function run(url, ...args) {
38
- return new Promise((resolve) => {
39
- const child = spawn(process.execPath, [cli, 'inspect', url, '--format=json', ...args], { stdio: ['ignore', 'pipe', 'pipe'] });
40
- let stdout = ''; let stderr = '';
41
- child.stdout.on('data', (chunk) => { stdout += chunk; });
42
- child.stderr.on('data', (chunk) => { stderr += chunk; });
43
- child.on('close', (code) => resolve({ code, stdout, stderr }));
44
- });
45
- }
46
-
47
- try {
48
- const good = await run(`http://127.0.0.1:${port}/good`);
49
- assert.equal(good.code, 0, good.stderr);
50
- assert.equal(JSON.parse(good.stdout).finalStatus, 'PASS');
51
- const bad = await run(`http://127.0.0.1:${port}/missing`);
52
- assert.equal(bad.code, 1, bad.stderr);
53
- assert.equal(JSON.parse(bad.stdout).finalStatus, 'FAIL');
54
- const hint = await run(`http://127.0.0.1:${port}/header-hint`, '--method=POST');
55
- assert.equal(hint.code, 0, hint.stderr);
56
- const hintReport = JSON.parse(hint.stdout);
57
- assert.equal(hintReport.finalStatus, 'PASS', JSON.stringify(hintReport.findings));
58
- assert.equal(hintReport.x402.accepts.length, 1, 'body accepts[] must win over accept-less header hints');
59
- const bad400 = await run(`http://127.0.0.1:${port}/bad-400`, '--method=POST');
60
- assert.equal(bad400.code, 1, bad400.stderr);
61
- const bad400Report = JSON.parse(bad400.stdout);
62
- assert.equal(bad400Report.finalStatus, 'FAIL');
63
- assert.ok(bad400Report.findings.some((f) => f.code === 'NO_402'), 'must flag 400-instead-of-402');
64
- const help = await new Promise((resolve) => {
65
- const child = spawn(process.execPath, [cli, '--help'], { stdio: ['ignore', 'pipe', 'pipe'] });
66
- let stdout = ''; child.stdout.on('data', (chunk) => { stdout += chunk; }); child.on('close', (code) => resolve({ code, stdout }));
67
- });
68
- assert.equal(help.code, 0);
69
- assert.match(help.stdout, /mcpdoctor/);
70
- console.log('mcpdoctor smoke tests passed');
71
- } finally {
72
- server.close();
73
- }
1
+ #!/usr/bin/env node
2
+ import assert from 'node:assert/strict';
3
+ import { createServer } from 'node:http';
4
+ import { spawn } from 'node:child_process';
5
+ import { once } from 'node:events';
6
+ import { fileURLToPath } from 'node:url';
7
+ import path from 'node:path';
8
+
9
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
10
+ const cli = path.join(root, 'bin', 'mcpdoctor.mjs');
11
+ const server = createServer((request, response) => {
12
+ if (request.url === '/good') {
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
+ response.end(JSON.stringify({ x402Version: 2, accepts: [{ scheme: 'exact', network: 'eip155:8453', asset: 'USDC', amount: '10000', payTo: '0x1234567890123456789012345678901234567890' }] }));
15
+ return;
16
+ }
17
+ // regression (found against production ReceiptRail): a hint header WITHOUT accepts[]
18
+ // must not shadow the real payment document in the body
19
+ if (request.url === '/header-hint') {
20
+ response.writeHead(402, { 'content-type': 'application/json', 'x-payment-required': JSON.stringify({ vendor: 'VendorHintNoAccepts', amount: '1000', decimals: 6 }) });
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
+ return;
23
+ }
24
+ // regression (our original production bug): body validation must not shadow the 402
25
+ if (request.url === '/bad-400') {
26
+ response.writeHead(400, { 'content-type': 'application/json' });
27
+ response.end(JSON.stringify({ error: 'missing body param' }));
28
+ return;
29
+ }
30
+ response.writeHead(404, { 'content-type': 'application/json' });
31
+ response.end(JSON.stringify({ error: 'not found' }));
32
+ });
33
+ server.listen(0, '127.0.0.1');
34
+ await once(server, 'listening');
35
+ const port = server.address().port;
36
+
37
+ function run(url, ...args) {
38
+ return new Promise((resolve) => {
39
+ const child = spawn(process.execPath, [cli, 'inspect', url, '--format=json', ...args], { stdio: ['ignore', 'pipe', 'pipe'] });
40
+ let stdout = ''; let stderr = '';
41
+ child.stdout.on('data', (chunk) => { stdout += chunk; });
42
+ child.stderr.on('data', (chunk) => { stderr += chunk; });
43
+ child.on('close', (code) => resolve({ code, stdout, stderr }));
44
+ });
45
+ }
46
+
47
+ try {
48
+ const good = await run(`http://127.0.0.1:${port}/good`);
49
+ assert.equal(good.code, 0, good.stderr);
50
+ assert.equal(JSON.parse(good.stdout).finalStatus, 'PASS');
51
+ const bad = await run(`http://127.0.0.1:${port}/missing`);
52
+ assert.equal(bad.code, 1, bad.stderr);
53
+ assert.equal(JSON.parse(bad.stdout).finalStatus, 'FAIL');
54
+ const hint = await run(`http://127.0.0.1:${port}/header-hint`, '--method=POST');
55
+ assert.equal(hint.code, 0, hint.stderr);
56
+ const hintReport = JSON.parse(hint.stdout);
57
+ assert.equal(hintReport.finalStatus, 'PASS', JSON.stringify(hintReport.findings));
58
+ assert.equal(hintReport.x402.accepts.length, 1, 'body accepts[] must win over accept-less header hints');
59
+ const bad400 = await run(`http://127.0.0.1:${port}/bad-400`, '--method=POST');
60
+ assert.equal(bad400.code, 1, bad400.stderr);
61
+ const bad400Report = JSON.parse(bad400.stdout);
62
+ assert.equal(bad400Report.finalStatus, 'FAIL');
63
+ assert.ok(bad400Report.findings.some((f) => f.code === 'NO_402'), 'must flag 400-instead-of-402');
64
+ const help = await new Promise((resolve) => {
65
+ const child = spawn(process.execPath, [cli, '--help'], { stdio: ['ignore', 'pipe', 'pipe'] });
66
+ let stdout = ''; child.stdout.on('data', (chunk) => { stdout += chunk; }); child.on('close', (code) => resolve({ code, stdout }));
67
+ });
68
+ assert.equal(help.code, 0);
69
+ assert.match(help.stdout, /mcpdoctor/);
70
+ console.log('mcpdoctor smoke tests passed');
71
+ } finally {
72
+ server.close();
73
+ }