@tsed/platform-mcp 8.34.0 → 8.35.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/decorators/prompt.js +1 -1
- package/lib/esm/decorators/resource.js +1 -1
- package/lib/esm/decorators/tool.js +1 -1
- package/lib/esm/fn/definePrompt.js +3 -3
- package/lib/esm/fn/defineResource.js +3 -3
- package/lib/esm/fn/defineTool.js +6 -6
- package/lib/esm/services/McpServerFactory.js +1 -1
- package/lib/esm/services/PlatformMcpModule.js +3 -3
- package/lib/esm/utils/toZod.js +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/decorators/resource.d.ts +1 -1
- package/lib/types/fn/definePrompt.d.ts +3 -3
- package/lib/types/fn/defineTool.d.ts +3 -3
- package/lib/types/interfaces/PlatformMcpSettings.d.ts +1 -1
- package/lib/types/services/PlatformMcpModule.d.ts +1 -1
- package/package.json +9 -10
- package/src/decorators/prompt.spec.ts +1 -2
- package/src/decorators/prompt.ts +1 -2
- package/src/decorators/resource.spec.ts +1 -2
- package/src/decorators/resource.ts +1 -2
- package/src/decorators/tool.spec.ts +1 -2
- package/src/decorators/tool.ts +1 -2
- package/src/fn/definePrompt.spec.ts +2 -3
- package/src/fn/definePrompt.ts +6 -7
- package/src/fn/defineResource.spec.ts +2 -3
- package/src/fn/defineResource.ts +4 -5
- package/src/fn/defineTool.spec.ts +4 -5
- package/src/fn/defineTool.ts +9 -10
- package/src/interfaces/PlatformMcpSettings.ts +1 -1
- package/src/services/McpServerFactory.ts +4 -5
- package/src/services/PlatformMcpModule.spec.ts +3 -5
- package/src/services/PlatformMcpModule.ts +4 -5
- package/src/utils/toZod.spec.ts +1 -2
- package/src/utils/toZod.ts +1 -1
- package/vitest.config.mts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { defineResource } from "../fn/defineResource.js";
|
|
1
2
|
import { classOf } from "@tsed/core";
|
|
2
3
|
import { isString } from "@tsed/core/utils/isString.js";
|
|
3
|
-
import { defineResource } from "../fn/defineResource.js";
|
|
4
4
|
/**
|
|
5
5
|
* Decorator that turns a class method into an MCP resource backed by either a URI or a full {@link ResourceTemplate}.
|
|
6
6
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isArrowFn } from "@tsed/core";
|
|
2
|
+
import { s } from "@tsed/schema";
|
|
2
3
|
import { context, inject, injectable, logger } from "@tsed/di";
|
|
3
|
-
import { JsonEntityStore } from "@tsed/schema";
|
|
4
|
-
import { constantCase } from "change-case";
|
|
5
4
|
import { MCP_PROVIDER_TYPES } from "../constants/constants.js";
|
|
5
|
+
import { constantCase } from "change-case";
|
|
6
6
|
import { toZod } from "../utils/toZod.js";
|
|
7
7
|
function mapOptions(options) {
|
|
8
8
|
let handler = undefined;
|
|
@@ -16,7 +16,7 @@ function mapOptions(options) {
|
|
|
16
16
|
const instance = inject(options.token);
|
|
17
17
|
return instance[propertyKey](...args);
|
|
18
18
|
});
|
|
19
|
-
const methodStore =
|
|
19
|
+
const methodStore = s.store.method(token, propertyKey);
|
|
20
20
|
options.description = options.description || methodStore.operation.get("description");
|
|
21
21
|
options.title = options.title || methodStore.schema.get("title");
|
|
22
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { context, inject, injectable, logger } from "@tsed/di";
|
|
2
|
-
import { JsonEntityStore } from "@tsed/schema";
|
|
3
|
-
import { constantCase } from "change-case";
|
|
4
2
|
import { MCP_PROVIDER_TYPES } from "../constants/constants.js";
|
|
3
|
+
import { constantCase } from "change-case";
|
|
4
|
+
import { s } from "@tsed/schema";
|
|
5
5
|
function isClassResourceProps(options) {
|
|
6
6
|
return "token" in options && "propertyKey" in options;
|
|
7
7
|
}
|
|
@@ -14,7 +14,7 @@ function mapOptions(options) {
|
|
|
14
14
|
const instance = inject(options.token);
|
|
15
15
|
return instance[propertyKey](...args);
|
|
16
16
|
};
|
|
17
|
-
const methodStore =
|
|
17
|
+
const methodStore = s.store.method(token, propertyKey);
|
|
18
18
|
options.description = options.description || methodStore.operation.get("description");
|
|
19
19
|
options.title = options.title || methodStore.schema.get("title");
|
|
20
20
|
}
|
package/lib/esm/fn/defineTool.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { isArrowFn, isClass } from "@tsed/core";
|
|
2
|
+
import { JsonSchema, s } from "@tsed/schema";
|
|
2
3
|
import { context, inject, injectable, logger } from "@tsed/di";
|
|
3
|
-
import { deserialize } from "@tsed/json-mapper";
|
|
4
|
-
import { JsonEntityStore, JsonSchema } from "@tsed/schema";
|
|
5
|
-
import { constantCase } from "change-case";
|
|
6
4
|
import { MCP_PROVIDER_TYPES } from "../constants/constants.js";
|
|
5
|
+
import { constantCase } from "change-case";
|
|
6
|
+
import { deserialize } from "@tsed/json-mapper";
|
|
7
7
|
import { toZod } from "../utils/toZod.js";
|
|
8
8
|
function getOutputSchema(methodStore) {
|
|
9
9
|
const schema = methodStore.operation.getResponseOf(200)?.getMedia("application/json")?.get("schema");
|
|
10
10
|
return schema?.itemSchema();
|
|
11
11
|
}
|
|
12
12
|
function getInputSchema(token, propertyKey) {
|
|
13
|
-
return
|
|
13
|
+
return s.store(token, propertyKey, 0).schema?.itemSchema();
|
|
14
14
|
}
|
|
15
15
|
function resolveInputSchema(inputSchema) {
|
|
16
16
|
return isArrowFn(inputSchema) ? inputSchema() : inputSchema;
|
|
@@ -34,12 +34,12 @@ function mapOptions(options) {
|
|
|
34
34
|
let inputStore;
|
|
35
35
|
if ("propertyKey" in options) {
|
|
36
36
|
const { token, propertyKey } = options;
|
|
37
|
-
inputStore =
|
|
37
|
+
inputStore = s.store(token, propertyKey, 0);
|
|
38
38
|
handler = (args, extra) => {
|
|
39
39
|
const instance = inject(options.token);
|
|
40
40
|
return instance[options.propertyKey](args, extra);
|
|
41
41
|
};
|
|
42
|
-
const methodStore =
|
|
42
|
+
const methodStore = s.store.method(token, propertyKey);
|
|
43
43
|
options.description = options.description || methodStore.operation.get("description");
|
|
44
44
|
options.inputSchema =
|
|
45
45
|
options.inputSchema || (inputStore.schema?.itemSchema() || getInputSchema(token, propertyKey));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
1
|
import { constant, inject, injectable, injector } from "@tsed/di";
|
|
3
2
|
import { MCP_PROVIDER_TYPES } from "../constants/constants.js";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
4
|
function collectTokens(type, configured = []) {
|
|
5
5
|
const tokens = new Set(configured);
|
|
6
6
|
injector()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
2
|
-
import { constant, inject, injectable } from "@tsed/di";
|
|
3
1
|
import { application } from "@tsed/platform-http";
|
|
4
|
-
import {
|
|
2
|
+
import { constant, inject, injectable } from "@tsed/di";
|
|
5
3
|
import { MCP_SERVER } from "./McpServerFactory.js";
|
|
4
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
5
|
+
import { useContextHandler } from "@tsed/platform-router";
|
|
6
6
|
/**
|
|
7
7
|
* Platform module that mounts the MCP HTTP endpoint and forwards requests to the configured server instance.
|
|
8
8
|
*
|
package/lib/esm/utils/toZod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JsonSchema } from "@tsed/schema";
|
|
2
|
-
import { jsonSchemaToZod } from "json-schema-to-zod";
|
|
3
2
|
import { z } from "zod";
|
|
3
|
+
import { jsonSchemaToZod } from "json-schema-to-zod";
|
|
4
4
|
function transform(schema, opts) {
|
|
5
5
|
const schemaFactory = new Function("z", `return ${jsonSchemaToZod(schema.toJSON(opts), { zodVersion: 4 })}`);
|
|
6
6
|
return schemaFactory(z);
|