@tsed/platform-mcp 8.40.1 → 8.41.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/lib/esm/cli/services/mcpStdioServer.js +2 -1
- package/lib/esm/common/utils/asResourceResponse.js +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/cli/services/mcpStdioServer.spec.ts +18 -1
- package/src/cli/services/mcpStdioServer.ts +2 -1
- package/src/common/fn/defineResource.spec.ts +1 -1
- package/src/common/utils/asResourceResponse.spec.ts +1 -1
- package/src/common/utils/asResourceResponse.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-mcp",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.41.0",
|
|
4
4
|
"description": "Model Context Protocol integration for Ts.ED HTTP adapters.",
|
|
5
5
|
"source": "./src/http/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"uuid": ">=11.0.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@tsed/barrels": "8.
|
|
53
|
-
"@tsed/core": "8.
|
|
54
|
-
"@tsed/di": "8.
|
|
55
|
-
"@tsed/json-mapper": "8.
|
|
56
|
-
"@tsed/platform-http": "8.
|
|
57
|
-
"@tsed/schema": "8.
|
|
58
|
-
"@tsed/typescript": "8.
|
|
52
|
+
"@tsed/barrels": "8.41.0",
|
|
53
|
+
"@tsed/core": "8.41.0",
|
|
54
|
+
"@tsed/di": "8.41.0",
|
|
55
|
+
"@tsed/json-mapper": "8.41.0",
|
|
56
|
+
"@tsed/platform-http": "8.41.0",
|
|
57
|
+
"@tsed/schema": "8.41.0",
|
|
58
|
+
"@tsed/typescript": "8.41.0",
|
|
59
59
|
"typescript": "6.0.2",
|
|
60
60
|
"vitest": "4.1.4"
|
|
61
61
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {McpServer} from "@modelcontextprotocol/server";
|
|
2
|
-
import {DITest} from "@tsed/di";
|
|
2
|
+
import {DITest, injector} from "@tsed/di";
|
|
3
3
|
import {beforeEach, describe, expect, it, vi} from "vitest";
|
|
4
4
|
|
|
5
5
|
import {mcpStdioServer} from "./mcpStdioServer.js";
|
|
@@ -65,4 +65,21 @@ describe("mcpStdioServer", () => {
|
|
|
65
65
|
|
|
66
66
|
expect(importSpy).toHaveBeenCalled();
|
|
67
67
|
});
|
|
68
|
+
|
|
69
|
+
it("should stop the logger before connecting", async () => {
|
|
70
|
+
const stop = vi.fn();
|
|
71
|
+
injector().logger = {...console, stop} as any;
|
|
72
|
+
|
|
73
|
+
await mcpStdioServer(mockServer);
|
|
74
|
+
|
|
75
|
+
expect(stop).toHaveBeenCalledTimes(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("should connect when the logger has no stop method", async () => {
|
|
79
|
+
injector().logger = console as any;
|
|
80
|
+
|
|
81
|
+
await mcpStdioServer(mockServer);
|
|
82
|
+
|
|
83
|
+
expect(mockConnect).toHaveBeenCalledTimes(1);
|
|
84
|
+
});
|
|
68
85
|
});
|
|
@@ -6,7 +6,8 @@ export async function mcpStdioServer(server: McpServer) {
|
|
|
6
6
|
|
|
7
7
|
const transport = new StdioServerTransport();
|
|
8
8
|
|
|
9
|
-
logger().
|
|
9
|
+
// stdout is reserved for the MCP protocol; a logger without stop() (e.g. console) is left untouched
|
|
10
|
+
logger().stop?.();
|
|
10
11
|
|
|
11
12
|
return server.connect(transport);
|
|
12
13
|
}
|
|
@@ -10,7 +10,7 @@ describe("defineResource", () => {
|
|
|
10
10
|
function expectError(result: any, error: Record<string, unknown>) {
|
|
11
11
|
expect(result.contents[0]).toEqual({
|
|
12
12
|
uri: "tsed://resource",
|
|
13
|
-
mimeType: "plain
|
|
13
|
+
mimeType: "text/plain",
|
|
14
14
|
text: error.message
|
|
15
15
|
});
|
|
16
16
|
expect(result.contents[1]).toEqual({
|
|
@@ -24,7 +24,7 @@ describe("asResponse", () => {
|
|
|
24
24
|
it("should add a text error item before the JSON error payload", () => {
|
|
25
25
|
expect(asResourceResponse("tsed://resource", {message: "boom"}, {isError: true})).toEqual({
|
|
26
26
|
contents: [
|
|
27
|
-
{uri: "tsed://resource", mimeType: "plain
|
|
27
|
+
{uri: "tsed://resource", mimeType: "text/plain", text: "boom"},
|
|
28
28
|
{uri: "tsed://resource", mimeType: "application/json", text: '{\n "message": "boom"\n}'}
|
|
29
29
|
]
|
|
30
30
|
});
|