@tsed/platform-mcp 8.28.0 → 8.28.2

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.
@@ -1,11 +1,11 @@
1
- import { type PromptProps } from "../fn/definePrompt.js";
1
+ import { type ClassPromptProps } from "../fn/definePrompt.js";
2
2
  /**
3
3
  * Options accepted by {@link Prompt} when decorating a class method. Matches {@link PromptProps} minus the handler reference.
4
4
  *
5
5
  * @module platform/mcp
6
6
  * @since 8.17.0
7
7
  */
8
- export type PromptDecoratorOptions = Omit<PromptProps, "handler">;
8
+ export type PromptDecoratorOptions<Args = any> = Omit<ClassPromptProps<Args>, "token" | "propertyKey">;
9
9
  /**
10
10
  * Declares a Ts.ED class method as an MCP prompt and registers it through {@link definePrompt}.
11
11
  *
@@ -23,4 +23,4 @@ export type PromptDecoratorOptions = Omit<PromptProps, "handler">;
23
23
  * }
24
24
  * ```
25
25
  */
26
- export declare function Prompt(options?: PromptDecoratorOptions): (target: any, propertyKey: string | symbol, _: PropertyDescriptor) => void;
26
+ export declare function Prompt<Args = any>(options?: PromptDecoratorOptions<Args>): (target: any, propertyKey: string | symbol, _: PropertyDescriptor) => void;
@@ -1,12 +1,12 @@
1
1
  import type { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { type ResourceProps } from "../fn/defineResource.js";
2
+ import { type ClassResourceReadProps } from "../fn/defineResource.js";
3
3
  /**
4
4
  * Options accepted by the {@link Resource} decorator beyond the handler binding fields, allowing callers to override metadata.
5
5
  *
6
6
  * @module platform/mcp
7
7
  * @since 8.17.0
8
8
  */
9
- export type ResourceDecoratorOptions = Omit<ResourceProps, "handler" | "uri" | "template">;
9
+ export type ResourceDecoratorOptions = Omit<ClassResourceReadProps, "token" | "propertyKey" | "uri">;
10
10
  /**
11
11
  * Decorator that turns a class method into an MCP resource backed by either a URI or a full {@link ResourceTemplate}.
12
12
  *
@@ -1,14 +1,22 @@
1
- import type { McpServer, PromptCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
1
+ import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
2
+ import type { GetPromptResult, ServerNotification, ServerRequest } from "@modelcontextprotocol/sdk/types.js";
2
3
  import { type AbstractType, type Type } from "@tsed/core";
4
+ import { type TokenProvider } from "@tsed/di";
3
5
  import { JsonSchema } from "@tsed/schema";
4
- type BasePromptProps<Args> = Omit<Parameters<McpServer["registerPrompt"]>[1], "argsSchema"> & {
6
+ type BasePromptConfig = {
7
+ title?: string;
8
+ description?: string;
9
+ };
10
+ type BasePromptProps<Args> = BasePromptConfig & {
5
11
  name: string;
6
- argsSchema?: Parameters<McpServer["registerPrompt"]>[1]["argsSchema"] | JsonSchema<Args> | (() => JsonSchema<Args>);
12
+ argsSchema?: JsonSchema<Args> | (() => JsonSchema<Args>) | Record<string, unknown>;
7
13
  };
8
- type FnPromptProps<Args extends undefined = any> = BasePromptProps<Args> & {
9
- handler: PromptCallback<Args>;
14
+ export type PromptHandler<Args = undefined> = Args extends undefined ? (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => GetPromptResult | Promise<GetPromptResult> : (args: Args, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => GetPromptResult | Promise<GetPromptResult>;
15
+ export type FnPromptProps<Args = any> = BasePromptProps<Args> & {
16
+ handler: PromptHandler<Args>;
10
17
  };
11
- type ClassPromptProps<Args extends undefined = any> = BasePromptProps<Args> & {
18
+ export type ClassPromptProps<Args = any> = Omit<BasePromptProps<Args>, "name"> & {
19
+ name?: string;
12
20
  token: Type | AbstractType<any>;
13
21
  propertyKey: string | symbol;
14
22
  };
@@ -19,19 +27,19 @@ type ClassPromptProps<Args extends undefined = any> = BasePromptProps<Args> & {
19
27
  * @module platform/mcp
20
28
  * @since 8.17.0
21
29
  */
22
- export type PromptProps<Args extends undefined = any> = FnPromptProps<Args> | ClassPromptProps<Args>;
23
- declare function mapOptions<Args extends undefined = any>(options: PromptProps<Args>): {
30
+ export type PromptProps<Args = any> = FnPromptProps<Args> | ClassPromptProps<Args>;
31
+ declare function mapOptions<Args = any>(options: PromptProps<Args>): {
32
+ name: string | undefined;
24
33
  argsSchema: import("zod").ZodObject<import("zod/v4/core").$ZodLooseShape, import("zod/v4/core").$strip> | undefined;
25
- handler: PromptCallback<Args>;
26
- description?: string | undefined;
27
- title?: string | undefined;
28
- name: string;
34
+ handler: PromptHandler<Args>;
35
+ title?: string;
36
+ description?: string;
29
37
  } | {
38
+ name: string | undefined;
30
39
  argsSchema: import("zod").ZodObject<import("zod/v4/core").$ZodLooseShape, import("zod/v4/core").$strip> | undefined;
31
- handler: PromptCallback<Args>;
40
+ handler: PromptHandler<Args>;
32
41
  description?: string | undefined;
33
42
  title?: string | undefined;
34
- name: string;
35
43
  token: Type | AbstractType<any>;
36
44
  propertyKey: string | symbol;
37
45
  };
@@ -60,19 +68,6 @@ export type PromptsSettings = ReturnType<typeof mapOptions>;
60
68
  * });
61
69
  * ```
62
70
  */
63
- export declare function definePrompt<Args extends undefined = any>(options: PromptProps<Args>): import("@tsed/di").FactoryTokenProvider<{
64
- argsSchema: import("zod").ZodObject<import("zod/v4/core").$ZodLooseShape, import("zod/v4/core").$strip> | undefined;
65
- handler: PromptCallback<Args>;
66
- description?: string | undefined;
67
- title?: string | undefined;
68
- name: string;
69
- } | {
70
- argsSchema: import("zod").ZodObject<import("zod/v4/core").$ZodLooseShape, import("zod/v4/core").$strip> | undefined;
71
- handler: PromptCallback<Args>;
72
- description?: string | undefined;
73
- title?: string | undefined;
74
- name: string;
75
- token: Type | AbstractType<any>;
76
- propertyKey: string | symbol;
77
- }>;
71
+ export declare function definePrompt<Args = any>(options: FnPromptProps<Args>): TokenProvider;
72
+ export declare function definePrompt<Args = any>(options: ClassPromptProps<Args>): TokenProvider;
78
73
  export {};
@@ -1,15 +1,25 @@
1
1
  import type { ReadResourceCallback, ResourceMetadata, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { type TokenProvider } from "@tsed/di";
3
- type ResourceBaseProps = ResourceMetadata & {
3
+ type ResourceMetadataProps = ResourceMetadata & {
4
4
  name: string;
5
+ };
6
+ export type FnResourceReadProps = ResourceMetadataProps & {
7
+ uri: string;
8
+ handler: ReadResourceCallback;
9
+ };
10
+ export type FnResourceTemplateProps = ResourceMetadataProps & {
11
+ template: ResourceTemplate;
5
12
  handler: ReadResourceCallback;
6
- token?: TokenProvider;
7
- propertyKey?: string | symbol;
8
13
  };
9
- type ResourceReadProps = ResourceBaseProps & {
14
+ type ClassResourceBaseProps = Omit<ResourceMetadataProps, "name"> & {
15
+ name?: string;
16
+ token: TokenProvider;
17
+ propertyKey: string | symbol;
18
+ };
19
+ export type ClassResourceReadProps = ClassResourceBaseProps & {
10
20
  uri: string;
11
21
  };
12
- type ResourceTemplateProps = ResourceBaseProps & {
22
+ export type ClassResourceTemplateProps = ClassResourceBaseProps & {
13
23
  template: ResourceTemplate;
14
24
  };
15
25
  /**
@@ -18,7 +28,101 @@ type ResourceTemplateProps = ResourceBaseProps & {
18
28
  * @module platform/mcp
19
29
  * @since 8.17.0
20
30
  */
21
- export type ResourceProps = ResourceReadProps | ResourceTemplateProps;
31
+ export type ResourceProps = FnResourceReadProps | FnResourceTemplateProps | ClassResourceReadProps | ClassResourceTemplateProps;
32
+ declare function mapOptions(options: ResourceProps): {
33
+ name: string | undefined;
34
+ handler: ReadResourceCallback;
35
+ description?: string | undefined;
36
+ _meta?: {
37
+ [x: string]: unknown;
38
+ } | undefined;
39
+ annotations?: {
40
+ audience?: ("user" | "assistant")[] | undefined;
41
+ priority?: number | undefined;
42
+ lastModified?: string | undefined;
43
+ } | undefined;
44
+ icons?: {
45
+ src: string;
46
+ mimeType?: string | undefined;
47
+ sizes?: string[] | undefined;
48
+ theme?: "light" | "dark" | undefined;
49
+ }[] | undefined;
50
+ title?: string | undefined;
51
+ mimeType?: string | undefined;
52
+ size?: number | undefined;
53
+ uri: string;
54
+ } | {
55
+ name: string | undefined;
56
+ handler: ReadResourceCallback;
57
+ description?: string | undefined;
58
+ _meta?: {
59
+ [x: string]: unknown;
60
+ } | undefined;
61
+ annotations?: {
62
+ audience?: ("user" | "assistant")[] | undefined;
63
+ priority?: number | undefined;
64
+ lastModified?: string | undefined;
65
+ } | undefined;
66
+ icons?: {
67
+ src: string;
68
+ mimeType?: string | undefined;
69
+ sizes?: string[] | undefined;
70
+ theme?: "light" | "dark" | undefined;
71
+ }[] | undefined;
72
+ title?: string | undefined;
73
+ mimeType?: string | undefined;
74
+ size?: number | undefined;
75
+ template: ResourceTemplate;
76
+ } | {
77
+ name: string | undefined;
78
+ handler: ReadResourceCallback;
79
+ description?: string | undefined;
80
+ _meta?: {
81
+ [x: string]: unknown;
82
+ } | undefined;
83
+ annotations?: {
84
+ audience?: ("user" | "assistant")[] | undefined;
85
+ priority?: number | undefined;
86
+ lastModified?: string | undefined;
87
+ } | undefined;
88
+ icons?: {
89
+ src: string;
90
+ mimeType?: string | undefined;
91
+ sizes?: string[] | undefined;
92
+ theme?: "light" | "dark" | undefined;
93
+ }[] | undefined;
94
+ title?: string | undefined;
95
+ mimeType?: string | undefined;
96
+ size?: number | undefined;
97
+ token: TokenProvider;
98
+ propertyKey: string | symbol;
99
+ uri: string;
100
+ } | {
101
+ name: string | undefined;
102
+ handler: ReadResourceCallback;
103
+ description?: string | undefined;
104
+ _meta?: {
105
+ [x: string]: unknown;
106
+ } | undefined;
107
+ annotations?: {
108
+ audience?: ("user" | "assistant")[] | undefined;
109
+ priority?: number | undefined;
110
+ lastModified?: string | undefined;
111
+ } | undefined;
112
+ icons?: {
113
+ src: string;
114
+ mimeType?: string | undefined;
115
+ sizes?: string[] | undefined;
116
+ theme?: "light" | "dark" | undefined;
117
+ }[] | undefined;
118
+ title?: string | undefined;
119
+ mimeType?: string | undefined;
120
+ size?: number | undefined;
121
+ token: TokenProvider;
122
+ propertyKey: string | symbol;
123
+ template: ResourceTemplate;
124
+ };
125
+ export type ResourceSettings = ReturnType<typeof mapOptions>;
22
126
  /**
23
127
  * Registers an MCP resource provider with the Ts.ED injector and returns its token.
24
128
  *
@@ -36,6 +140,8 @@ export type ResourceProps = ResourceReadProps | ResourceTemplateProps;
36
140
  * });
37
141
  * ```
38
142
  */
39
- export declare function defineResource(options: ResourceReadProps): TokenProvider;
40
- export declare function defineResource(options: ResourceTemplateProps): TokenProvider;
143
+ export declare function defineResource(options: FnResourceReadProps): TokenProvider;
144
+ export declare function defineResource(options: FnResourceTemplateProps): TokenProvider;
145
+ export declare function defineResource(options: ClassResourceReadProps): TokenProvider;
146
+ export declare function defineResource(options: ClassResourceTemplateProps): TokenProvider;
41
147
  export {};
@@ -1,7 +1,7 @@
1
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
1
  import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
3
- import type { CallToolResult, ServerNotification, ServerRequest, Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import type { CallToolResult, ServerNotification, ServerRequest, Tool, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
4
3
  import { type AbstractType, type Type } from "@tsed/core";
4
+ import { type TokenProvider } from "@tsed/di";
5
5
  import { JsonSchema } from "@tsed/schema";
6
6
  /**
7
7
  * Signature implemented by MCP tool handlers invoked through {@link defineTool}.
@@ -11,12 +11,17 @@ import { JsonSchema } from "@tsed/schema";
11
11
  * @since 8.17.0
12
12
  */
13
13
  export type ToolCallback<Args = undefined> = (args: Args, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => CallToolResult | Promise<CallToolResult>;
14
- type ToolConfig = Parameters<McpServer["registerTool"]>[1];
15
- type BaseToolProps<Input, Output = undefined> = Omit<ToolConfig, "inputSchema" | "outputSchema"> & {
14
+ type BaseToolConfig = {
15
+ title?: string;
16
+ description?: string;
17
+ annotations?: ToolAnnotations;
18
+ _meta?: Record<string, unknown>;
19
+ };
20
+ type BaseToolProps<Input, Output = undefined> = BaseToolConfig & {
16
21
  inputSchema?: JsonSchema<Input> | (() => JsonSchema<Input>) | Tool["inputSchema"];
17
22
  outputSchema?: JsonSchema<Output> | Tool["outputSchema"];
18
23
  };
19
- type FnToolProps<Input, Output = undefined> = BaseToolProps<Input, Output> & {
24
+ export type FnToolProps<Input, Output = undefined> = BaseToolProps<Input, Output> & {
20
25
  name: string;
21
26
  handler: ToolCallback<Input>;
22
27
  };
@@ -56,221 +61,6 @@ export type ToolProps<Input, Output = undefined> = FnToolProps<Input, Output> |
56
61
  * });
57
62
  * ```
58
63
  */
59
- export declare function defineTool<Input, Output = undefined>(options: ToolProps<Input, Output>): import("@tsed/di").FactoryTokenProvider<{
60
- name: string | undefined;
61
- inputSchema: import("zod").ZodObject<import("zod/v4/core").$ZodLooseShape, import("zod/v4/core").$strip> | undefined;
62
- outputSchema: import("zod").ZodObject<import("zod/v4/core").$ZodLooseShape, import("zod/v4/core").$strip> | undefined;
63
- handler(args: Input, extra: RequestHandlerExtra<ServerRequest, ServerNotification>): Promise<{
64
- [x: string]: unknown;
65
- content: ({
66
- type: "text";
67
- text: string;
68
- annotations?: {
69
- audience?: ("user" | "assistant")[] | undefined;
70
- priority?: number | undefined;
71
- lastModified?: string | undefined;
72
- } | undefined;
73
- _meta?: {
74
- [x: string]: unknown;
75
- } | undefined;
76
- } | {
77
- type: "image";
78
- data: string;
79
- mimeType: string;
80
- annotations?: {
81
- audience?: ("user" | "assistant")[] | undefined;
82
- priority?: number | undefined;
83
- lastModified?: string | undefined;
84
- } | undefined;
85
- _meta?: {
86
- [x: string]: unknown;
87
- } | undefined;
88
- } | {
89
- type: "audio";
90
- data: string;
91
- mimeType: string;
92
- annotations?: {
93
- audience?: ("user" | "assistant")[] | undefined;
94
- priority?: number | undefined;
95
- lastModified?: string | undefined;
96
- } | undefined;
97
- _meta?: {
98
- [x: string]: unknown;
99
- } | undefined;
100
- } | {
101
- uri: string;
102
- name: string;
103
- type: "resource_link";
104
- description?: string | undefined;
105
- mimeType?: string | undefined;
106
- size?: number | undefined;
107
- annotations?: {
108
- audience?: ("user" | "assistant")[] | undefined;
109
- priority?: number | undefined;
110
- lastModified?: string | undefined;
111
- } | undefined;
112
- _meta?: {
113
- [x: string]: unknown;
114
- } | undefined;
115
- icons?: {
116
- src: string;
117
- mimeType?: string | undefined;
118
- sizes?: string[] | undefined;
119
- theme?: "light" | "dark" | undefined;
120
- }[] | undefined;
121
- title?: string | undefined;
122
- } | {
123
- type: "resource";
124
- resource: {
125
- uri: string;
126
- text: string;
127
- mimeType?: string | undefined;
128
- _meta?: {
129
- [x: string]: unknown;
130
- } | undefined;
131
- } | {
132
- uri: string;
133
- blob: string;
134
- mimeType?: string | undefined;
135
- _meta?: {
136
- [x: string]: unknown;
137
- } | undefined;
138
- };
139
- annotations?: {
140
- audience?: ("user" | "assistant")[] | undefined;
141
- priority?: number | undefined;
142
- lastModified?: string | undefined;
143
- } | undefined;
144
- _meta?: {
145
- [x: string]: unknown;
146
- } | undefined;
147
- })[];
148
- _meta?: {
149
- [x: string]: unknown;
150
- progressToken?: string | number | undefined;
151
- "io.modelcontextprotocol/related-task"?: {
152
- taskId: string;
153
- } | undefined;
154
- } | undefined;
155
- structuredContent?: {
156
- [x: string]: unknown;
157
- } | undefined;
158
- isError?: boolean | undefined;
159
- } | {
160
- content: never[];
161
- structuredContent: {
162
- code: string;
163
- message: any;
164
- };
165
- }>;
166
- } | {
167
- name: string | undefined;
168
- inputSchema: import("zod").ZodObject<import("zod/v4/core").$ZodLooseShape, import("zod/v4/core").$strip> | undefined;
169
- outputSchema: import("zod").ZodObject<import("zod/v4/core").$ZodLooseShape, import("zod/v4/core").$strip> | undefined;
170
- handler(args: Input, extra: RequestHandlerExtra<ServerRequest, ServerNotification>): Promise<{
171
- [x: string]: unknown;
172
- content: ({
173
- type: "text";
174
- text: string;
175
- annotations?: {
176
- audience?: ("user" | "assistant")[] | undefined;
177
- priority?: number | undefined;
178
- lastModified?: string | undefined;
179
- } | undefined;
180
- _meta?: {
181
- [x: string]: unknown;
182
- } | undefined;
183
- } | {
184
- type: "image";
185
- data: string;
186
- mimeType: string;
187
- annotations?: {
188
- audience?: ("user" | "assistant")[] | undefined;
189
- priority?: number | undefined;
190
- lastModified?: string | undefined;
191
- } | undefined;
192
- _meta?: {
193
- [x: string]: unknown;
194
- } | undefined;
195
- } | {
196
- type: "audio";
197
- data: string;
198
- mimeType: string;
199
- annotations?: {
200
- audience?: ("user" | "assistant")[] | undefined;
201
- priority?: number | undefined;
202
- lastModified?: string | undefined;
203
- } | undefined;
204
- _meta?: {
205
- [x: string]: unknown;
206
- } | undefined;
207
- } | {
208
- uri: string;
209
- name: string;
210
- type: "resource_link";
211
- description?: string | undefined;
212
- mimeType?: string | undefined;
213
- size?: number | undefined;
214
- annotations?: {
215
- audience?: ("user" | "assistant")[] | undefined;
216
- priority?: number | undefined;
217
- lastModified?: string | undefined;
218
- } | undefined;
219
- _meta?: {
220
- [x: string]: unknown;
221
- } | undefined;
222
- icons?: {
223
- src: string;
224
- mimeType?: string | undefined;
225
- sizes?: string[] | undefined;
226
- theme?: "light" | "dark" | undefined;
227
- }[] | undefined;
228
- title?: string | undefined;
229
- } | {
230
- type: "resource";
231
- resource: {
232
- uri: string;
233
- text: string;
234
- mimeType?: string | undefined;
235
- _meta?: {
236
- [x: string]: unknown;
237
- } | undefined;
238
- } | {
239
- uri: string;
240
- blob: string;
241
- mimeType?: string | undefined;
242
- _meta?: {
243
- [x: string]: unknown;
244
- } | undefined;
245
- };
246
- annotations?: {
247
- audience?: ("user" | "assistant")[] | undefined;
248
- priority?: number | undefined;
249
- lastModified?: string | undefined;
250
- } | undefined;
251
- _meta?: {
252
- [x: string]: unknown;
253
- } | undefined;
254
- })[];
255
- _meta?: {
256
- [x: string]: unknown;
257
- progressToken?: string | number | undefined;
258
- "io.modelcontextprotocol/related-task"?: {
259
- taskId: string;
260
- } | undefined;
261
- } | undefined;
262
- structuredContent?: {
263
- [x: string]: unknown;
264
- } | undefined;
265
- isError?: boolean | undefined;
266
- } | {
267
- content: never[];
268
- structuredContent: {
269
- code: string;
270
- message: any;
271
- };
272
- }>;
273
- token: Type | AbstractType<any>;
274
- propertyKey: string | symbol;
275
- }>;
64
+ export declare function defineTool<Input, Output = undefined>(options: FnToolProps<Input, Output>): TokenProvider;
65
+ export declare function defineTool<Input, Output = undefined>(options: ClassToolProps<Input, Output>): TokenProvider;
276
66
  export {};
@@ -1,4 +1,6 @@
1
+ import type { ServerOptions } from "@modelcontextprotocol/sdk/server/index.js";
1
2
  import type { StreamableHTTPServerTransportOptions } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
3
+ import type { Implementation } from "@modelcontextprotocol/sdk/types.js";
2
4
  import type { TokenProvider } from "@tsed/di";
3
5
  /**
4
6
  * Configuration fragment accepted under `configuration.mcp` to wire the Platform MCP module.
@@ -23,12 +25,32 @@ export interface PlatformMcpSettings {
23
25
  * Optional version reported to MCP clients. Falls back to the Ts.ED app version.
24
26
  */
25
27
  version?: string;
28
+ /**
29
+ * Optional human-readable server title exposed to MCP clients.
30
+ */
31
+ title?: Implementation["title"];
32
+ /**
33
+ * Optional server description exposed to MCP clients.
34
+ */
35
+ description?: Implementation["description"];
36
+ /**
37
+ * Optional canonical website URL exposed to MCP clients.
38
+ */
39
+ websiteUrl?: Implementation["websiteUrl"];
40
+ /**
41
+ * Optional icon descriptors exposed to MCP clients.
42
+ */
43
+ icons?: Implementation["icons"];
26
44
  /**
27
45
  * Optional tokens registered through configuration.
28
46
  */
29
47
  tools?: TokenProvider[];
30
48
  resources?: TokenProvider[];
31
49
  prompts?: TokenProvider[];
50
+ /**
51
+ * Optional low-level MCP server options forwarded to `new McpServer(serverInfo, options)`.
52
+ */
53
+ serverOptions?: ServerOptions;
32
54
  /**
33
55
  * Optional transport options for the MCP server.
34
56
  */
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/platform-mcp",
3
3
  "description": "Model Context Protocol integration for Ts.ED HTTP adapters.",
4
4
  "type": "module",
5
- "version": "8.28.0",
5
+ "version": "8.28.2",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -19,22 +19,24 @@
19
19
  "build": "yarn barrels && yarn build:ts",
20
20
  "barrels": "barrels",
21
21
  "test": "vitest run",
22
+ "test:types": "tsc -p test/types/tsconfig.json",
22
23
  "build:ts": "tsc --build tsconfig.esm.json",
23
24
  "test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
24
25
  },
25
26
  "dependencies": {
26
27
  "@modelcontextprotocol/sdk": ">=1.29.0",
28
+ "change-case": ">=5.4.4",
27
29
  "tslib": ">=2.7.0",
28
30
  "uuid": ">=11.0.2",
29
31
  "zod": ">=4.0.0"
30
32
  },
31
33
  "devDependencies": {
32
- "@tsed/barrels": "8.28.0",
33
- "@tsed/core": "8.28.0",
34
- "@tsed/di": "8.28.0",
35
- "@tsed/platform-http": "8.28.0",
36
- "@tsed/schema": "8.28.0",
37
- "@tsed/typescript": "8.28.0",
34
+ "@tsed/barrels": "8.28.2",
35
+ "@tsed/core": "8.28.2",
36
+ "@tsed/di": "8.28.2",
37
+ "@tsed/platform-http": "8.28.2",
38
+ "@tsed/schema": "8.28.2",
39
+ "@tsed/typescript": "8.28.2",
38
40
  "eslint": "9.12.0",
39
41
  "typescript": "6.0.2",
40
42
  "vitest": "4.1.4"
@@ -1,6 +1,6 @@
1
1
  import {classOf} from "@tsed/core";
2
2
 
3
- import {definePrompt, type PromptProps} from "../fn/definePrompt.js";
3
+ import {type ClassPromptProps, definePrompt} from "../fn/definePrompt.js";
4
4
 
5
5
  /**
6
6
  * Options accepted by {@link Prompt} when decorating a class method. Matches {@link PromptProps} minus the handler reference.
@@ -8,7 +8,7 @@ import {definePrompt, type PromptProps} from "../fn/definePrompt.js";
8
8
  * @module platform/mcp
9
9
  * @since 8.17.0
10
10
  */
11
- export type PromptDecoratorOptions = Omit<PromptProps, "handler">;
11
+ export type PromptDecoratorOptions<Args = any> = Omit<ClassPromptProps<Args>, "token" | "propertyKey">;
12
12
 
13
13
  /**
14
14
  * Declares a Ts.ED class method as an MCP prompt and registers it through {@link definePrompt}.
@@ -27,10 +27,10 @@ export type PromptDecoratorOptions = Omit<PromptProps, "handler">;
27
27
  * }
28
28
  * ```
29
29
  */
30
- export function Prompt(options?: PromptDecoratorOptions) {
30
+ export function Prompt<Args = any>(options?: PromptDecoratorOptions<Args>) {
31
31
  return (target: any, propertyKey: string | symbol, _: PropertyDescriptor) => {
32
- definePrompt({
33
- ...(options as PromptProps),
32
+ definePrompt<Args>({
33
+ ...options,
34
34
  name: options?.name || String(propertyKey),
35
35
  token: classOf(target),
36
36
  propertyKey: propertyKey
@@ -2,7 +2,7 @@ import type {ResourceTemplate} from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import {classOf} from "@tsed/core";
3
3
  import {isString} from "@tsed/core/utils/isString.js";
4
4
 
5
- import {defineResource, type ResourceProps} from "../fn/defineResource.js";
5
+ import {type ClassResourceReadProps, type ClassResourceTemplateProps, defineResource} from "../fn/defineResource.js";
6
6
 
7
7
  /**
8
8
  * Options accepted by the {@link Resource} decorator beyond the handler binding fields, allowing callers to override metadata.
@@ -10,7 +10,7 @@ import {defineResource, type ResourceProps} from "../fn/defineResource.js";
10
10
  * @module platform/mcp
11
11
  * @since 8.17.0
12
12
  */
13
- export type ResourceDecoratorOptions = Omit<ResourceProps, "handler" | "uri" | "template">;
13
+ export type ResourceDecoratorOptions = Omit<ClassResourceReadProps, "token" | "propertyKey" | "uri">;
14
14
 
15
15
  /**
16
16
  * Decorator that turns a class method into an MCP resource backed by either a URI or a full {@link ResourceTemplate}.
@@ -32,13 +32,25 @@ export type ResourceDecoratorOptions = Omit<ResourceProps, "handler" | "uri" | "
32
32
  */
33
33
  export function Resource(uriOrTemplate: string | ResourceTemplate, options?: Partial<ResourceDecoratorOptions>) {
34
34
  return (target: any, propertyKey: string | symbol, _: PropertyDescriptor) => {
35
- defineResource({
36
- ...(options as ResourceProps),
35
+ const base = {
36
+ ...options,
37
37
  name: options?.name || String(propertyKey),
38
38
  token: classOf(target),
39
- propertyKey,
40
- uri: isString(uriOrTemplate) ? uriOrTemplate : undefined,
41
- template: !isString(uriOrTemplate) ? uriOrTemplate : undefined
42
- } as any);
39
+ propertyKey
40
+ };
41
+
42
+ if (isString(uriOrTemplate)) {
43
+ defineResource({
44
+ ...base,
45
+ uri: uriOrTemplate
46
+ } satisfies ClassResourceReadProps);
47
+
48
+ return;
49
+ }
50
+
51
+ defineResource({
52
+ ...base,
53
+ template: uriOrTemplate
54
+ } satisfies ClassResourceTemplateProps);
43
55
  };
44
56
  }