@yawlabs/mcp-compliance 0.1.2 → 0.2.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
@@ -1,6 +1,6 @@
1
1
  # @yawlabs/mcp-compliance
2
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).
3
+ CLI tool and MCP server that tests MCP servers for spec compliance. Runs a 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).
4
4
 
5
5
  ## Install
6
6
 
@@ -33,6 +33,22 @@ mcp-compliance test https://my-server.com/mcp --auth "Bearer tok123"
33
33
 
34
34
  # Custom headers (repeatable)
35
35
  mcp-compliance test https://my-server.com/mcp -H "Authorization: Bearer tok123" -H "X-Api-Key: abc"
36
+
37
+ # Custom timeout (default: 15000ms)
38
+ mcp-compliance test https://my-server.com/mcp --timeout 30000
39
+
40
+ # Retry failed tests
41
+ mcp-compliance test https://my-server.com/mcp --retries 2
42
+
43
+ # Only run specific categories or test IDs
44
+ mcp-compliance test https://my-server.com/mcp --only transport,lifecycle
45
+ mcp-compliance test https://my-server.com/mcp --only lifecycle-init,tools-list
46
+
47
+ # Skip specific categories or test IDs
48
+ mcp-compliance test https://my-server.com/mcp --skip prompts,resources
49
+
50
+ # Verbose mode — print each test result as it runs
51
+ mcp-compliance test https://my-server.com/mcp --verbose
36
52
  ```
37
53
 
38
54
  ### Options
@@ -43,6 +59,11 @@ mcp-compliance test https://my-server.com/mcp -H "Authorization: Bearer tok123"
43
59
  | `--strict` | Exit with code 1 on any required test failure (for CI) |
44
60
  | `-H, --header <header>` | Add header to all requests, format `"Key: Value"` (repeatable) |
45
61
  | `--auth <token>` | Shorthand for `-H "Authorization: <token>"` |
62
+ | `--timeout <ms>` | Request timeout in milliseconds (default: `15000`) |
63
+ | `--retries <n>` | Number of retries for failed tests (default: `0`) |
64
+ | `--only <items>` | Only run tests matching these categories or test IDs (comma-separated) |
65
+ | `--skip <items>` | Skip tests matching these categories or test IDs (comma-separated) |
66
+ | `--verbose` | Print each test result as it runs |
46
67
 
47
68
  ### Get badge markdown
48
69
 
@@ -52,46 +73,64 @@ mcp-compliance badge https://my-server.com/mcp
52
73
 
53
74
  Outputs the markdown embed for a compliance badge hosted at [mcp.hosting](https://mcp.hosting).
54
75
 
55
- ## What the 24 tests check
76
+ ## What the 43 tests check
56
77
 
57
- ### Transport (2 tests)
78
+ ### Transport (7 tests)
58
79
  - **transport-post** — Server accepts HTTP POST requests (required)
59
80
  - **transport-content-type** — Responds with application/json or text/event-stream (required)
81
+ - **transport-notification-202** — Notifications return 202 Accepted
82
+ - **transport-session-id** — Enforces MCP-Session-Id after initialization
83
+ - **transport-get** — GET returns SSE stream or 405
84
+ - **transport-delete** — DELETE accepted or returns 405
85
+ - **transport-batch-reject** — Rejects JSON-RPC batch requests (required)
60
86
 
61
- ### Lifecycle (6 tests)
87
+ ### Lifecycle (10 tests)
62
88
  - **lifecycle-init** — Initialize handshake succeeds (required)
63
89
  - **lifecycle-proto-version** — Returns valid YYYY-MM-DD protocol version (required)
64
90
  - **lifecycle-server-info** — Includes serverInfo with name
65
91
  - **lifecycle-capabilities** — Returns capabilities object (required)
66
92
  - **lifecycle-jsonrpc** — Response is valid JSON-RPC 2.0 (required)
67
93
  - **lifecycle-ping** — Responds to ping method (required)
94
+ - **lifecycle-instructions** — Instructions field is valid string if present
95
+ - **lifecycle-id-match** — Response ID matches request ID (required)
96
+ - **lifecycle-logging** — logging/setLevel accepted (required if logging capability declared)
97
+ - **lifecycle-completions** — completion/complete accepted (required if completions capability declared)
68
98
 
69
- ### Tools (3 tests)
99
+ ### Tools (4 tests)
70
100
  - **tools-list** — tools/list returns valid array (required if tools capability declared)
71
101
  - **tools-call** — tools/call responds with correct format
72
- - **tools-call-unknown** — Returns error for nonexistent tool name
102
+ - **tools-pagination** — tools/list supports cursor-based pagination
103
+ - **tools-content-types** — Tool content items have valid types
73
104
 
74
- ### Resources (4 tests)
105
+ ### Resources (5 tests)
75
106
  - **resources-list** — resources/list returns valid array (required if resources capability declared)
76
107
  - **resources-read** — resources/read returns content items
77
108
  - **resources-templates** — resources/templates/list works or returns method-not-found
78
- - **resources-schema** — Resources have valid uri and name (required if resources capability declared)
109
+ - **resources-pagination** — resources/list supports cursor-based pagination
110
+ - **resources-subscribe** — Resource subscribe/unsubscribe (required if subscribe capability declared)
79
111
 
80
112
  ### Prompts (3 tests)
81
113
  - **prompts-list** — prompts/list returns valid array (required if prompts capability declared)
82
- - **prompts-schema** — Prompts have name field (required if prompts capability declared)
83
114
  - **prompts-get** — prompts/get returns valid messages
115
+ - **prompts-pagination** — prompts/list supports cursor-based pagination
84
116
 
85
- ### Error Handling (4 tests)
117
+ ### Error Handling (8 tests)
86
118
  - **error-unknown-method** — Returns JSON-RPC error for unknown method (required)
87
119
  - **error-method-code** — Uses correct -32601 error code
88
120
  - **error-invalid-jsonrpc** — Handles malformed JSON-RPC (required)
89
121
  - **error-invalid-json** — Handles invalid JSON body
90
122
  - **error-missing-params** — Returns error for tools/call without name
123
+ - **error-parse-code** — Returns -32700 for invalid JSON
124
+ - **error-invalid-request-code** — Returns -32600 for invalid request
125
+ - **tools-call-unknown** — Returns error for nonexistent tool name
91
126
 
92
- ### Schema Validation (2 tests)
127
+ ### Schema Validation (6 tests)
93
128
  - **tools-schema** — All tools have valid name and inputSchema (required if tools capability declared)
129
+ - **tools-annotations** — Tool annotations are valid if present
130
+ - **tools-title-field** — Tools include title field (2025-11-25)
131
+ - **tools-output-schema** — Tools with outputSchema are valid (2025-11-25)
94
132
  - **prompts-schema** — Prompts have valid name field (required if prompts capability declared)
133
+ - **resources-schema** — Resources have valid uri and name (required if resources capability declared)
95
134
 
96
135
  ## Grading
97
136
 
@@ -121,6 +160,12 @@ Required tests are worth 70% of the score, optional tests 30%.
121
160
  cat compliance.json | jq '.grade'
122
161
  ```
123
162
 
163
+ ```yaml
164
+ # With retries for flaky network conditions
165
+ - name: MCP Compliance Check
166
+ run: npx @yawlabs/mcp-compliance test ${{ env.MCP_SERVER_URL }} --strict --retries 2 --timeout 30000
167
+ ```
168
+
124
169
  ## MCP Server (for Claude Code)
125
170
 
126
171
  This package also exposes an MCP server with 3 tools that can be used from Claude Code or any MCP client.
@@ -134,22 +179,7 @@ Add to your Claude Code MCP config:
134
179
  "mcpServers": {
135
180
  "mcp-compliance": {
136
181
  "command": "npx",
137
- "args": ["-y", "@yawlabs/mcp-compliance"],
138
- "env": {},
139
- "args_extra": ["mcp"]
140
- }
141
- }
142
- }
143
- ```
144
-
145
- Or run the MCP server directly:
146
-
147
- ```json
148
- {
149
- "mcpServers": {
150
- "mcp-compliance": {
151
- "command": "node",
152
- "args": ["path/to/node_modules/@yawlabs/mcp-compliance/dist/mcp/server.js"]
182
+ "args": ["-y", "@yawlabs/mcp-compliance", "mcp"]
153
183
  }
154
184
  }
155
185
  }
@@ -157,7 +187,7 @@ Or run the MCP server directly:
157
187
 
158
188
  ### Tools
159
189
 
160
- - **mcp_compliance_test** — Run the full 24-test suite against a URL. Returns grade, score, and detailed results.
190
+ - **mcp_compliance_test** — Run the full 43-test suite against a URL. Returns grade, score, and detailed results.
161
191
  - **mcp_compliance_badge** — Get the badge markdown/HTML for a server.
162
192
  - **mcp_compliance_explain** — Explain what a specific test ID checks and why it matters.
163
193
 
@@ -168,6 +198,14 @@ import { runComplianceSuite } from '@yawlabs/mcp-compliance';
168
198
 
169
199
  const report = await runComplianceSuite('https://my-server.com/mcp');
170
200
  console.log(`Grade: ${report.grade} (${report.score}%)`);
201
+
202
+ // With options
203
+ const report2 = await runComplianceSuite('https://my-server.com/mcp', {
204
+ headers: { 'Authorization': 'Bearer tok123' },
205
+ timeout: 30000,
206
+ retries: 1,
207
+ only: ['transport', 'lifecycle'],
208
+ });
171
209
  ```
172
210
 
173
211
  ## Links