@yawlabs/mcp-compliance 0.1.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 +164 -0
- package/dist/chunk-4AQGMM2X.js +513 -0
- package/dist/index.js +627 -0
- package/dist/mcp/server.d.ts +2 -0
- package/dist/mcp/server.js +128 -0
- package/dist/runner.d.ts +99 -0
- package/dist/runner.js +14 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# @yawlabs/mcp-compliance
|
|
2
|
+
|
|
3
|
+
CLI tool and MCP server that tests MCP servers for spec compliance. Runs a 24-test suite covering transport, lifecycle, tools, resources, prompts, error handling, and schema validation against the [MCP specification](https://modelcontextprotocol.io/specification/2025-11-25).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @yawlabs/mcp-compliance
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run directly with npx:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @yawlabs/mcp-compliance test https://my-server.com/mcp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## CLI Usage
|
|
18
|
+
|
|
19
|
+
### Run compliance tests
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Terminal output with colors and grade
|
|
23
|
+
mcp-compliance test https://my-server.com/mcp
|
|
24
|
+
|
|
25
|
+
# JSON output (for scripting)
|
|
26
|
+
mcp-compliance test https://my-server.com/mcp --format json
|
|
27
|
+
|
|
28
|
+
# Strict mode — exits with code 1 on required test failure (for CI)
|
|
29
|
+
mcp-compliance test https://my-server.com/mcp --strict
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Get badge markdown
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
mcp-compliance badge https://my-server.com/mcp
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Outputs the markdown embed for a compliance badge hosted at [mcp.hosting](https://mcp.hosting).
|
|
39
|
+
|
|
40
|
+
## What the 24 tests check
|
|
41
|
+
|
|
42
|
+
### Transport (2 tests)
|
|
43
|
+
- **transport-post** — Server accepts HTTP POST requests (required)
|
|
44
|
+
- **transport-content-type** — Responds with application/json or text/event-stream (required)
|
|
45
|
+
|
|
46
|
+
### Lifecycle (6 tests)
|
|
47
|
+
- **lifecycle-init** — Initialize handshake succeeds (required)
|
|
48
|
+
- **lifecycle-proto-version** — Returns valid YYYY-MM-DD protocol version (required)
|
|
49
|
+
- **lifecycle-server-info** — Includes serverInfo with name
|
|
50
|
+
- **lifecycle-capabilities** — Returns capabilities object (required)
|
|
51
|
+
- **lifecycle-jsonrpc** — Response is valid JSON-RPC 2.0 (required)
|
|
52
|
+
- **lifecycle-ping** — Responds to ping method (required)
|
|
53
|
+
|
|
54
|
+
### Tools (3 tests)
|
|
55
|
+
- **tools-list** — tools/list returns valid array (required if tools capability declared)
|
|
56
|
+
- **tools-call** — tools/call responds with correct format
|
|
57
|
+
- **tools-call-unknown** — Returns error for nonexistent tool name
|
|
58
|
+
|
|
59
|
+
### Resources (4 tests)
|
|
60
|
+
- **resources-list** — resources/list returns valid array (required if resources capability declared)
|
|
61
|
+
- **resources-read** — resources/read returns content items
|
|
62
|
+
- **resources-templates** — resources/templates/list works or returns method-not-found
|
|
63
|
+
- **resources-schema** — Resources have valid uri and name (required if resources capability declared)
|
|
64
|
+
|
|
65
|
+
### Prompts (3 tests)
|
|
66
|
+
- **prompts-list** — prompts/list returns valid array (required if prompts capability declared)
|
|
67
|
+
- **prompts-schema** — Prompts have name field (required if prompts capability declared)
|
|
68
|
+
- **prompts-get** — prompts/get returns valid messages
|
|
69
|
+
|
|
70
|
+
### Error Handling (4 tests)
|
|
71
|
+
- **error-unknown-method** — Returns JSON-RPC error for unknown method (required)
|
|
72
|
+
- **error-method-code** — Uses correct -32601 error code
|
|
73
|
+
- **error-invalid-jsonrpc** — Handles malformed JSON-RPC (required)
|
|
74
|
+
- **error-invalid-json** — Handles invalid JSON body
|
|
75
|
+
- **error-missing-params** — Returns error for tools/call without name
|
|
76
|
+
|
|
77
|
+
### Schema Validation (2 tests)
|
|
78
|
+
- **tools-schema** — All tools have valid name and inputSchema (required if tools capability declared)
|
|
79
|
+
- **prompts-schema** — Prompts have valid name field (required if prompts capability declared)
|
|
80
|
+
|
|
81
|
+
## Grading
|
|
82
|
+
|
|
83
|
+
| Grade | Score |
|
|
84
|
+
|-------|--------|
|
|
85
|
+
| A | 90-100 |
|
|
86
|
+
| B | 75-89 |
|
|
87
|
+
| C | 60-74 |
|
|
88
|
+
| D | 40-59 |
|
|
89
|
+
| F | 0-39 |
|
|
90
|
+
|
|
91
|
+
Required tests are worth 70% of the score, optional tests 30%.
|
|
92
|
+
|
|
93
|
+
## CI Integration
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
# GitHub Actions example
|
|
97
|
+
- name: MCP Compliance Check
|
|
98
|
+
run: npx @yawlabs/mcp-compliance test ${{ env.MCP_SERVER_URL }} --strict
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```yaml
|
|
102
|
+
# With JSON output for parsing
|
|
103
|
+
- name: MCP Compliance Check
|
|
104
|
+
run: |
|
|
105
|
+
npx @yawlabs/mcp-compliance test ${{ env.MCP_SERVER_URL }} --format json > compliance.json
|
|
106
|
+
cat compliance.json | jq '.grade'
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## MCP Server (for Claude Code)
|
|
110
|
+
|
|
111
|
+
This package also exposes an MCP server with 3 tools that can be used from Claude Code or any MCP client.
|
|
112
|
+
|
|
113
|
+
### Setup
|
|
114
|
+
|
|
115
|
+
Add to your Claude Code MCP config:
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"mcpServers": {
|
|
120
|
+
"mcp-compliance": {
|
|
121
|
+
"command": "npx",
|
|
122
|
+
"args": ["@yawlabs/mcp-compliance-server"]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Or if installed globally:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"mcpServers": {
|
|
133
|
+
"mcp-compliance": {
|
|
134
|
+
"command": "node",
|
|
135
|
+
"args": ["path/to/node_modules/@yawlabs/mcp-compliance/dist/mcp/server.js"]
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Tools
|
|
142
|
+
|
|
143
|
+
- **mcp_compliance_test** — Run the full 24-test suite against a URL. Returns grade, score, and detailed results.
|
|
144
|
+
- **mcp_compliance_badge** — Get the badge markdown/HTML for a server.
|
|
145
|
+
- **mcp_compliance_explain** — Explain what a specific test ID checks and why it matters.
|
|
146
|
+
|
|
147
|
+
## Programmatic Usage
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { runComplianceSuite } from '@yawlabs/mcp-compliance';
|
|
151
|
+
|
|
152
|
+
const report = await runComplianceSuite('https://my-server.com/mcp');
|
|
153
|
+
console.log(`Grade: ${report.grade} (${report.score}%)`);
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Links
|
|
157
|
+
|
|
158
|
+
- [mcp.hosting](https://mcp.hosting) — Hosted MCP server infrastructure
|
|
159
|
+
- [MCP Specification](https://modelcontextprotocol.io/specification/2025-11-25)
|
|
160
|
+
- [Yaw Labs](https://yaw.sh)
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
MIT
|