@eidonze/mcpdoctor 0.1.6 → 0.1.7

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
@@ -20,13 +20,13 @@ Read-only checks for MCP tool schemas and x402 payment endpoints. Use it before
20
20
  Check an MCP server without calling any tools:
21
21
 
22
22
  ```bash
23
- npx @eidonze/mcpdoctor@0.1.5 schema https://your-mcp-server.example/mcp --json
23
+ npx @eidonze/mcpdoctor@0.1.6 schema https://your-mcp-server.example/mcp --json
24
24
  ```
25
25
 
26
26
  Check an x402 endpoint without paying:
27
27
 
28
28
  ```bash
29
- npx @eidonze/mcpdoctor@0.1.5 inspect https://your-api.example/paid --method=POST --json
29
+ npx @eidonze/mcpdoctor@0.1.6 inspect https://your-api.example/paid --method=POST --json
30
30
  ```
31
31
 
32
32
  Requires Node.js 18+. No API key or wallet is needed.
@@ -57,6 +57,18 @@ The exact same run against a healthy server prints `Status: PASS` and exits 0, s
57
57
 
58
58
  Exit codes are stable for automation: `0` PASS, `1` FAIL, `2` UNKNOWN/network error, `3` usage error.
59
59
 
60
+ ## What it does NOT check
61
+
62
+ mcpdoctor is a protocol- and schema-level preflight, not a security audit. It does not:
63
+
64
+ - Detect malicious code, prompt injection, or supply-chain risk in the server's implementation
65
+ - Call tools, so it cannot prove runtime behavior, data handling, or permission scope
66
+ - Bypass, test, or evaluate authentication and authorization
67
+ - Verify payment settlement or delivery for x402 endpoints
68
+ - Certify compliance with any spec beyond the response shapes it inspects
69
+
70
+ A `PASS` means the observed handshake and schemas were well-formed at scan time. Nothing more.
71
+
60
72
  ## GitHub Actions
61
73
 
62
74
  Add a read-only check to pull requests:
@@ -0,0 +1,105 @@
1
+ // mcpdoctor-mcp: run mcpdoctor as an MCP server (stdio, zero dependencies).
2
+ // Exposes two tools so AI clients can check endpoints without leaving chat:
3
+ // schema_check(url) - read-only MCP handshake + tools/list validation
4
+ // x402_inspect(url) - read-only 402 challenge validation, never pays
5
+ // Protocol: newline-delimited JSON-RPC 2.0 per the MCP stdio transport spec.
6
+ import { spawn } from 'node:child_process';
7
+ import path from 'node:path';
8
+ import url from 'node:url';
9
+ import readline from 'node:readline';
10
+
11
+ const cliPath = path.join(path.dirname(url.fileURLToPath(import.meta.url)), 'mcpdoctor.mjs');
12
+
13
+ const TOOLS = [
14
+ {
15
+ name: 'schema_check',
16
+ description: 'Run a read-only MCP preflight check against a server URL: initialize handshake, tools/list, and tool JSON schema validation. Never calls tools or reads data. Returns PASS/FAIL/UNKNOWN with detailed findings.',
17
+ inputSchema: {
18
+ type: 'object',
19
+ properties: {
20
+ url: { type: 'string', description: 'MCP server endpoint URL, e.g. https://example.com/mcp' },
21
+ },
22
+ required: ['url'],
23
+ },
24
+ },
25
+ {
26
+ name: 'x402_inspect',
27
+ description: 'Inspect an x402 payment endpoint without paying: reads the HTTP 402 challenge, validates the payment document shape, accepts[] entries and discovery manifests. Never signs or settles.',
28
+ inputSchema: {
29
+ type: 'object',
30
+ properties: {
31
+ url: { type: 'string', description: 'x402 resource URL, e.g. https://api.example/paid' },
32
+ method: { type: 'string', enum: ['GET', 'POST'], description: 'HTTP method to probe with, default GET' },
33
+ },
34
+ required: ['url'],
35
+ },
36
+ },
37
+ ];
38
+
39
+ function runCli(args) {
40
+ return new Promise((resolve) => {
41
+ const child = spawn(process.execPath, [cliPath, ...args, '--json'], { stdio: ['ignore', 'pipe', 'pipe'] });
42
+ let out = '', err = '';
43
+ child.stdout.on('data', (d) => (out += d));
44
+ child.stderr.on('data', (d) => (err += d));
45
+ const t = setTimeout(() => { try { child.kill('SIGKILL'); } catch { /* gone */ } }, 45000);
46
+ child.on('close', (code) => {
47
+ clearTimeout(t);
48
+ resolve({ code, out: out.trim(), err: err.trim() });
49
+ });
50
+ });
51
+ }
52
+
53
+ async function callTool(name, args) {
54
+ if (name === 'schema_check') {
55
+ const r = await runCli(['schema', String(args.url)]);
56
+ const text = r.out || r.err || `exit ${r.code}`;
57
+ return { content: [{ type: 'text', text }], isError: r.code === 1 ? false : r.code >= 2 };
58
+ }
59
+ if (name === 'x402_inspect') {
60
+ const m = ['GET', 'POST'].includes(String(args.method ?? '').toUpperCase()) ? `--method=${String(args.method).toUpperCase()}` : '';
61
+ const r = await runCli(['inspect', String(args.url), m].filter(Boolean));
62
+ const text = r.out || r.err || `exit ${r.code}`;
63
+ return { content: [{ type: 'text', text }], isError: r.code === 1 ? false : r.code >= 2 };
64
+ }
65
+ throw new Error(`unknown tool: ${name}`);
66
+ }
67
+
68
+ const serverInfo = { name: 'mcpdoctor', version: '0.1.7' };
69
+ const write = (msg) => process.stdout.write(JSON.stringify(msg) + '\n');
70
+
71
+ const rl = readline.createInterface({ input: process.stdin, terminal: false });
72
+ rl.on('line', async (line) => {
73
+ if (!line.trim()) return;
74
+ let msg;
75
+ try { msg = JSON.parse(line); } catch { return; }
76
+ const { id, method, params } = msg;
77
+ const respond = (result) => id !== undefined && write({ jsonrpc: '2.0', id, result });
78
+ const fail = (code, message) => id !== undefined && write({ jsonrpc: '2.0', id, error: { code, message } });
79
+
80
+ switch (method) {
81
+ case 'initialize':
82
+ respond({ protocolVersion: params?.protocolVersion ?? '2025-06-18', capabilities: { tools: {} }, serverInfo });
83
+ break;
84
+ case 'notifications/initialized':
85
+ case 'notifications/cancelled':
86
+ break;
87
+ case 'ping':
88
+ respond({});
89
+ break;
90
+ case 'tools/list':
91
+ respond({ tools: TOOLS });
92
+ break;
93
+ case 'tools/call': {
94
+ try {
95
+ const result = await callTool(String(params?.name), params?.arguments ?? {});
96
+ respond(result);
97
+ } catch (e) {
98
+ fail(-32000, String(e.message ?? e));
99
+ }
100
+ break;
101
+ }
102
+ default:
103
+ fail(-32601, `method not found: ${method}`);
104
+ }
105
+ });
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@eidonze/mcpdoctor",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "mcpName": "io.github.xka0085-byte/mcpdoctor",
5
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": {
9
- "mcpdoctor": "bin/mcpdoctor.mjs"
9
+ "mcpdoctor": "bin/mcpdoctor.mjs",
10
+ "mcpdoctor-mcp": "bin/mcpdoctor-mcp.mjs"
10
11
  },
11
12
  "main": "bin/mcpdoctor.mjs",
12
13
  "files": [