@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/dist/mcp/server.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Create and configure the MCP compliance server instance.
|
|
5
|
+
*/
|
|
6
|
+
declare function createComplianceServer(): McpServer;
|
|
7
|
+
/**
|
|
8
|
+
* Start the MCP compliance server with stdio transport.
|
|
9
|
+
*/
|
|
10
|
+
declare function startServer(): Promise<void>;
|
|
11
|
+
|
|
12
|
+
export { createComplianceServer, startServer };
|
package/dist/mcp/server.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
SPEC_BASE,
|
|
2
3
|
TEST_DEFINITIONS,
|
|
3
4
|
runComplianceSuite
|
|
4
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-Z7VLPYIO.js";
|
|
5
6
|
|
|
6
7
|
// src/mcp/server.ts
|
|
7
8
|
import { createRequire } from "module";
|
|
@@ -10,10 +11,10 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
10
11
|
|
|
11
12
|
// src/mcp/tools.ts
|
|
12
13
|
import { z } from "zod";
|
|
13
|
-
function registerTools(
|
|
14
|
-
|
|
14
|
+
function registerTools(server) {
|
|
15
|
+
server.tool(
|
|
15
16
|
"mcp_compliance_test",
|
|
16
|
-
"Run the full MCP compliance test suite against a server URL. Returns grade (A-F), score, and detailed results for all
|
|
17
|
+
"Run the full MCP compliance test suite against a server URL. Returns grade (A-F), score, and detailed results for all 48 tests covering transport, lifecycle, tools, resources, prompts, errors, and schema validation.",
|
|
17
18
|
{
|
|
18
19
|
url: z.string().url().describe("The MCP server URL to test (must be HTTP or HTTPS)"),
|
|
19
20
|
auth: z.string().optional().describe('Authorization header value (e.g., "Bearer tok123")'),
|
|
@@ -69,14 +70,15 @@ ${JSON.stringify(report, null, 2)}` }
|
|
|
69
70
|
]
|
|
70
71
|
};
|
|
71
72
|
} catch (err) {
|
|
73
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
72
74
|
return {
|
|
73
|
-
content: [{ type: "text", text: `Error running compliance test: ${
|
|
75
|
+
content: [{ type: "text", text: `Error running compliance test: ${message}` }],
|
|
74
76
|
isError: true
|
|
75
77
|
};
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
);
|
|
79
|
-
|
|
81
|
+
server.tool(
|
|
80
82
|
"mcp_compliance_badge",
|
|
81
83
|
"Get the badge markdown embed code for an MCP server. Runs the compliance test suite first to determine the grade.",
|
|
82
84
|
{
|
|
@@ -118,14 +120,15 @@ ${JSON.stringify(report, null, 2)}` }
|
|
|
118
120
|
]
|
|
119
121
|
};
|
|
120
122
|
} catch (err) {
|
|
123
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
121
124
|
return {
|
|
122
|
-
content: [{ type: "text", text: `Error: ${
|
|
125
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
123
126
|
isError: true
|
|
124
127
|
};
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
130
|
);
|
|
128
|
-
|
|
131
|
+
server.tool(
|
|
129
132
|
"mcp_compliance_explain",
|
|
130
133
|
"Explain what a specific compliance test ID checks and why it matters.",
|
|
131
134
|
{
|
|
@@ -163,9 +166,11 @@ ${TEST_DEFINITIONS.map((t) => t.id).join(", ")}`
|
|
|
163
166
|
`Name: ${def.name}`,
|
|
164
167
|
`Category: ${def.category}`,
|
|
165
168
|
`Required: ${def.required ? "Yes" : "No"}`,
|
|
166
|
-
`Spec reference:
|
|
169
|
+
`Spec reference: ${SPEC_BASE}/${def.specRef}`,
|
|
167
170
|
"",
|
|
168
|
-
def.description
|
|
171
|
+
def.description,
|
|
172
|
+
"",
|
|
173
|
+
`Fix: ${def.recommendation}`
|
|
169
174
|
].join("\n")
|
|
170
175
|
}
|
|
171
176
|
]
|
|
@@ -177,13 +182,24 @@ ${TEST_DEFINITIONS.map((t) => t.id).join(", ")}`
|
|
|
177
182
|
// src/mcp/server.ts
|
|
178
183
|
var require2 = createRequire(import.meta.url);
|
|
179
184
|
var { version } = require2("../../package.json");
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
function createComplianceServer() {
|
|
186
|
+
const server = new McpServer({ name: "mcp-compliance", version });
|
|
187
|
+
registerTools(server);
|
|
188
|
+
return server;
|
|
189
|
+
}
|
|
190
|
+
async function startServer() {
|
|
191
|
+
const server = createComplianceServer();
|
|
183
192
|
const transport = new StdioServerTransport();
|
|
184
193
|
await server.connect(transport);
|
|
185
194
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
195
|
+
var isDirectRun = process.argv[1]?.endsWith("mcp/server.js") || process.argv[1]?.endsWith("mcp\\server.js");
|
|
196
|
+
if (isDirectRun) {
|
|
197
|
+
startServer().catch((err) => {
|
|
198
|
+
console.error("MCP server error:", err);
|
|
199
|
+
process.exit(1);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
export {
|
|
203
|
+
createComplianceServer,
|
|
204
|
+
startServer
|
|
205
|
+
};
|
package/dist/runner.d.ts
CHANGED
|
@@ -58,8 +58,9 @@ interface TestDefinition {
|
|
|
58
58
|
required: boolean;
|
|
59
59
|
specRef: string;
|
|
60
60
|
description: string;
|
|
61
|
+
recommendation: string;
|
|
61
62
|
}
|
|
62
|
-
/** All
|
|
63
|
+
/** All 48 test IDs with descriptions for the explain command */
|
|
63
64
|
declare const TEST_DEFINITIONS: TestDefinition[];
|
|
64
65
|
|
|
65
66
|
declare function computeGrade(score: number): Grade;
|
|
@@ -91,6 +92,16 @@ declare function generateBadge(url: string): {
|
|
|
91
92
|
html: string;
|
|
92
93
|
};
|
|
93
94
|
|
|
95
|
+
declare const SPEC_VERSION = "2025-11-25";
|
|
96
|
+
declare const SPEC_BASE = "https://modelcontextprotocol.io/specification/2025-11-25";
|
|
97
|
+
/**
|
|
98
|
+
* Parse SSE (text/event-stream) response body.
|
|
99
|
+
* Handles multi-line data fields per the SSE specification:
|
|
100
|
+
* consecutive "data:" lines are concatenated with "\n".
|
|
101
|
+
* An empty line marks the end of an event.
|
|
102
|
+
* @internal Exported for testing.
|
|
103
|
+
*/
|
|
104
|
+
declare function parseSSEResponse(text: string): any;
|
|
94
105
|
interface RunOptions {
|
|
95
106
|
/** Optional callback for progress updates */
|
|
96
107
|
onProgress?: (testId: string, passed: boolean, details: string) => void;
|
|
@@ -110,4 +121,4 @@ interface RunOptions {
|
|
|
110
121
|
*/
|
|
111
122
|
declare function runComplianceSuite(url: string, options?: RunOptions): Promise<ComplianceReport>;
|
|
112
123
|
|
|
113
|
-
export { type ComplianceReport, type RunOptions, TEST_DEFINITIONS, type TestResult, computeGrade, computeScore, generateBadge, runComplianceSuite };
|
|
124
|
+
export { type ComplianceReport, type RunOptions, SPEC_BASE, SPEC_VERSION, TEST_DEFINITIONS, type TestResult, computeGrade, computeScore, generateBadge, parseSSEResponse, runComplianceSuite };
|
package/dist/runner.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
+
SPEC_BASE,
|
|
3
|
+
SPEC_VERSION,
|
|
2
4
|
TEST_DEFINITIONS,
|
|
3
5
|
computeGrade,
|
|
4
6
|
computeScore,
|
|
5
7
|
generateBadge,
|
|
8
|
+
parseSSEResponse,
|
|
6
9
|
runComplianceSuite
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-Z7VLPYIO.js";
|
|
8
11
|
export {
|
|
12
|
+
SPEC_BASE,
|
|
13
|
+
SPEC_VERSION,
|
|
9
14
|
TEST_DEFINITIONS,
|
|
10
15
|
computeGrade,
|
|
11
16
|
computeScore,
|
|
12
17
|
generateBadge,
|
|
18
|
+
parseSSEResponse,
|
|
13
19
|
runComplianceSuite
|
|
14
20
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yawlabs/mcp-compliance",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "CLI tool and MCP server that tests MCP servers for spec compliance",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"author": "Yaw Labs (https://yaw.sh)",
|
|
6
|
+
"author": "Yaw Labs <contact@yaw.sh> (https://yaw.sh)",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
21
|
-
"
|
|
21
|
+
"!dist/**/*.test.*",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
22
24
|
],
|
|
23
25
|
"scripts": {
|
|
24
26
|
"build": "tsup",
|
|
@@ -28,7 +30,8 @@
|
|
|
28
30
|
"lint:fix": "biome check --write src/",
|
|
29
31
|
"typecheck": "tsc --noEmit",
|
|
30
32
|
"test:ci": "npm run build && npm test",
|
|
31
|
-
"prepublishOnly": "npm run build"
|
|
33
|
+
"prepublishOnly": "npm run build",
|
|
34
|
+
"start": "node dist/index.js"
|
|
32
35
|
},
|
|
33
36
|
"dependencies": {
|
|
34
37
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
@@ -52,7 +55,12 @@
|
|
|
52
55
|
"model-context-protocol",
|
|
53
56
|
"compliance",
|
|
54
57
|
"testing",
|
|
55
|
-
"cli"
|
|
58
|
+
"cli",
|
|
59
|
+
"mcp-server",
|
|
60
|
+
"spec",
|
|
61
|
+
"validation",
|
|
62
|
+
"json-rpc",
|
|
63
|
+
"ai"
|
|
56
64
|
],
|
|
57
65
|
"repository": {
|
|
58
66
|
"type": "git",
|