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/dist/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Entry point for MCP Test Kits server (TypeScript)
|
|
4
|
+
*/
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
6
|
+
import { Config } from "./config.js";
|
|
7
|
+
import { createServer } from "./server.js";
|
|
8
|
+
import { runStdioServer, runHttpServer, runSseServer, } from "./transports/index.js";
|
|
9
|
+
function printHelp() {
|
|
10
|
+
console.log(`
|
|
11
|
+
MCP Test Kits - A comprehensive MCP testing server
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
mcp-test-kits [options]
|
|
15
|
+
|
|
16
|
+
Options:
|
|
17
|
+
-t, --transport <type> Transport type: stdio, http, sse (default: stdio)
|
|
18
|
+
--host <host> Host to bind to (default: localhost)
|
|
19
|
+
-p, --port <port> Port to listen on (default: 3000)
|
|
20
|
+
-l, --log-level <level> Log level: debug, info, warn, error (default: info)
|
|
21
|
+
--no-tools Disable tools capability
|
|
22
|
+
--no-resources Disable resources capability
|
|
23
|
+
--no-prompts Disable prompts capability
|
|
24
|
+
-v, --version Show version
|
|
25
|
+
-h, --help Show this help
|
|
26
|
+
|
|
27
|
+
Examples:
|
|
28
|
+
# Run with stdio (default)
|
|
29
|
+
mcp-test-kits
|
|
30
|
+
|
|
31
|
+
# Run with HTTP transport
|
|
32
|
+
mcp-test-kits --transport http --port 3000
|
|
33
|
+
|
|
34
|
+
# Run with only tools (no resources or prompts)
|
|
35
|
+
mcp-test-kits --no-resources --no-prompts
|
|
36
|
+
`);
|
|
37
|
+
}
|
|
38
|
+
async function main() {
|
|
39
|
+
// Parse command line arguments
|
|
40
|
+
const { values } = parseArgs({
|
|
41
|
+
options: {
|
|
42
|
+
transport: { type: "string", short: "t", default: "stdio" },
|
|
43
|
+
host: { type: "string", default: "localhost" },
|
|
44
|
+
port: { type: "string", short: "p", default: "3000" },
|
|
45
|
+
"log-level": { type: "string", short: "l", default: "info" },
|
|
46
|
+
"no-tools": { type: "boolean", default: false },
|
|
47
|
+
"no-resources": { type: "boolean", default: false },
|
|
48
|
+
"no-prompts": { type: "boolean", default: false },
|
|
49
|
+
version: { type: "boolean", short: "v" },
|
|
50
|
+
help: { type: "boolean", short: "h" },
|
|
51
|
+
},
|
|
52
|
+
allowPositionals: true,
|
|
53
|
+
});
|
|
54
|
+
if (values.help) {
|
|
55
|
+
printHelp();
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
if (values.version) {
|
|
59
|
+
console.log("mcp-test-kits 1.0.0");
|
|
60
|
+
process.exit(0);
|
|
61
|
+
}
|
|
62
|
+
// Build config from CLI args
|
|
63
|
+
const transport = values.transport;
|
|
64
|
+
const host = values.host;
|
|
65
|
+
const port = parseInt(values.port, 10);
|
|
66
|
+
const config = new Config({
|
|
67
|
+
server: { name: "mcp-test-kits", version: "1.0.0" },
|
|
68
|
+
transport: { type: transport, network: { host, port } },
|
|
69
|
+
capabilities: {
|
|
70
|
+
tools: !values["no-tools"],
|
|
71
|
+
resources: !values["no-resources"],
|
|
72
|
+
prompts: !values["no-prompts"],
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
// Create server
|
|
76
|
+
const server = createServer(config);
|
|
77
|
+
// Run with appropriate transport
|
|
78
|
+
switch (transport) {
|
|
79
|
+
case "stdio":
|
|
80
|
+
await runStdioServer(server, config);
|
|
81
|
+
break;
|
|
82
|
+
case "http":
|
|
83
|
+
await runHttpServer(server, config);
|
|
84
|
+
break;
|
|
85
|
+
case "sse":
|
|
86
|
+
await runSseServer(server, config);
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
console.error(`Unknown transport type: ${transport}`);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
main().catch((error) => {
|
|
94
|
+
console.error("Fatal error:", error);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,aAAa,EACb,YAAY,GACb,MAAM,uBAAuB,CAAC;AAE/B,SAAS,SAAS;IAChB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Bb,CAAC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,+BAA+B;IAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;QAC3B,OAAO,EAAE;YACP,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE;YAC3D,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE;YAC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,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACvD,YAAY,EAAE;YACZ,KAAK,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;YAC1B,SAAS,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;YAClC,OAAO,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC;SAC/B;KACF,CAAC,CAAC;IAEH,gBAAgB;IAChB,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAEpC,iCAAiC;IACjC,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACrC,MAAM;QACR,KAAK,MAAM;YACT,MAAM,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACpC,MAAM;QACR,KAAK,KAAK;YACR,MAAM,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACnC,MAAM;QACR;YACE,OAAO,CAAC,KAAK,CAAC,2BAA2B,SAAS,EAAE,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Introspection utilities for extracting specifications from MCP Server
|
|
3
|
+
*/
|
|
4
|
+
import { McpServer, RegisteredTool, RegisteredResource, RegisteredResourceTemplate, RegisteredPrompt } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
/**
|
|
6
|
+
* Extended McpServer with introspection capabilities.
|
|
7
|
+
* Provides access to registered tools, resources, and prompts for spec extraction.
|
|
8
|
+
*/
|
|
9
|
+
export declare class IntrospectableMcpServer extends McpServer {
|
|
10
|
+
/**
|
|
11
|
+
* Get all registered tools with their metadata
|
|
12
|
+
*/
|
|
13
|
+
getRegisteredTools(): Record<string, RegisteredTool>;
|
|
14
|
+
/**
|
|
15
|
+
* Get all registered resources with their metadata
|
|
16
|
+
*/
|
|
17
|
+
getRegisteredResources(): Record<string, RegisteredResource>;
|
|
18
|
+
/**
|
|
19
|
+
* Get all registered resource templates with their metadata
|
|
20
|
+
*/
|
|
21
|
+
getRegisteredResourceTemplates(): Record<string, RegisteredResourceTemplate>;
|
|
22
|
+
/**
|
|
23
|
+
* Get all registered prompts with their metadata
|
|
24
|
+
*/
|
|
25
|
+
getRegisteredPrompts(): Record<string, RegisteredPrompt>;
|
|
26
|
+
}
|
|
27
|
+
interface ToolSpec {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
}
|
|
31
|
+
interface ResourceSpec {
|
|
32
|
+
name: string;
|
|
33
|
+
uri: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
mimeType?: string;
|
|
36
|
+
}
|
|
37
|
+
interface PromptArgSpec {
|
|
38
|
+
name: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
required?: boolean;
|
|
41
|
+
}
|
|
42
|
+
interface PromptSpec {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
arguments?: PromptArgSpec[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Extract tool specifications from an introspectable server
|
|
49
|
+
*/
|
|
50
|
+
export declare function extractToolsSpec(server: IntrospectableMcpServer): ToolSpec[];
|
|
51
|
+
/**
|
|
52
|
+
* Extract resource specifications from an introspectable server
|
|
53
|
+
*/
|
|
54
|
+
export declare function extractResourcesSpec(server: IntrospectableMcpServer): ResourceSpec[];
|
|
55
|
+
/**
|
|
56
|
+
* Extract prompt specifications from an introspectable server
|
|
57
|
+
*/
|
|
58
|
+
export declare function extractPromptsSpec(server: IntrospectableMcpServer): PromptSpec[];
|
|
59
|
+
/**
|
|
60
|
+
* Extract full specification from an introspectable server
|
|
61
|
+
*/
|
|
62
|
+
export declare function extractSpec(server: IntrospectableMcpServer): {
|
|
63
|
+
tools: ToolSpec[];
|
|
64
|
+
resources: ResourceSpec[];
|
|
65
|
+
prompts: PromptSpec[];
|
|
66
|
+
};
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=introspection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspection.d.ts","sourceRoot":"","sources":["../src/introspection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EACjB,MAAM,yCAAyC,CAAC;AAYjD;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;IACpD;;OAEG;IACH,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC;IAKpD;;OAEG;IACH,sBAAsB,IAAI,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAK5D;;OAEG;IACH,8BAA8B,IAAI,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC;IAK5E;;OAEG;IACH,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;CAIzD;AAED,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,GAAG,QAAQ,EAAE,CAc5E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,uBAAuB,GAC9B,YAAY,EAAE,CAkBhB;AAsDD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,uBAAuB,GAC9B,UAAU,EAAE,CAmBd;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,uBAAuB;;;;EAM1D"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Introspection utilities for extracting specifications from MCP Server
|
|
3
|
+
*/
|
|
4
|
+
import { McpServer, } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
/**
|
|
6
|
+
* Extended McpServer with introspection capabilities.
|
|
7
|
+
* Provides access to registered tools, resources, and prompts for spec extraction.
|
|
8
|
+
*/
|
|
9
|
+
export class IntrospectableMcpServer extends McpServer {
|
|
10
|
+
/**
|
|
11
|
+
* Get all registered tools with their metadata
|
|
12
|
+
*/
|
|
13
|
+
getRegisteredTools() {
|
|
14
|
+
// Access the private _registeredTools field (it's an object, not a Map)
|
|
15
|
+
return this._registeredTools;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get all registered resources with their metadata
|
|
19
|
+
*/
|
|
20
|
+
getRegisteredResources() {
|
|
21
|
+
// Access the private _registeredResources field (it's an object, not a Map)
|
|
22
|
+
return this._registeredResources;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get all registered resource templates with their metadata
|
|
26
|
+
*/
|
|
27
|
+
getRegisteredResourceTemplates() {
|
|
28
|
+
// Access the private _registeredResourceTemplates field (it's an object, not a Map)
|
|
29
|
+
return this._registeredResourceTemplates;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get all registered prompts with their metadata
|
|
33
|
+
*/
|
|
34
|
+
getRegisteredPrompts() {
|
|
35
|
+
// Access the private _registeredPrompts field (it's an object, not a Map)
|
|
36
|
+
return this._registeredPrompts;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Extract tool specifications from an introspectable server
|
|
41
|
+
*/
|
|
42
|
+
export function extractToolsSpec(server) {
|
|
43
|
+
const tools = [];
|
|
44
|
+
const registeredTools = server.getRegisteredTools();
|
|
45
|
+
for (const [name, tool] of Object.entries(registeredTools)) {
|
|
46
|
+
if (tool.enabled) {
|
|
47
|
+
tools.push({
|
|
48
|
+
name,
|
|
49
|
+
description: tool.description || "",
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return tools.sort((a, b) => a.name.localeCompare(b.name));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Extract resource specifications from an introspectable server
|
|
57
|
+
*/
|
|
58
|
+
export function extractResourcesSpec(server) {
|
|
59
|
+
const resources = [];
|
|
60
|
+
const registeredResources = server.getRegisteredResources();
|
|
61
|
+
for (const [uri, resource] of Object.entries(registeredResources)) {
|
|
62
|
+
if (resource.enabled) {
|
|
63
|
+
resources.push({
|
|
64
|
+
name: resource.name,
|
|
65
|
+
uri,
|
|
66
|
+
mimeType: resource.metadata?.mimeType || "text/plain",
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Note: Resource templates are not included in static spec extraction
|
|
71
|
+
// as they represent dynamic URI patterns
|
|
72
|
+
return resources.sort((a, b) => a.uri.localeCompare(b.uri));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Extract argument specifications from Zod schema
|
|
76
|
+
*/
|
|
77
|
+
function extractPromptArgs(argsSchema) {
|
|
78
|
+
if (!argsSchema || !argsSchema._def) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
const args = [];
|
|
82
|
+
// Handle Zod object schema
|
|
83
|
+
if (argsSchema._def.typeName === "ZodObject") {
|
|
84
|
+
const shape = argsSchema._def.shape?.();
|
|
85
|
+
if (shape) {
|
|
86
|
+
for (const [argName, argSchema] of Object.entries(shape)) {
|
|
87
|
+
// Check if the argument is optional
|
|
88
|
+
const isOptional = argSchema._def.typeName === "ZodOptional";
|
|
89
|
+
const innerSchema = isOptional ? argSchema._def.innerType : argSchema;
|
|
90
|
+
// Extract description from the schema
|
|
91
|
+
let description = "";
|
|
92
|
+
if (innerSchema?._def.description) {
|
|
93
|
+
description = innerSchema._def.description;
|
|
94
|
+
}
|
|
95
|
+
args.push({
|
|
96
|
+
name: argName,
|
|
97
|
+
description,
|
|
98
|
+
required: !isOptional,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return args;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Extract prompt specifications from an introspectable server
|
|
107
|
+
*/
|
|
108
|
+
export function extractPromptsSpec(server) {
|
|
109
|
+
const prompts = [];
|
|
110
|
+
const registeredPrompts = server.getRegisteredPrompts();
|
|
111
|
+
for (const [name, prompt] of Object.entries(registeredPrompts)) {
|
|
112
|
+
if (prompt.enabled) {
|
|
113
|
+
const args = prompt.argsSchema
|
|
114
|
+
? extractPromptArgs(prompt.argsSchema)
|
|
115
|
+
: [];
|
|
116
|
+
prompts.push({
|
|
117
|
+
name,
|
|
118
|
+
description: prompt.description || "",
|
|
119
|
+
arguments: args,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return prompts.sort((a, b) => a.name.localeCompare(b.name));
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Extract full specification from an introspectable server
|
|
127
|
+
*/
|
|
128
|
+
export function extractSpec(server) {
|
|
129
|
+
return {
|
|
130
|
+
tools: extractToolsSpec(server),
|
|
131
|
+
resources: extractResourcesSpec(server),
|
|
132
|
+
prompts: extractPromptsSpec(server),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=introspection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspection.js","sourceRoot":"","sources":["../src/introspection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,SAAS,GAKV,MAAM,yCAAyC,CAAC;AAYjD;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,SAAS;IACpD;;OAEG;IACH,kBAAkB;QAChB,wEAAwE;QACxE,OAAQ,IAAqC,CAAC,gBAAgB,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,sBAAsB;QACpB,4EAA4E;QAC5E,OAAQ,IAAqC,CAAC,oBAAoB,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,8BAA8B;QAC5B,oFAAoF;QACpF,OAAQ,IAAqC,CAAC,4BAA4B,CAAC;IAC7E,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,0EAA0E;QAC1E,OAAQ,IAAqC,CAAC,kBAAkB,CAAC;IACnE,CAAC;CACF;AA0BD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAA+B;IAC9D,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,MAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;IAEpD,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;QAC3D,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI;gBACJ,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;aACpC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CA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C,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,MAA+B;IACzD,OAAO;QACL,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC;QAC/B,SAAS,EAAE,oBAAoB,CAAC,MAAM,CAAC;QACvC,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC;KACpC,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server setup for MCP Test Kits
|
|
3
|
+
*/
|
|
4
|
+
import { Config } from "./config.js";
|
|
5
|
+
import { IntrospectableMcpServer } from "./introspection.js";
|
|
6
|
+
/**
|
|
7
|
+
* Create and configure the MCP server
|
|
8
|
+
*/
|
|
9
|
+
export declare function createServer(config: Config): IntrospectableMcpServer;
|
|
10
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAK7D;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,uBAAuB,CAoBpE"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server setup for MCP Test Kits
|
|
3
|
+
*/
|
|
4
|
+
import { IntrospectableMcpServer } from "./introspection.js";
|
|
5
|
+
import { registerTools } from "./capabilities/tools.js";
|
|
6
|
+
import { registerResources } from "./capabilities/resources.js";
|
|
7
|
+
import { registerPrompts } from "./capabilities/prompts.js";
|
|
8
|
+
/**
|
|
9
|
+
* Create and configure the MCP server
|
|
10
|
+
*/
|
|
11
|
+
export function createServer(config) {
|
|
12
|
+
const server = new IntrospectableMcpServer({
|
|
13
|
+
name: config.server.name,
|
|
14
|
+
version: config.server.version,
|
|
15
|
+
});
|
|
16
|
+
// Register capabilities based on config
|
|
17
|
+
if (config.capabilities.tools) {
|
|
18
|
+
registerTools(server);
|
|
19
|
+
}
|
|
20
|
+
if (config.capabilities.resources) {
|
|
21
|
+
registerResources(server);
|
|
22
|
+
}
|
|
23
|
+
if (config.capabilities.prompts) {
|
|
24
|
+
registerPrompts(server);
|
|
25
|
+
}
|
|
26
|
+
return server;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,MAAM,GAAG,IAAI,uBAAuB,CAAC;QACzC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;QACxB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO;KAC/B,CAAC,CAAC;IAEH,wCAAwC;IACxC,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC9B,aAAa,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC;QAClC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP transport for MCP Test Kits (Streamable HTTP)
|
|
3
|
+
*/
|
|
4
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
import type { Config } from "../config.js";
|
|
6
|
+
/**
|
|
7
|
+
* Run the MCP server over HTTP transport (Streamable HTTP)
|
|
8
|
+
*/
|
|
9
|
+
export declare function runHttpServer(server: McpServer, config: Config): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/transports/http.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;GAEG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP transport for MCP Test Kits (Streamable HTTP)
|
|
3
|
+
*/
|
|
4
|
+
import express from "express";
|
|
5
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
6
|
+
/**
|
|
7
|
+
* Run the MCP server over HTTP transport (Streamable HTTP)
|
|
8
|
+
*/
|
|
9
|
+
export async function runHttpServer(server, config) {
|
|
10
|
+
const { host, port } = config.transport.network;
|
|
11
|
+
const app = express();
|
|
12
|
+
app.use(express.json());
|
|
13
|
+
// MCP endpoint - handle all HTTP methods
|
|
14
|
+
app.all("/mcp", async (req, res) => {
|
|
15
|
+
const transport = new StreamableHTTPServerTransport({
|
|
16
|
+
sessionIdGenerator: undefined,
|
|
17
|
+
enableJsonResponse: true,
|
|
18
|
+
});
|
|
19
|
+
res.on("close", () => transport.close());
|
|
20
|
+
await server.connect(transport);
|
|
21
|
+
await transport.handleRequest(req, res, req.body);
|
|
22
|
+
});
|
|
23
|
+
// Start server
|
|
24
|
+
console.error(`Starting MCP HTTP server at http://${host}:${port}/mcp`);
|
|
25
|
+
app.listen(port, host, () => {
|
|
26
|
+
console.error(`MCP HTTP server listening on http://${host}:${port}`);
|
|
27
|
+
});
|
|
28
|
+
// Keep the process running
|
|
29
|
+
await new Promise(() => { });
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/transports/http.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAGnG;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAiB,EACjB,MAAc;IAEd,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;IAEhD,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAExB,yCAAyC;IACzC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACjC,MAAM,SAAS,GAAG,IAAI,6BAA6B,CAAC;YAClD,kBAAkB,EAAE,SAAS;YAC7B,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;QACzC,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,MAAM,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,eAAe;IACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,IAAI,IAAI,IAAI,MAAM,CAAC,CAAC;IACxE,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;QAC1B,OAAO,CAAC,KAAK,CAAC,uCAAuC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,2BAA2B;IAC3B,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transports/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transports/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSE transport for MCP Test Kits
|
|
3
|
+
*/
|
|
4
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
import type { Config } from "../config.js";
|
|
6
|
+
/**
|
|
7
|
+
* Run the MCP server over SSE transport
|
|
8
|
+
*/
|
|
9
|
+
export declare function runSseServer(server: McpServer, config: Config): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/transports/sse.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;GAEG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CA4Cf"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSE transport for MCP Test Kits
|
|
3
|
+
*/
|
|
4
|
+
import express from "express";
|
|
5
|
+
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
6
|
+
/**
|
|
7
|
+
* Run the MCP server over SSE transport
|
|
8
|
+
*/
|
|
9
|
+
export async function runSseServer(server, config) {
|
|
10
|
+
const { host, port } = config.transport.network;
|
|
11
|
+
const app = express();
|
|
12
|
+
app.use(express.json());
|
|
13
|
+
// Store active transports for session management
|
|
14
|
+
const transports = new Map();
|
|
15
|
+
// SSE endpoint for server->client messages
|
|
16
|
+
app.get("/sse", async (req, res) => {
|
|
17
|
+
const transport = new SSEServerTransport("/sse", res);
|
|
18
|
+
const sessionId = transport.sessionId;
|
|
19
|
+
transports.set(sessionId, transport);
|
|
20
|
+
// Cleanup on close
|
|
21
|
+
transport.onclose = () => {
|
|
22
|
+
transports.delete(sessionId);
|
|
23
|
+
};
|
|
24
|
+
await server.connect(transport);
|
|
25
|
+
});
|
|
26
|
+
// POST endpoint for client->server messages
|
|
27
|
+
app.post("/sse", async (req, res) => {
|
|
28
|
+
const sessionId = req.query.sessionId;
|
|
29
|
+
if (!sessionId || !transports.has(sessionId)) {
|
|
30
|
+
res.status(400).json({ error: "Invalid or missing session ID" });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const transport = transports.get(sessionId);
|
|
34
|
+
await transport.handlePostMessage(req, res, req.body);
|
|
35
|
+
});
|
|
36
|
+
// Start server
|
|
37
|
+
console.error(`Starting MCP SSE server at http://${host}:${port}/sse`);
|
|
38
|
+
app.listen(port, host, () => {
|
|
39
|
+
console.error(`MCP SSE server listening on http://${host}:${port}`);
|
|
40
|
+
});
|
|
41
|
+
// Keep the process running
|
|
42
|
+
await new Promise(() => { });
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=sse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/transports/sse.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAG7E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAiB,EACjB,MAAc;IAEd,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;IAEhD,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAExB,iDAAiD;IACjD,MAAM,UAAU,GAAG,IAAI,GAAG,EAA8B,CAAC;IAEzD,2CAA2C;IAC3C,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACjC,MAAM,SAAS,GAAG,IAAI,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;QACtC,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAErC,mBAAmB;QACnB,SAAS,CAAC,OAAO,GAAG,GAAG,EAAE;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
+
/**
|
|
7
|
+
* Run the MCP server over stdio transport
|
|
8
|
+
*/
|
|
9
|
+
export declare function runStdioServer(server: McpServer, _config: Config): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=stdio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../../src/transports/stdio.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;GAEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stdio transport for MCP Test Kits
|
|
3
|
+
*/
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
/**
|
|
6
|
+
* Run the MCP server over stdio transport
|
|
7
|
+
*/
|
|
8
|
+
export async function runStdioServer(server, _config) {
|
|
9
|
+
const transport = new StdioServerTransport();
|
|
10
|
+
await server.connect(transport);
|
|
11
|
+
// Keep the process running
|
|
12
|
+
await new Promise(() => { });
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../src/transports/stdio.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGjF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAiB,EACjB,OAAe;IAEf,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,2BAA2B;IAC3B,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAC9B,CAAC"}
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
|
|
4
|
+
export default tseslint.config(
|
|
5
|
+
js.configs.recommended,
|
|
6
|
+
...tseslint.configs.recommended,
|
|
7
|
+
{
|
|
8
|
+
files: ['src/**/*.ts'],
|
|
9
|
+
languageOptions: {
|
|
10
|
+
parserOptions: {
|
|
11
|
+
project: './tsconfig.json',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
16
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
ignores: ['dist/**', 'node_modules/**'],
|
|
21
|
+
}
|
|
22
|
+
);
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcp-test-kits",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "A comprehensive MCP testing server for debugging and testing MCP clients",
|
|
5
|
+
"author": "midodimori",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/midodimori/mcp-test-kits"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"bin": {
|
|
13
|
+
"mcp-test-kits": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"dev": "tsx src/index.ts",
|
|
18
|
+
"start": "node dist/index.js",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"lint": "eslint src/",
|
|
21
|
+
"lint:fix": "eslint src/ --fix && prettier --write src/",
|
|
22
|
+
"typecheck": "tsc --noEmit"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"mcp",
|
|
26
|
+
"model-context-protocol",
|
|
27
|
+
"testing",
|
|
28
|
+
"ai",
|
|
29
|
+
"llm"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
37
|
+
"express": "^4.21.0",
|
|
38
|
+
"zod": "^3.23.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@eslint/js": "^9.17.0",
|
|
42
|
+
"@types/express": "^4.17.21",
|
|
43
|
+
"@types/node": "^22.0.0",
|
|
44
|
+
"eslint": "^9.17.0",
|
|
45
|
+
"prettier": "^3.4.0",
|
|
46
|
+
"tsx": "^4.19.0",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"typescript-eslint": "^8.18.2",
|
|
49
|
+
"vitest": "^2.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|