@yawlabs/mcp-compliance 0.2.1 → 0.4.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/LICENSE +21 -0
- package/README.md +152 -24
- package/dist/chunk-KNOSZ3TD.js +1621 -0
- package/dist/index.js +1495 -687
- package/dist/mcp/server.d.ts +11 -1
- package/dist/mcp/server.js +109 -47
- package/dist/runner.d.ts +5 -4
- package/dist/runner.js +1 -1
- package/package.json +22 -7
- package/dist/chunk-SP24UFRC.js +0 -987
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yaw Labs
|
|
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,22 +1,46 @@
|
|
|
1
1
|
# @yawlabs/mcp-compliance
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@yawlabs/mcp-compliance)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://github.com/YawLabs/mcp-compliance/stargazers)
|
|
6
|
+
[](https://github.com/YawLabs/mcp-compliance/actions/workflows/ci.yml)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
**Test any MCP server for spec compliance.** 43-test suite covering transport, lifecycle, tools, resources, prompts, error handling, and schema validation against the [MCP specification](https://modelcontextprotocol.io/specification/2025-11-25). CLI, MCP server, and programmatic API.
|
|
9
|
+
|
|
10
|
+
Built and maintained by [Yaw Labs](https://yaw.sh).
|
|
11
|
+
|
|
12
|
+
## Why this tool?
|
|
13
|
+
|
|
14
|
+
MCP servers are multiplying fast — but most ship without compliance testing. Broken transport handling, missing error codes, malformed schemas, and silent capability violations are common. Hand-rolling test scripts is tedious and incomplete.
|
|
15
|
+
|
|
16
|
+
This tool solves that:
|
|
17
|
+
|
|
18
|
+
- **43 tests across 7 categories** — transport, lifecycle, tools, resources, prompts, error handling, and schema validation. No gaps.
|
|
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
|
+
- **Graded scoring** — A-F letter grade with a weighted score (required tests 70%, optional 30%). One number to communicate compliance.
|
|
21
|
+
- **CI-ready** — `--strict` mode exits with code 1 on required test failures. Drop it into any pipeline.
|
|
22
|
+
- **Spec-referenced** — every test links to the exact section of the MCP specification it validates. No ambiguity about what's being tested or why.
|
|
23
|
+
- **Three interfaces** — CLI for humans, MCP server for AI assistants, programmatic API for integration.
|
|
24
|
+
- **Published specification** — the [testing methodology](./MCP_COMPLIANCE_SPEC.md) and [rule catalog](./mcp-compliance-rules.json) are open (CC BY 4.0) so anyone can implement compatible tooling.
|
|
25
|
+
|
|
26
|
+
## Quick start
|
|
27
|
+
|
|
28
|
+
**Run against any MCP server:**
|
|
6
29
|
|
|
7
30
|
```bash
|
|
8
|
-
|
|
31
|
+
npx @yawlabs/mcp-compliance test https://my-server.com/mcp
|
|
9
32
|
```
|
|
10
33
|
|
|
11
|
-
Or
|
|
34
|
+
**Or install globally:**
|
|
12
35
|
|
|
13
36
|
```bash
|
|
14
|
-
|
|
37
|
+
npm install -g @yawlabs/mcp-compliance
|
|
38
|
+
mcp-compliance test https://my-server.com/mcp
|
|
15
39
|
```
|
|
16
40
|
|
|
17
|
-
|
|
41
|
+
That's it. You'll get a colored terminal report with a letter grade (A-F), per-test pass/fail, and a compliance score.
|
|
18
42
|
|
|
19
|
-
|
|
43
|
+
## CLI usage
|
|
20
44
|
|
|
21
45
|
```bash
|
|
22
46
|
# Terminal output with colors and grade
|
|
@@ -25,6 +49,9 @@ mcp-compliance test https://my-server.com/mcp
|
|
|
25
49
|
# JSON output (for scripting)
|
|
26
50
|
mcp-compliance test https://my-server.com/mcp --format json
|
|
27
51
|
|
|
52
|
+
# SARIF output (for GitHub Code Scanning)
|
|
53
|
+
mcp-compliance test https://my-server.com/mcp --format sarif > compliance.sarif
|
|
54
|
+
|
|
28
55
|
# Strict mode — exits with code 1 on required test failure (for CI)
|
|
29
56
|
mcp-compliance test https://my-server.com/mcp --strict
|
|
30
57
|
|
|
@@ -55,7 +82,7 @@ mcp-compliance test https://my-server.com/mcp --verbose
|
|
|
55
82
|
|
|
56
83
|
| Option | Description |
|
|
57
84
|
|--------|-------------|
|
|
58
|
-
| `--format <format>` | Output format: `terminal` or `
|
|
85
|
+
| `--format <format>` | Output format: `terminal`, `json`, or `sarif` (default: `terminal`) |
|
|
59
86
|
| `--strict` | Exit with code 1 on any required test failure (for CI) |
|
|
60
87
|
| `-H, --header <header>` | Add header to all requests, format `"Key: Value"` (repeatable) |
|
|
61
88
|
| `--auth <token>` | Shorthand for `-H "Authorization: <token>"` |
|
|
@@ -75,7 +102,9 @@ Outputs the markdown embed for a compliance badge hosted at [mcp.hosting](https:
|
|
|
75
102
|
|
|
76
103
|
## What the 43 tests check
|
|
77
104
|
|
|
78
|
-
|
|
105
|
+
<details>
|
|
106
|
+
<summary><strong>Transport (7 tests)</strong></summary>
|
|
107
|
+
|
|
79
108
|
- **transport-post** — Server accepts HTTP POST requests (required)
|
|
80
109
|
- **transport-content-type** — Responds with application/json or text/event-stream (required)
|
|
81
110
|
- **transport-notification-202** — Notifications return 202 Accepted
|
|
@@ -84,7 +113,11 @@ Outputs the markdown embed for a compliance badge hosted at [mcp.hosting](https:
|
|
|
84
113
|
- **transport-delete** — DELETE accepted or returns 405
|
|
85
114
|
- **transport-batch-reject** — Rejects JSON-RPC batch requests (required)
|
|
86
115
|
|
|
87
|
-
|
|
116
|
+
</details>
|
|
117
|
+
|
|
118
|
+
<details>
|
|
119
|
+
<summary><strong>Lifecycle (10 tests)</strong></summary>
|
|
120
|
+
|
|
88
121
|
- **lifecycle-init** — Initialize handshake succeeds (required)
|
|
89
122
|
- **lifecycle-proto-version** — Returns valid YYYY-MM-DD protocol version (required)
|
|
90
123
|
- **lifecycle-server-info** — Includes serverInfo with name
|
|
@@ -96,25 +129,41 @@ Outputs the markdown embed for a compliance badge hosted at [mcp.hosting](https:
|
|
|
96
129
|
- **lifecycle-logging** — logging/setLevel accepted (required if logging capability declared)
|
|
97
130
|
- **lifecycle-completions** — completion/complete accepted (required if completions capability declared)
|
|
98
131
|
|
|
99
|
-
|
|
132
|
+
</details>
|
|
133
|
+
|
|
134
|
+
<details>
|
|
135
|
+
<summary><strong>Tools (4 tests)</strong></summary>
|
|
136
|
+
|
|
100
137
|
- **tools-list** — tools/list returns valid array (required if tools capability declared)
|
|
101
138
|
- **tools-call** — tools/call responds with correct format
|
|
102
139
|
- **tools-pagination** — tools/list supports cursor-based pagination
|
|
103
140
|
- **tools-content-types** — Tool content items have valid types
|
|
104
141
|
|
|
105
|
-
|
|
142
|
+
</details>
|
|
143
|
+
|
|
144
|
+
<details>
|
|
145
|
+
<summary><strong>Resources (5 tests)</strong></summary>
|
|
146
|
+
|
|
106
147
|
- **resources-list** — resources/list returns valid array (required if resources capability declared)
|
|
107
148
|
- **resources-read** — resources/read returns content items
|
|
108
149
|
- **resources-templates** — resources/templates/list works or returns method-not-found
|
|
109
150
|
- **resources-pagination** — resources/list supports cursor-based pagination
|
|
110
151
|
- **resources-subscribe** — Resource subscribe/unsubscribe (required if subscribe capability declared)
|
|
111
152
|
|
|
112
|
-
|
|
153
|
+
</details>
|
|
154
|
+
|
|
155
|
+
<details>
|
|
156
|
+
<summary><strong>Prompts (3 tests)</strong></summary>
|
|
157
|
+
|
|
113
158
|
- **prompts-list** — prompts/list returns valid array (required if prompts capability declared)
|
|
114
159
|
- **prompts-get** — prompts/get returns valid messages
|
|
115
160
|
- **prompts-pagination** — prompts/list supports cursor-based pagination
|
|
116
161
|
|
|
117
|
-
|
|
162
|
+
</details>
|
|
163
|
+
|
|
164
|
+
<details>
|
|
165
|
+
<summary><strong>Error Handling (8 tests)</strong></summary>
|
|
166
|
+
|
|
118
167
|
- **error-unknown-method** — Returns JSON-RPC error for unknown method (required)
|
|
119
168
|
- **error-method-code** — Uses correct -32601 error code
|
|
120
169
|
- **error-invalid-jsonrpc** — Handles malformed JSON-RPC (required)
|
|
@@ -124,7 +173,11 @@ Outputs the markdown embed for a compliance badge hosted at [mcp.hosting](https:
|
|
|
124
173
|
- **error-invalid-request-code** — Returns -32600 for invalid request
|
|
125
174
|
- **tools-call-unknown** — Returns error for nonexistent tool name
|
|
126
175
|
|
|
127
|
-
|
|
176
|
+
</details>
|
|
177
|
+
|
|
178
|
+
<details>
|
|
179
|
+
<summary><strong>Schema Validation (6 tests)</strong></summary>
|
|
180
|
+
|
|
128
181
|
- **tools-schema** — All tools have valid name and inputSchema (required if tools capability declared)
|
|
129
182
|
- **tools-annotations** — Tool annotations are valid if present
|
|
130
183
|
- **tools-title-field** — Tools include title field (2025-11-25)
|
|
@@ -132,6 +185,8 @@ Outputs the markdown embed for a compliance badge hosted at [mcp.hosting](https:
|
|
|
132
185
|
- **prompts-schema** — Prompts have valid name field (required if prompts capability declared)
|
|
133
186
|
- **resources-schema** — Resources have valid uri and name (required if resources capability declared)
|
|
134
187
|
|
|
188
|
+
</details>
|
|
189
|
+
|
|
135
190
|
## Grading
|
|
136
191
|
|
|
137
192
|
| Grade | Score |
|
|
@@ -142,9 +197,9 @@ Outputs the markdown embed for a compliance badge hosted at [mcp.hosting](https:
|
|
|
142
197
|
| D | 40-59 |
|
|
143
198
|
| F | 0-39 |
|
|
144
199
|
|
|
145
|
-
Required tests are worth 70% of the score, optional tests 30%.
|
|
200
|
+
Required tests are worth 70% of the score, optional tests 30%. See the [full scoring algorithm](./MCP_COMPLIANCE_SPEC.md#2-scoring-algorithm) in the specification.
|
|
146
201
|
|
|
147
|
-
## CI
|
|
202
|
+
## CI integration
|
|
148
203
|
|
|
149
204
|
```yaml
|
|
150
205
|
# GitHub Actions example
|
|
@@ -166,13 +221,31 @@ Required tests are worth 70% of the score, optional tests 30%.
|
|
|
166
221
|
run: npx @yawlabs/mcp-compliance test ${{ env.MCP_SERVER_URL }} --strict --retries 2 --timeout 30000
|
|
167
222
|
```
|
|
168
223
|
|
|
169
|
-
|
|
224
|
+
```yaml
|
|
225
|
+
# SARIF output for GitHub Code Scanning
|
|
226
|
+
- name: MCP Compliance Check
|
|
227
|
+
run: npx @yawlabs/mcp-compliance test ${{ env.MCP_SERVER_URL }} --format sarif > compliance.sarif
|
|
228
|
+
- name: Upload SARIF
|
|
229
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
230
|
+
with:
|
|
231
|
+
sarif_file: compliance.sarif
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## MCP server (for Claude Code, Cursor, etc.)
|
|
170
235
|
|
|
171
|
-
This package also exposes an MCP server with 3 tools that can be used from Claude Code or any MCP client.
|
|
236
|
+
This package also exposes an MCP server with 3 tools that can be used from Claude Code, Cursor, or any MCP client.
|
|
172
237
|
|
|
173
238
|
### Setup
|
|
174
239
|
|
|
175
|
-
|
|
240
|
+
**Claude Code (one-liner):**
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
claude mcp add mcp-compliance -- npx -y @yawlabs/mcp-compliance mcp
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Or create `.mcp.json` in your project root:**
|
|
247
|
+
|
|
248
|
+
macOS / Linux / WSL:
|
|
176
249
|
|
|
177
250
|
```json
|
|
178
251
|
{
|
|
@@ -185,13 +258,32 @@ Add to your Claude Code MCP config:
|
|
|
185
258
|
}
|
|
186
259
|
```
|
|
187
260
|
|
|
261
|
+
Windows:
|
|
262
|
+
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"mcpServers": {
|
|
266
|
+
"mcp-compliance": {
|
|
267
|
+
"command": "cmd",
|
|
268
|
+
"args": ["/c", "npx", "-y", "@yawlabs/mcp-compliance", "mcp"]
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
> **Tip:** This file is safe to commit — it contains no secrets.
|
|
275
|
+
|
|
276
|
+
Restart your MCP client and approve the server when prompted.
|
|
277
|
+
|
|
188
278
|
### Tools
|
|
189
279
|
|
|
190
|
-
- **mcp_compliance_test** — Run the full 43-test suite against a URL. Returns grade, score, and detailed results.
|
|
191
|
-
- **mcp_compliance_badge** — Get the badge markdown/HTML for a server.
|
|
280
|
+
- **mcp_compliance_test** — Run the full 43-test suite against a URL. Supports auth, custom headers, timeout, retries, and category/test filtering. Returns grade, score, and detailed results.
|
|
281
|
+
- **mcp_compliance_badge** — Get the badge markdown/HTML for a server. Supports auth and custom headers.
|
|
192
282
|
- **mcp_compliance_explain** — Explain what a specific test ID checks and why it matters.
|
|
193
283
|
|
|
194
|
-
|
|
284
|
+
All tools have [MCP tool annotations](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#annotations) (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) so MCP clients can skip confirmation dialogs for safe operations.
|
|
285
|
+
|
|
286
|
+
## Programmatic usage
|
|
195
287
|
|
|
196
288
|
```typescript
|
|
197
289
|
import { runComplianceSuite } from '@yawlabs/mcp-compliance';
|
|
@@ -208,12 +300,48 @@ const report2 = await runComplianceSuite('https://my-server.com/mcp', {
|
|
|
208
300
|
});
|
|
209
301
|
```
|
|
210
302
|
|
|
303
|
+
## Specification
|
|
304
|
+
|
|
305
|
+
The compliance testing methodology is published as an open specification:
|
|
306
|
+
|
|
307
|
+
- **[MCP Compliance Testing Specification](./MCP_COMPLIANCE_SPEC.md)** — test execution model, scoring algorithm, all 43 test rules with pass/fail criteria (CC BY 4.0)
|
|
308
|
+
- **[Machine-readable rule catalog](./mcp-compliance-rules.json)** — JSON Schema-compliant catalog for programmatic consumption
|
|
309
|
+
|
|
310
|
+
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.
|
|
311
|
+
|
|
312
|
+
## Requirements
|
|
313
|
+
|
|
314
|
+
- Node.js 18+
|
|
315
|
+
|
|
316
|
+
## Contributing
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
git clone https://github.com/YawLabs/mcp-compliance.git
|
|
320
|
+
cd mcp-compliance
|
|
321
|
+
npm install
|
|
322
|
+
npm run build
|
|
323
|
+
npm test
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**Development commands:**
|
|
327
|
+
|
|
328
|
+
| Command | Description |
|
|
329
|
+
|---------|-------------|
|
|
330
|
+
| `npm run build` | Compile with tsup |
|
|
331
|
+
| `npm run dev` | Watch mode |
|
|
332
|
+
| `npm test` | Run tests (vitest) |
|
|
333
|
+
| `npm run lint` | Check with Biome |
|
|
334
|
+
| `npm run lint:fix` | Auto-fix with Biome |
|
|
335
|
+
| `npm run typecheck` | TypeScript type checking |
|
|
336
|
+
| `npm run test:ci` | Build + test (CI-safe) |
|
|
337
|
+
|
|
211
338
|
## Links
|
|
212
339
|
|
|
213
340
|
- [mcp.hosting](https://mcp.hosting) — Hosted MCP server infrastructure
|
|
214
341
|
- [MCP Specification](https://modelcontextprotocol.io/specification/2025-11-25)
|
|
342
|
+
- [MCP Compliance Testing Spec](./MCP_COMPLIANCE_SPEC.md)
|
|
215
343
|
- [Yaw Labs](https://yaw.sh)
|
|
216
344
|
|
|
217
345
|
## License
|
|
218
346
|
|
|
219
|
-
MIT
|
|
347
|
+
MIT — see [LICENSE](./LICENSE).
|