@yawlabs/mcp-compliance 0.8.1 → 0.9.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
@@ -5,7 +5,7 @@
5
5
  [![GitHub stars](https://img.shields.io/github/stars/YawLabs/mcp-compliance)](https://github.com/YawLabs/mcp-compliance/stargazers)
6
6
  [![CI](https://github.com/YawLabs/mcp-compliance/actions/workflows/ci.yml/badge.svg)](https://github.com/YawLabs/mcp-compliance/actions/workflows/ci.yml)
7
7
 
8
- **Test any MCP server for spec compliance.** 81-test suite covering transport, lifecycle, tools, resources, prompts, error handling, schema validation, and security against the [MCP specification](https://modelcontextprotocol.io/specification/2025-11-25). CLI, MCP server, and programmatic API.
8
+ **Test any MCP server for spec compliance.** 84-test suite covering transport, lifecycle, tools, resources, prompts, error handling, schema validation, and security against the [MCP specification](https://modelcontextprotocol.io/specification/2025-11-25). Works against **HTTP endpoints** (`https://my-server.com/mcp`) and **stdio servers** (`npx @modelcontextprotocol/server-filesystem /tmp`) alike. CLI, MCP server, and programmatic API.
9
9
 
10
10
  Built and maintained by [Yaw Labs](https://yaw.sh).
11
11
 
@@ -15,7 +15,7 @@ MCP servers are multiplying fast — but most ship without compliance testing. B
15
15
 
16
16
  This tool solves that:
17
17
 
18
- - **81 tests across 8 categories** — transport, lifecycle, tools, resources, prompts, error handling, schema validation, and security. No gaps.
18
+ - **84 tests across 8 categories** — transport, lifecycle, tools, resources, prompts, error handling, schema validation, and security. No gaps.
19
19
  - **Capability-driven** — tests adapt to what the server declares. If it says it supports tools, tool tests become required. No false failures for features the server doesn't claim.
20
20
  - **Graded scoring** — A-F letter grade with a weighted score (required tests 70%, optional 30%). One number to communicate compliance.
21
21
  - **CI-ready** — `--strict` mode exits with code 1 on required test failures. Drop it into any pipeline.
@@ -25,13 +25,26 @@ This tool solves that:
25
25
 
26
26
  ## Quick start
27
27
 
28
- **Run against any MCP server:**
28
+ **Remote HTTP server:**
29
29
 
30
30
  ```bash
31
31
  npx @yawlabs/mcp-compliance test https://my-server.com/mcp
32
32
  ```
33
33
 
34
- **Or install globally:**
34
+ **Local stdio server** (the vast majority of MCP servers on npm):
35
+
36
+ ```bash
37
+ # Pass the command directly, Inspector-style
38
+ npx @yawlabs/mcp-compliance test npx @modelcontextprotocol/server-filesystem /tmp
39
+
40
+ # Or a local build
41
+ npx @yawlabs/mcp-compliance test node ./dist/server.js
42
+
43
+ # With env vars
44
+ npx @yawlabs/mcp-compliance test -E GITHUB_TOKEN=$GITHUB_TOKEN -- npx @modelcontextprotocol/server-github
45
+ ```
46
+
47
+ **Install globally:**
35
48
 
36
49
  ```bash
37
50
  npm install -g @yawlabs/mcp-compliance
@@ -42,65 +55,178 @@ That's it. You'll get a colored terminal report with a letter grade (A-F), per-t
42
55
 
43
56
  ## CLI usage
44
57
 
58
+ ### HTTP targets
59
+
45
60
  ```bash
46
61
  # Terminal output with colors and grade
47
62
  mcp-compliance test https://my-server.com/mcp
48
63
 
49
- # JSON output (for scripting)
64
+ # JSON / SARIF for scripting + GitHub Code Scanning
50
65
  mcp-compliance test https://my-server.com/mcp --format json
51
-
52
- # SARIF output (for GitHub Code Scanning)
53
66
  mcp-compliance test https://my-server.com/mcp --format sarif > compliance.sarif
54
67
 
55
- # Strict mode — exits with code 1 on required test failure (for CI)
68
+ # Strict mode for CI — exits 1 on required-test failure
56
69
  mcp-compliance test https://my-server.com/mcp --strict
57
70
 
58
- # With authentication
71
+ # Auth (shorthand or full header)
59
72
  mcp-compliance test https://my-server.com/mcp --auth "Bearer tok123"
73
+ mcp-compliance test https://my-server.com/mcp -H "X-Api-Key: abc"
60
74
 
61
- # Custom headers (repeatable)
62
- mcp-compliance test https://my-server.com/mcp -H "Authorization: Bearer tok123" -H "X-Api-Key: abc"
75
+ # Focus the run
76
+ mcp-compliance test https://my-server.com/mcp --only transport,lifecycle
77
+ mcp-compliance test https://my-server.com/mcp --skip prompts,resources
78
+ mcp-compliance test https://my-server.com/mcp --verbose
79
+ ```
63
80
 
64
- # Custom timeout (default: 15000ms)
65
- mcp-compliance test https://my-server.com/mcp --timeout 30000
81
+ ### stdio targets
66
82
 
67
- # Retry failed tests
68
- mcp-compliance test https://my-server.com/mcp --retries 2
83
+ Pass the command and its args as positional arguments (MCP Inspector-style). Use `--` to disambiguate when the target needs flags that collide with ours.
69
84
 
70
- # Only run specific categories or test IDs
71
- mcp-compliance test https://my-server.com/mcp --only transport,lifecycle
72
- mcp-compliance test https://my-server.com/mcp --only lifecycle-init,tools-list
85
+ ```bash
86
+ # npm-distributed stdio servers
87
+ mcp-compliance test npx -y @modelcontextprotocol/server-filesystem /tmp
88
+ mcp-compliance test uvx mcp-server-git
73
89
 
74
- # Skip specific categories or test IDs
75
- mcp-compliance test https://my-server.com/mcp --skip prompts,resources
90
+ # Local build
91
+ mcp-compliance test node ./dist/server.js
76
92
 
77
- # Verbose mode print each test result as it runs
78
- mcp-compliance test https://my-server.com/mcp --verbose
93
+ # With env vars (repeatable -E, or --env-file)
94
+ mcp-compliance test -E API_KEY=secret -E REGION=us-east-1 -- npx my-server
95
+ mcp-compliance test --env-file .env -- node ./server.js
96
+
97
+ # Set working directory
98
+ mcp-compliance test --cwd ./services/mcp -- node ./dist/server.js
99
+
100
+ # Target uses a flag that collides with ours — use `--` to separate
101
+ mcp-compliance test --verbose -- node ./server.js --verbose
79
102
  ```
80
103
 
104
+ On Windows, `npx` and other `.cmd` shims are handled automatically by spawning through the shell.
105
+
81
106
  ### Options
82
107
 
108
+ | Option | Applies to | Description |
109
+ |--------|-----------|-------------|
110
+ | `--format <format>` | both | Output format: `terminal`, `json`, `sarif`, `github`, or `markdown` (default: `terminal`) |
111
+ | `--config <path>` | both | Load defaults from a config file (default: `mcp-compliance.config.json` in cwd) |
112
+ | `--output <file>` | both | Write a local SVG badge to the given path after the run |
113
+ | `--list` | both | Print test IDs that would run given current filters, then exit (no connection) |
114
+ | `--transport <kind>` | both | Filter by `http` or `stdio` (only used with `--list` when no target is provided) |
115
+ | `--strict` | both | Exit with code 1 on any required test failure (for CI) |
116
+ | `--min-grade <grade>` | both | Exit with code 1 if grade is below this threshold (`A`–`F`) |
117
+ | `-H, --header <h>` | HTTP | Add header to all requests, format `"Key: Value"` (repeatable) |
118
+ | `--auth <token>` | HTTP | Shorthand for `-H "Authorization: <token>"` |
119
+ | `-E, --env <var>` | stdio | Set env var for stdio command, format `"KEY=VALUE"` (repeatable) |
120
+ | `--env-file <path>` | stdio | Load env vars from a file (one `KEY=VALUE` per line) |
121
+ | `--cwd <dir>` | stdio | Working directory for the stdio command |
122
+ | `--timeout <ms>` | both | Request timeout in milliseconds (default: `15000`) |
123
+ | `--preflight-timeout <ms>` | HTTP | Preflight connectivity check timeout (HTTP only) |
124
+ | `--retries <n>` | both | Number of retries for failed tests (default: `0`) |
125
+ | `--only <items>` | both | Only run tests matching these categories or test IDs (comma-separated) |
126
+ | `--skip <items>` | both | Skip tests matching these categories or test IDs (comma-separated) |
127
+ | `--verbose` | both | Print each test result as it runs (also forwards stdio stderr) |
128
+
129
+ ### CI integration
130
+
131
+ ```bash
132
+ # GitHub Actions: emits ::error / ::warning annotations inline on the PR
133
+ mcp-compliance test https://my-server.com/mcp --format github --strict
134
+
135
+ # Slack/Linear/PR comment: drop the body straight into a comment
136
+ mcp-compliance test https://my-server.com/mcp --format markdown > report.md
137
+
138
+ # Block release if grade slips below B
139
+ mcp-compliance test https://my-server.com/mcp --min-grade B
140
+
141
+ # Preview which tests will run before connecting (handy for --only/--skip authoring)
142
+ mcp-compliance test --list --transport stdio --skip security
143
+ ```
144
+
145
+ ### Scaffold a config
146
+
147
+ ```bash
148
+ mcp-compliance init
149
+ ```
150
+
151
+ Interactive prompts walk you through transport (http/stdio), command/url, env vars, timeout, and strict mode — then write a `mcp-compliance.config.json` you can commit.
152
+
153
+ ### Config file
154
+
155
+ Check in a `mcp-compliance.config.json` so CI and your dev loop can run `mcp-compliance test` with no arguments. Supported locations (searched in order): `mcp-compliance.config.json`, `.mcp-compliancerc.json`, `.mcp-compliancerc`, and the `"mcp-compliance"` field of `package.json`. Pass `--config <path>` to load an explicit file.
156
+
157
+ **HTTP:**
158
+
159
+ ```json
160
+ {
161
+ "target": {
162
+ "type": "http",
163
+ "url": "https://my-server.com/mcp",
164
+ "headers": { "Authorization": "Bearer tok123" }
165
+ },
166
+ "timeout": 20000,
167
+ "strict": true
168
+ }
169
+ ```
170
+
171
+ **stdio:**
172
+
173
+ ```json
174
+ {
175
+ "target": {
176
+ "type": "stdio",
177
+ "command": "node",
178
+ "args": ["./dist/server.js"],
179
+ "env": { "LOG_LEVEL": "error" }
180
+ },
181
+ "skip": ["security"],
182
+ "strict": true
183
+ }
184
+ ```
185
+
186
+ Precedence: CLI flags > config file > defaults. Any field can be overridden on the command line.
187
+
188
+ ### Publish a shareable badge (HTTP only)
189
+
190
+ ```bash
191
+ mcp-compliance badge https://my-server.com/mcp
192
+ ```
193
+
194
+ Runs the compliance suite, publishes the report to [mcp.hosting](https://mcp.hosting), and prints the markdown embed for your README. The badge image reflects the real grade (A–F) and links to the full report.
195
+
83
196
  | Option | Description |
84
197
  |--------|-------------|
85
- | `--format <format>` | Output format: `terminal`, `json`, or `sarif` (default: `terminal`) |
86
- | `--strict` | Exit with code 1 on any required test failure (for CI) |
87
198
  | `-H, --header <header>` | Add header to all requests, format `"Key: Value"` (repeatable) |
88
199
  | `--auth <token>` | Shorthand for `-H "Authorization: <token>"` |
89
200
  | `--timeout <ms>` | Request timeout in milliseconds (default: `15000`) |
90
- | `--retries <n>` | Number of retries for failed tests (default: `0`) |
91
- | `--only <items>` | Only run tests matching these categories or test IDs (comma-separated) |
92
- | `--skip <items>` | Skip tests matching these categories or test IDs (comma-separated) |
93
- | `--verbose` | Print each test result as it runs |
201
+ | `--no-publish` | Skip publishing; print a local badge markdown only |
202
+ | `--output <file>` | Also write a local SVG badge to the given path |
203
+
204
+ Reports are kept for 90 days from last submission; resubmitting the same URL overwrites the previous report. Auth headers are stripped client-side before upload. Private/loopback URLs (`localhost`, `127.0.0.1`, `192.168.*`, etc.) trigger an interactive confirmation before publishing, and are rejected by the server in any case.
94
205
 
95
- ### Get badge markdown
206
+ A delete token is returned at publish time and stored at `~/.mcp-compliance/tokens.json` (mode `0600`). Use it to take a report down:
96
207
 
97
208
  ```bash
98
- mcp-compliance badge https://my-server.com/mcp
209
+ mcp-compliance unpublish https://my-server.com/mcp
210
+ ```
211
+
212
+ ### Local SVG badge (any transport)
213
+
214
+ Stdio servers can't be published (no public URL to key on), but you can commit a local SVG reflecting the real grade:
215
+
216
+ ```bash
217
+ mcp-compliance test node ./dist/server.js --output badge.svg
218
+ mcp-compliance badge npx -y @modelcontextprotocol/server-filesystem /tmp --output badge.svg
219
+ ```
220
+
221
+ Then embed it in your README:
222
+
223
+ ```markdown
224
+ ![MCP Compliance](./badge.svg)
99
225
  ```
100
226
 
101
- Outputs the markdown embed for a compliance badge hosted at [mcp.hosting](https://mcp.hosting).
227
+ The `test` command never publishes — use it for CI, debugging, and local iteration. `badge` is the only command that publishes to mcp.hosting.
102
228
 
103
- ## What the 81 tests check
229
+ ## What the 84 tests check
104
230
 
105
231
  <details>
106
232
  <summary><strong>Transport (13 tests)</strong></summary>
@@ -321,7 +447,7 @@ Restart your MCP client and approve the server when prompted.
321
447
 
322
448
  ### Tools
323
449
 
324
- - **mcp_compliance_test** — Run the full 81-test suite against a URL. Supports auth, custom headers, timeout, retries, and category/test filtering. Returns grade, score, and detailed results.
450
+ - **mcp_compliance_test** — Run the full 84-test suite against a URL or stdio command. Supports auth, custom headers, env vars, timeout, retries, and category/test filtering. Returns grade, score, and detailed results.
325
451
  - **mcp_compliance_badge** — Get the badge markdown/HTML for a server. Supports auth and custom headers.
326
452
  - **mcp_compliance_explain** — Explain what a specific test ID checks and why it matters.
327
453
 
@@ -348,7 +474,7 @@ const report2 = await runComplianceSuite('https://my-server.com/mcp', {
348
474
 
349
475
  The compliance testing methodology is published as an open specification:
350
476
 
351
- - **[MCP Compliance Testing Specification](./MCP_COMPLIANCE_SPEC.md)** — test execution model, scoring algorithm, all 81 test rules with pass/fail criteria (CC BY 4.0)
477
+ - **[MCP Compliance Testing Specification](./MCP_COMPLIANCE_SPEC.md)** — test execution model, scoring algorithm, all 84 test rules with pass/fail criteria (CC BY 4.0)
352
478
  - **[Machine-readable rule catalog](./mcp-compliance-rules.json)** — JSON Schema-compliant catalog for programmatic consumption
353
479
 
354
480
  These are complementary to (not competing with) the [official MCP specification](https://modelcontextprotocol.io/specification/2025-11-25). The MCP spec defines what servers must do; this spec defines how to verify compliance.