mcp-test-kits 0.0.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 +94 -0
- package/dist/capabilities/prompts.d.ts +9 -0
- package/dist/capabilities/prompts.d.ts.map +1 -0
- package/dist/capabilities/prompts.js +76 -0
- package/dist/capabilities/prompts.js.map +1 -0
- package/dist/capabilities/resources.d.ts +9 -0
- package/dist/capabilities/resources.d.ts.map +1 -0
- package/dist/capabilities/resources.js +76 -0
- package/dist/capabilities/resources.js.map +1 -0
- package/dist/capabilities/tools.d.ts +9 -0
- package/dist/capabilities/tools.d.ts.map +1 -0
- package/dist/capabilities/tools.js +77 -0
- package/dist/capabilities/tools.js.map +1 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +30 -0
- package/dist/config.js.map +1 -0
- package/dist/extract-spec.d.ts +14 -0
- package/dist/extract-spec.d.ts.map +1 -0
- package/dist/extract-spec.js +117 -0
- package/dist/extract-spec.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/dist/introspection.d.ts +68 -0
- package/dist/introspection.d.ts.map +1 -0
- package/dist/introspection.js +135 -0
- package/dist/introspection.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +28 -0
- package/dist/server.js.map +1 -0
- package/dist/transports/http.d.ts +10 -0
- package/dist/transports/http.d.ts.map +1 -0
- package/dist/transports/http.js +31 -0
- package/dist/transports/http.js.map +1 -0
- package/dist/transports/index.d.ts +7 -0
- package/dist/transports/index.d.ts.map +1 -0
- package/dist/transports/index.js +7 -0
- package/dist/transports/index.js.map +1 -0
- package/dist/transports/sse.d.ts +10 -0
- package/dist/transports/sse.d.ts.map +1 -0
- package/dist/transports/sse.js +44 -0
- package/dist/transports/sse.js.map +1 -0
- package/dist/transports/stdio.d.ts +10 -0
- package/dist/transports/stdio.d.ts.map +1 -0
- package/dist/transports/stdio.js +14 -0
- package/dist/transports/stdio.js.map +1 -0
- package/eslint.config.js +22 -0
- package/package.json +51 -0
- package/src/capabilities/prompts.ts +108 -0
- package/src/capabilities/resources.ts +108 -0
- package/src/capabilities/tools.ts +124 -0
- package/src/config.ts +60 -0
- package/src/extract-spec.ts +189 -0
- package/src/index.ts +110 -0
- package/src/introspection.ts +216 -0
- package/src/server.ts +34 -0
- package/src/transports/http.ts +42 -0
- package/src/transports/index.ts +7 -0
- package/src/transports/sse.ts +60 -0
- package/src/transports/stdio.ts +21 -0
- package/tests/fixtures.ts +146 -0
- package/tests/http.test.ts +34 -0
- package/tests/sse.test.ts +34 -0
- package/tests/stdio.test.ts +98 -0
- package/tsconfig.json +27 -0
- package/vitest.config.ts +8 -0
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# MCP Test Kits - TypeScript
|
|
2
|
+
|
|
3
|
+
Build from source using the official MCP SDK.
|
|
4
|
+
|
|
5
|
+
## Build
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd typescript
|
|
9
|
+
npm install
|
|
10
|
+
npm run build
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## stdio
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"mcp-test-kits": {
|
|
21
|
+
"command": "node",
|
|
22
|
+
"args": ["dist/index.js"],
|
|
23
|
+
"cwd": "/path/to/mcp-test-kits/typescript"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## HTTP
|
|
32
|
+
|
|
33
|
+
Start server:
|
|
34
|
+
```bash
|
|
35
|
+
node dist/index.js --transport http --port 3000
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
MCP client config:
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"mcp-test-kits": {
|
|
43
|
+
"url": "http://localhost:3000/sse"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## SSE
|
|
52
|
+
|
|
53
|
+
Start server:
|
|
54
|
+
```bash
|
|
55
|
+
node dist/index.js --transport sse --port 3000
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
MCP client config:
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"mcpServers": {
|
|
62
|
+
"mcp-test-kits": {
|
|
63
|
+
"url": "http://localhost:3000/mcp"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Test with MCP Inspector
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# stdio
|
|
75
|
+
npx @modelcontextprotocol/inspector node dist/index.js
|
|
76
|
+
|
|
77
|
+
# HTTP (start server first: node dist/index.js --transport http --port 3000)
|
|
78
|
+
npx @modelcontextprotocol/inspector --transport http --server-url http://localhost:3000/mcp
|
|
79
|
+
|
|
80
|
+
# SSE (start server first: node dist/index.js --transport sse --port 3000)
|
|
81
|
+
npx @modelcontextprotocol/inspector --transport sse --server-url http://localhost:3000/sse
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Development
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm run dev # Run with tsx
|
|
90
|
+
npm run build # Build to dist/
|
|
91
|
+
npm run typecheck # Type check
|
|
92
|
+
npm run lint # Lint code
|
|
93
|
+
npm test # Run tests
|
|
94
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt implementations for MCP Test Kits
|
|
3
|
+
*/
|
|
4
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
/**
|
|
6
|
+
* Register all prompts with the MCP server
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerPrompts(server: McpServer): void;
|
|
9
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/capabilities/prompts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiGvD"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt implementations for MCP Test Kits
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
/**
|
|
6
|
+
* Register all prompts with the MCP server
|
|
7
|
+
*/
|
|
8
|
+
export function registerPrompts(server) {
|
|
9
|
+
// Simple prompt
|
|
10
|
+
server.prompt("simple_prompt", "A basic prompt with no arguments", async () => ({
|
|
11
|
+
messages: [
|
|
12
|
+
{
|
|
13
|
+
role: "user",
|
|
14
|
+
content: {
|
|
15
|
+
type: "text",
|
|
16
|
+
text: "You are a helpful assistant. Please respond concisely and accurately.",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
}));
|
|
21
|
+
// Greeting prompt
|
|
22
|
+
server.prompt("greeting_prompt", "Generate a greeting message", {
|
|
23
|
+
name: z.string().describe("Name of the person to greet"),
|
|
24
|
+
style: z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Greeting style (formal, casual, friendly)"),
|
|
28
|
+
}, async ({ name, style }) => ({
|
|
29
|
+
messages: [
|
|
30
|
+
{
|
|
31
|
+
role: "user",
|
|
32
|
+
content: {
|
|
33
|
+
type: "text",
|
|
34
|
+
text: `Generate a ${style ?? "friendly"} greeting for ${name}.`,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
}));
|
|
39
|
+
// Template prompt
|
|
40
|
+
server.prompt("template_prompt", "A template with multiple arguments", {
|
|
41
|
+
topic: z.string().describe("Main topic"),
|
|
42
|
+
context: z.string().optional().describe("Additional context"),
|
|
43
|
+
length: z
|
|
44
|
+
.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("Desired length (short, medium, long)"),
|
|
47
|
+
}, async ({ topic, context, length, }) => {
|
|
48
|
+
let text = `Write a ${length ?? "medium"} explanation about ${topic}.`;
|
|
49
|
+
if (context) {
|
|
50
|
+
text += ` Context: ${context}`;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
messages: [
|
|
54
|
+
{
|
|
55
|
+
role: "user",
|
|
56
|
+
content: { type: "text", text },
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
// Multi-message prompt
|
|
62
|
+
server.prompt("multi_message_prompt", "Prompt that returns multiple messages", {
|
|
63
|
+
count: z.string().describe("Number of messages to generate"),
|
|
64
|
+
}, async ({ count }) => {
|
|
65
|
+
const numMessages = Math.max(1, Math.min(parseInt(count, 10) || 1, 10));
|
|
66
|
+
const messages = Array.from({ length: numMessages }, (_, i) => ({
|
|
67
|
+
role: "user",
|
|
68
|
+
content: {
|
|
69
|
+
type: "text",
|
|
70
|
+
text: `Message ${i + 1} of ${numMessages}: Generate a helpful response.`,
|
|
71
|
+
},
|
|
72
|
+
}));
|
|
73
|
+
return { messages };
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/capabilities/prompts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,CAAC,EAAE,MAA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|
+
* Register all resources with the MCP server
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerResources(server: McpServer): void;
|
|
9
|
+
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/capabilities/resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAczE;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAsFzD"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource implementations for MCP Test Kits
|
|
3
|
+
*/
|
|
4
|
+
// Large text content for testing
|
|
5
|
+
const LARGE_TEXT_CONTENT = `
|
|
6
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
|
|
7
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
|
8
|
+
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
9
|
+
|
|
10
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
|
11
|
+
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
12
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
13
|
+
|
|
14
|
+
`.repeat(100);
|
|
15
|
+
/**
|
|
16
|
+
* Register all resources with the MCP server
|
|
17
|
+
*/
|
|
18
|
+
export function registerResources(server) {
|
|
19
|
+
// Static greeting resource
|
|
20
|
+
server.registerResource("static-greeting", "test://static/greeting", { title: "Static Greeting", mimeType: "text/plain" }, async () => ({
|
|
21
|
+
contents: [
|
|
22
|
+
{
|
|
23
|
+
uri: "test://static/greeting",
|
|
24
|
+
mimeType: "text/plain",
|
|
25
|
+
text: "Hello from mcp-test-kits!",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
}));
|
|
29
|
+
// Static numbers resource
|
|
30
|
+
server.registerResource("static-numbers", "test://static/numbers", { title: "Number List", mimeType: "application/json" }, async () => ({
|
|
31
|
+
contents: [
|
|
32
|
+
{
|
|
33
|
+
uri: "test://static/numbers",
|
|
34
|
+
mimeType: "application/json",
|
|
35
|
+
text: JSON.stringify({ numbers: [1, 2, 3, 4, 5] }),
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
}));
|
|
39
|
+
// Dynamic timestamp resource
|
|
40
|
+
server.registerResource("dynamic-timestamp", "test://dynamic/timestamp", { title: "Current Timestamp", mimeType: "application/json" }, async () => {
|
|
41
|
+
const now = new Date();
|
|
42
|
+
return {
|
|
43
|
+
contents: [
|
|
44
|
+
{
|
|
45
|
+
uri: "test://dynamic/timestamp",
|
|
46
|
+
mimeType: "application/json",
|
|
47
|
+
text: JSON.stringify({
|
|
48
|
+
timestamp: now.toISOString(),
|
|
49
|
+
unix: Math.floor(now.getTime() / 1000),
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
// Dynamic random resource
|
|
56
|
+
server.registerResource("dynamic-random", "test://dynamic/random", { title: "Random Number", mimeType: "application/json" }, async () => ({
|
|
57
|
+
contents: [
|
|
58
|
+
{
|
|
59
|
+
uri: "test://dynamic/random",
|
|
60
|
+
mimeType: "application/json",
|
|
61
|
+
text: JSON.stringify({ random: Math.floor(Math.random() * 101) }),
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
}));
|
|
65
|
+
// Large text resource
|
|
66
|
+
server.registerResource("large-text", "test://large-text", { title: "Large Text Resource", mimeType: "text/plain" }, async () => ({
|
|
67
|
+
contents: [
|
|
68
|
+
{
|
|
69
|
+
uri: "test://large-text",
|
|
70
|
+
mimeType: "text/plain",
|
|
71
|
+
text: LARGE_TEXT_CONTENT,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/capabilities/resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,iCAAiC;AACjC,MAAM,kBAAkB,GAAG;;;;;;;;;CAS1B,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAEd;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IACjD,2BAA2B;IAC3B,MAAM,CAAC,gBAAgB,CACrB,iBAAiB,EACjB,wBAAwB,EACxB,EAAE,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,EACpD,KAAK,IAAI,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,wBAAwB;gBAC7B,QAAQ,EAAE,YAAY;gBACtB,IAAI,EAAE,2BAA2B;aAClC;SACF;KACF,CAAC,CACH,CAAC;IAEF,0BAA0B;IAC1B,MAAM,CAAC,gBAAgB,CACrB,gBAAgB,EAChB,uBAAuB,EACvB,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EACtD,KAAK,IAAI,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,uBAAuB;gBAC5B,QAAQ,EAAE,kBAAkB;gBAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;aACnD;SACF;KACF,CAAC,CACH,CAAC;IAEF,6BAA6B;IAC7B,MAAM,CAAC,gBAAgB,CACrB,mBAAmB,EACnB,0BAA0B,EAC1B,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EAC5D,KAAK,IAAI,EAAE;QACT,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,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Register all tools with the MCP server
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerTools(server: McpServer): void;
|
|
9
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/capabilities/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiHrD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool implementations for MCP Test Kits
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
/**
|
|
6
|
+
* Register all tools with the MCP server
|
|
7
|
+
*/
|
|
8
|
+
export function registerTools(server) {
|
|
9
|
+
// echo tool
|
|
10
|
+
server.tool("echo", "Returns the input message unchanged", { message: z.string().describe("The message to echo") }, async ({ message }) => ({
|
|
11
|
+
content: [{ type: "text", text: message }],
|
|
12
|
+
}));
|
|
13
|
+
// add tool
|
|
14
|
+
server.tool("add", "Adds two numbers together", {
|
|
15
|
+
a: z.number().describe("First number"),
|
|
16
|
+
b: z.number().describe("Second number"),
|
|
17
|
+
}, async ({ a, b }) => ({
|
|
18
|
+
content: [{ type: "text", text: String(a + b) }],
|
|
19
|
+
}));
|
|
20
|
+
// multiply tool
|
|
21
|
+
server.tool("multiply", "Multiplies two numbers", {
|
|
22
|
+
x: z.number().describe("First number"),
|
|
23
|
+
y: z.number().describe("Second number"),
|
|
24
|
+
}, async ({ x, y }) => ({
|
|
25
|
+
content: [{ type: "text", text: String(x * y) }],
|
|
26
|
+
}));
|
|
27
|
+
// reverse_string tool
|
|
28
|
+
server.tool("reverse_string", "Reverses a string", { text: z.string().describe("Text to reverse") }, async ({ text }) => ({
|
|
29
|
+
content: [{ type: "text", text: text.split("").reverse().join("") }],
|
|
30
|
+
}));
|
|
31
|
+
// generate_uuid tool
|
|
32
|
+
server.tool("generate_uuid", "Generates a random UUID", {}, async () => ({
|
|
33
|
+
content: [{ type: "text", text: crypto.randomUUID() }],
|
|
34
|
+
}));
|
|
35
|
+
// get_timestamp tool
|
|
36
|
+
server.tool("get_timestamp", "Returns the current timestamp", {
|
|
37
|
+
format: z
|
|
38
|
+
.enum(["unix", "iso"])
|
|
39
|
+
.default("iso")
|
|
40
|
+
.describe("Format: 'unix' or 'iso'"),
|
|
41
|
+
}, async ({ format }) => {
|
|
42
|
+
const now = new Date();
|
|
43
|
+
const result = format === "unix"
|
|
44
|
+
? String(Math.floor(now.getTime() / 1000))
|
|
45
|
+
: now.toISOString();
|
|
46
|
+
return { content: [{ type: "text", text: result }] };
|
|
47
|
+
});
|
|
48
|
+
// sample_error tool
|
|
49
|
+
server.tool("sample_error", "Always throws an error (for testing error handling)", {
|
|
50
|
+
error_message: z
|
|
51
|
+
.string()
|
|
52
|
+
.default("This is a test error")
|
|
53
|
+
.describe("Custom error message"),
|
|
54
|
+
}, async ({ error_message }) => {
|
|
55
|
+
throw new Error(error_message);
|
|
56
|
+
});
|
|
57
|
+
// long_running_task tool
|
|
58
|
+
server.tool("long_running_task", "Simulates a long-running operation", {
|
|
59
|
+
duration: z
|
|
60
|
+
.number()
|
|
61
|
+
.min(0)
|
|
62
|
+
.max(10)
|
|
63
|
+
.describe("Duration in seconds (max 10)"),
|
|
64
|
+
}, async ({ duration }) => {
|
|
65
|
+
const actualDuration = Math.min(Math.max(duration, 0), 10);
|
|
66
|
+
await new Promise((resolve) => setTimeout(resolve, actualDuration * 1000));
|
|
67
|
+
return {
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: "text",
|
|
71
|
+
text: `Task completed after ${actualDuration} seconds`,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=tools.js.map
|
|
@@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* Configuration types for MCP Test Kits
|
|
3
|
+
*/
|
|
4
|
+
export interface ServerConfig {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
}
|
|
8
|
+
export interface NetworkConfig {
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
}
|
|
12
|
+
export interface TransportConfig {
|
|
13
|
+
type: "stdio" | "http" | "sse";
|
|
14
|
+
network: NetworkConfig;
|
|
15
|
+
}
|
|
16
|
+
export interface CapabilitiesConfig {
|
|
17
|
+
tools: boolean;
|
|
18
|
+
resources: boolean;
|
|
19
|
+
prompts: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ConfigOptions {
|
|
22
|
+
server: ServerConfig;
|
|
23
|
+
transport: TransportConfig;
|
|
24
|
+
capabilities: CapabilitiesConfig;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Configuration class with default values
|
|
28
|
+
*/
|
|
29
|
+
export declare class Config implements ConfigOptions {
|
|
30
|
+
server: ServerConfig;
|
|
31
|
+
transport: TransportConfig;
|
|
32
|
+
capabilities: CapabilitiesConfig;
|
|
33
|
+
constructor(options?: Partial<ConfigOptions>);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;IAC/B,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,eAAe,CAAC;IAC3B,YAAY,EAAE,kBAAkB,CAAC;CAClC;AAED;;GAEG;AACH,qBAAa,MAAO,YAAW,aAAa;IAC1C,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,eAAe,CAAC;IAC3B,YAAY,EAAE,kBAAkB,CAAC;gBAErB,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC;CAoB7C"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for MCP Test Kits
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Configuration class with default values
|
|
6
|
+
*/
|
|
7
|
+
export class Config {
|
|
8
|
+
server;
|
|
9
|
+
transport;
|
|
10
|
+
capabilities;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.server = {
|
|
13
|
+
name: options?.server?.name ?? "mcp-test-kits",
|
|
14
|
+
version: options?.server?.version ?? "1.0.0",
|
|
15
|
+
};
|
|
16
|
+
this.transport = {
|
|
17
|
+
type: options?.transport?.type ?? "stdio",
|
|
18
|
+
network: {
|
|
19
|
+
host: options?.transport?.network?.host ?? "127.0.0.1",
|
|
20
|
+
port: options?.transport?.network?.port ?? 3000,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
this.capabilities = {
|
|
24
|
+
tools: options?.capabilities?.tools ?? true,
|
|
25
|
+
resources: options?.capabilities?.resources ?? true,
|
|
26
|
+
prompts: options?.capabilities?.prompts ?? true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6BH;;GAEG;AACH,MAAM,OAAO,MAAM;IACjB,MAAM,CAAe;IACrB,SAAS,CAAkB;IAC3B,YAAY,CAAqB;IAEjC,YAAY,OAAgC;QAC1C,IAAI,CAAC,MAAM,GAAG;YACZ,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,IAAI,eAAe;YAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,OAAO;SAC7C,CAAC;QAEF,IAAI,CAAC,SAAS,GAAG;YACf,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,OAAO;YACzC,OAAO,EAAE;gBACP,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,IAAI,WAAW;gBACtD,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,IAAI,IAAI;aAChD;SACF,CAAC;QAEF,IAAI,CAAC,YAAY,GAAG;YAClB,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,IAAI,IAAI;YAC3C,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,IAAI,IAAI;YACnD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,IAAI,IAAI;SAChD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Extract specification from MCP Test Kits server.
|
|
4
|
+
*
|
|
5
|
+
* This script extracts the tools, resources, and prompts specification
|
|
6
|
+
* from the TypeScript implementation and outputs JSON that can be compared
|
|
7
|
+
* against the shared specification.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* node dist/extract-spec.js > extracted_spec.json
|
|
11
|
+
* node dist/extract-spec.js --compare
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=extract-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-spec.d.ts","sourceRoot":"","sources":["../src/extract-spec.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Extract specification from MCP Test Kits server.
|
|
4
|
+
*
|
|
5
|
+
* This script extracts the tools, resources, and prompts specification
|
|
6
|
+
* from the TypeScript implementation and outputs JSON that can be compared
|
|
7
|
+
* against the shared specification.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* node dist/extract-spec.js > extracted_spec.json
|
|
11
|
+
* node dist/extract-spec.js --compare
|
|
12
|
+
*/
|
|
13
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
14
|
+
import { join, dirname } from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import { parseArgs } from "node:util";
|
|
17
|
+
import { Config } from "./config.js";
|
|
18
|
+
import { createServer } from "./server.js";
|
|
19
|
+
import { extractSpec } from "./introspection.js";
|
|
20
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
/**
|
|
22
|
+
* Load shared specification from JSON files
|
|
23
|
+
*/
|
|
24
|
+
function loadSharedSpec() {
|
|
25
|
+
// Navigate from dist/ to project root, then to shared/
|
|
26
|
+
const projectRoot = join(__dirname, "..", "..");
|
|
27
|
+
const sharedDir = join(projectRoot, "shared", "test-data");
|
|
28
|
+
const tools = [];
|
|
29
|
+
const resources = [];
|
|
30
|
+
const prompts = [];
|
|
31
|
+
const toolsFile = join(sharedDir, "tools.json");
|
|
32
|
+
if (existsSync(toolsFile)) {
|
|
33
|
+
const data = JSON.parse(readFileSync(toolsFile, "utf-8"));
|
|
34
|
+
tools.push(...(data.tools || []));
|
|
35
|
+
}
|
|
36
|
+
const resourcesFile = join(sharedDir, "resources.json");
|
|
37
|
+
if (existsSync(resourcesFile)) {
|
|
38
|
+
const data = JSON.parse(readFileSync(resourcesFile, "utf-8"));
|
|
39
|
+
resources.push(...(data.resources || []));
|
|
40
|
+
}
|
|
41
|
+
const promptsFile = join(sharedDir, "prompts.json");
|
|
42
|
+
if (existsSync(promptsFile)) {
|
|
43
|
+
const data = JSON.parse(readFileSync(promptsFile, "utf-8"));
|
|
44
|
+
prompts.push(...(data.prompts || []));
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
tools: tools.sort((a, b) => a.name.localeCompare(b.name)),
|
|
48
|
+
resources: resources.sort((a, b) => a.uri.localeCompare(b.uri)),
|
|
49
|
+
prompts: prompts.sort((a, b) => a.name.localeCompare(b.name)),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Compare extracted spec against shared spec
|
|
54
|
+
*/
|
|
55
|
+
function compareSpecs(extracted, shared) {
|
|
56
|
+
const results = {
|
|
57
|
+
tools: { match: true, missing: [], extra: [] },
|
|
58
|
+
resources: { match: true, missing: [], extra: [] },
|
|
59
|
+
prompts: { match: true, missing: [], extra: [] },
|
|
60
|
+
};
|
|
61
|
+
// Compare tools by name
|
|
62
|
+
const extractedToolNames = new Set(extracted.tools.map((t) => t.name));
|
|
63
|
+
const sharedToolNames = new Set(shared.tools.map((t) => t.name));
|
|
64
|
+
results.tools.missing = [...sharedToolNames].filter((n) => !extractedToolNames.has(n));
|
|
65
|
+
results.tools.extra = [...extractedToolNames].filter((n) => !sharedToolNames.has(n));
|
|
66
|
+
results.tools.match =
|
|
67
|
+
results.tools.missing.length === 0 && results.tools.extra.length === 0;
|
|
68
|
+
// Compare resources by URI
|
|
69
|
+
const extractedResourceUris = new Set(extracted.resources.map((r) => r.uri));
|
|
70
|
+
const sharedResourceUris = new Set(shared.resources.map((r) => r.uri));
|
|
71
|
+
results.resources.missing = [...sharedResourceUris].filter((u) => !extractedResourceUris.has(u));
|
|
72
|
+
results.resources.extra = [...extractedResourceUris].filter((u) => !sharedResourceUris.has(u));
|
|
73
|
+
results.resources.match =
|
|
74
|
+
results.resources.missing.length === 0 &&
|
|
75
|
+
results.resources.extra.length === 0;
|
|
76
|
+
// Compare prompts by name
|
|
77
|
+
const extractedPromptNames = new Set(extracted.prompts.map((p) => p.name));
|
|
78
|
+
const sharedPromptNames = new Set(shared.prompts.map((p) => p.name));
|
|
79
|
+
results.prompts.missing = [...sharedPromptNames].filter((n) => !extractedPromptNames.has(n));
|
|
80
|
+
results.prompts.extra = [...extractedPromptNames].filter((n) => !sharedPromptNames.has(n));
|
|
81
|
+
results.prompts.match =
|
|
82
|
+
results.prompts.missing.length === 0 && results.prompts.extra.length === 0;
|
|
83
|
+
return results;
|
|
84
|
+
}
|
|
85
|
+
async function main() {
|
|
86
|
+
const { values } = parseArgs({
|
|
87
|
+
options: {
|
|
88
|
+
compare: { type: "boolean" },
|
|
89
|
+
output: { type: "string", short: "o" },
|
|
90
|
+
},
|
|
91
|
+
allowPositionals: true,
|
|
92
|
+
});
|
|
93
|
+
// Create server instance with default config
|
|
94
|
+
const config = new Config();
|
|
95
|
+
const server = createServer(config);
|
|
96
|
+
// Extract specifications automatically via introspection
|
|
97
|
+
const extracted = extractSpec(server);
|
|
98
|
+
if (values.compare) {
|
|
99
|
+
const shared = loadSharedSpec();
|
|
100
|
+
const results = compareSpecs(extracted, shared);
|
|
101
|
+
const allMatch = results.tools.match && results.resources.match && results.prompts.match;
|
|
102
|
+
const output = {
|
|
103
|
+
status: allMatch ? "pass" : "fail",
|
|
104
|
+
comparison: results,
|
|
105
|
+
};
|
|
106
|
+
console.log(JSON.stringify(output, null, 2));
|
|
107
|
+
process.exit(allMatch ? 0 : 1);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
console.log(JSON.stringify(extracted, null, 2));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
main().catch((error) => {
|
|
114
|
+
console.error("Error:", error);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=extract-spec.js.map
|
|
@@ -0,0 +1 @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