@yawlabs/mcp-compliance 0.3.0 → 0.5.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 +78 -13
- package/dist/{chunk-U66YZGE5.js → chunk-Z7VLPYIO.js} +429 -105
- package/dist/index.js +582 -134
- package/dist/mcp/server.d.ts +11 -1
- package/dist/mcp/server.js +33 -17
- package/dist/runner.d.ts +13 -2
- package/dist/runner.js +7 -1
- package/package.json +13 -5
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
|
@@ -7,17 +7,31 @@
|
|
|
7
7
|
|
|
8
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
9
|
|
|
10
|
-
Built and maintained by [
|
|
10
|
+
Built and maintained by [Yaw Labs](https://yaw.sh).
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Why this tool?
|
|
13
13
|
|
|
14
|
-
|
|
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
|
+
- **48 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:**
|
|
15
29
|
|
|
16
30
|
```bash
|
|
17
31
|
npx @yawlabs/mcp-compliance test https://my-server.com/mcp
|
|
18
32
|
```
|
|
19
33
|
|
|
20
|
-
**
|
|
34
|
+
**Or install globally:**
|
|
21
35
|
|
|
22
36
|
```bash
|
|
23
37
|
npm install -g @yawlabs/mcp-compliance
|
|
@@ -26,7 +40,7 @@ mcp-compliance test https://my-server.com/mcp
|
|
|
26
40
|
|
|
27
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.
|
|
28
42
|
|
|
29
|
-
## CLI
|
|
43
|
+
## CLI usage
|
|
30
44
|
|
|
31
45
|
```bash
|
|
32
46
|
# Terminal output with colors and grade
|
|
@@ -35,6 +49,9 @@ mcp-compliance test https://my-server.com/mcp
|
|
|
35
49
|
# JSON output (for scripting)
|
|
36
50
|
mcp-compliance test https://my-server.com/mcp --format json
|
|
37
51
|
|
|
52
|
+
# SARIF output (for GitHub Code Scanning)
|
|
53
|
+
mcp-compliance test https://my-server.com/mcp --format sarif > compliance.sarif
|
|
54
|
+
|
|
38
55
|
# Strict mode — exits with code 1 on required test failure (for CI)
|
|
39
56
|
mcp-compliance test https://my-server.com/mcp --strict
|
|
40
57
|
|
|
@@ -65,7 +82,7 @@ mcp-compliance test https://my-server.com/mcp --verbose
|
|
|
65
82
|
|
|
66
83
|
| Option | Description |
|
|
67
84
|
|--------|-------------|
|
|
68
|
-
| `--format <format>` | Output format: `terminal` or `
|
|
85
|
+
| `--format <format>` | Output format: `terminal`, `json`, or `sarif` (default: `terminal`) |
|
|
69
86
|
| `--strict` | Exit with code 1 on any required test failure (for CI) |
|
|
70
87
|
| `-H, --header <header>` | Add header to all requests, format `"Key: Value"` (repeatable) |
|
|
71
88
|
| `--auth <token>` | Shorthand for `-H "Authorization: <token>"` |
|
|
@@ -83,7 +100,7 @@ mcp-compliance badge https://my-server.com/mcp
|
|
|
83
100
|
|
|
84
101
|
Outputs the markdown embed for a compliance badge hosted at [mcp.hosting](https://mcp.hosting).
|
|
85
102
|
|
|
86
|
-
## What the
|
|
103
|
+
## What the 48 tests check
|
|
87
104
|
|
|
88
105
|
<details>
|
|
89
106
|
<summary><strong>Transport (7 tests)</strong></summary>
|
|
@@ -180,9 +197,9 @@ Outputs the markdown embed for a compliance badge hosted at [mcp.hosting](https:
|
|
|
180
197
|
| D | 40-59 |
|
|
181
198
|
| F | 0-39 |
|
|
182
199
|
|
|
183
|
-
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.
|
|
184
201
|
|
|
185
|
-
## CI
|
|
202
|
+
## CI integration
|
|
186
203
|
|
|
187
204
|
```yaml
|
|
188
205
|
# GitHub Actions example
|
|
@@ -204,13 +221,29 @@ Required tests are worth 70% of the score, optional tests 30%.
|
|
|
204
221
|
run: npx @yawlabs/mcp-compliance test ${{ env.MCP_SERVER_URL }} --strict --retries 2 --timeout 30000
|
|
205
222
|
```
|
|
206
223
|
|
|
207
|
-
|
|
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.)
|
|
208
235
|
|
|
209
236
|
This package also exposes an MCP server with 3 tools that can be used from Claude Code, Cursor, or any MCP client.
|
|
210
237
|
|
|
211
238
|
### Setup
|
|
212
239
|
|
|
213
|
-
|
|
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:**
|
|
214
247
|
|
|
215
248
|
macOS / Linux / WSL:
|
|
216
249
|
|
|
@@ -250,7 +283,7 @@ Restart your MCP client and approve the server when prompted.
|
|
|
250
283
|
|
|
251
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.
|
|
252
285
|
|
|
253
|
-
## Programmatic
|
|
286
|
+
## Programmatic usage
|
|
254
287
|
|
|
255
288
|
```typescript
|
|
256
289
|
import { runComplianceSuite } from '@yawlabs/mcp-compliance';
|
|
@@ -267,16 +300,48 @@ const report2 = await runComplianceSuite('https://my-server.com/mcp', {
|
|
|
267
300
|
});
|
|
268
301
|
```
|
|
269
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
|
+
|
|
270
312
|
## Requirements
|
|
271
313
|
|
|
272
314
|
- Node.js 18+
|
|
273
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
|
+
|
|
274
338
|
## Links
|
|
275
339
|
|
|
276
340
|
- [mcp.hosting](https://mcp.hosting) — Hosted MCP server infrastructure
|
|
277
341
|
- [MCP Specification](https://modelcontextprotocol.io/specification/2025-11-25)
|
|
342
|
+
- [MCP Compliance Testing Spec](./MCP_COMPLIANCE_SPEC.md)
|
|
278
343
|
- [Yaw Labs](https://yaw.sh)
|
|
279
344
|
|
|
280
345
|
## License
|
|
281
346
|
|
|
282
|
-
MIT
|
|
347
|
+
MIT — see [LICENSE](./LICENSE).
|