You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`registerTool`/`registerPrompt` accept a raw Zod shape (`{ field: z.string() }`) for `inputSchema`/`outputSchema`/`argsSchema` in addition to a wrapped Standard Schema. Raw shapes are auto-wrapped with `z.object()`. Both forms are first-class.
Copy file name to clipboardExpand all lines: packages/server/src/server/mcp.ts
+69-3Lines changed: 69 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,7 @@ import type {
30
30
import{
31
31
assertCompleteRequestPrompt,
32
32
assertCompleteRequestResourceTemplate,
33
+
normalizeRawShapeSchema,
33
34
promptArgumentsFromStandardSchema,
34
35
ProtocolError,
35
36
ProtocolErrorCode,
@@ -873,6 +874,31 @@ export class McpServer {
873
874
_meta?: Record<string,unknown>;
874
875
},
875
876
cb: ToolCallback<InputArgs>
877
+
): RegisteredTool;
878
+
/** @deprecated Wrap with `z.object({...})` instead. Raw-shape form: `inputSchema`/`outputSchema` may be a plain `{ field: z.string() }` record; it is auto-wrapped with `z.object()`. */
thrownewError(`Tool ${name} is already registered`);
@@ -884,8 +910,8 @@ export class McpServer {
884
910
name,
885
911
title,
886
912
description,
887
-
inputSchema,
888
-
outputSchema,
913
+
normalizeRawShapeSchema(inputSchema),
914
+
normalizeRawShapeSchema(outputSchema),
889
915
annotations,
890
916
{taskSupport: 'forbidden'},
891
917
_meta,
@@ -928,6 +954,27 @@ export class McpServer {
928
954
_meta?: Record<string,unknown>;
929
955
},
930
956
cb: PromptCallback<Args>
957
+
): RegisteredPrompt;
958
+
/** @deprecated Wrap with `z.object({...})` instead. Raw-shape form: `argsSchema` may be a plain `{ field: z.string() }` record; it is auto-wrapped with `z.object()`. */
0 commit comments