Skip to content

Commit caed2d5

Browse files
fix: update zod type imports and inference for v4 compatibility
Replace removed/renamed types with v4 equivalents: - AnyZodObject → ZodObject<any> - z.objectOutputType<> → z.infer<ZodObject<>> - Remove ZodTypeDef import (will be addressed with PromptArgsRawShape fix) This resolves 4 compilation errors (Category B & C).
1 parent 9c5d1d6 commit caed2d5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/server/mcp.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Server, ServerOptions } from './index.js';
2-
import { z, ZodRawShape, ZodObject, ZodString, AnyZodObject, ZodTypeAny, ZodType, ZodTypeDef, ZodOptional } from 'zod';
2+
import { z, ZodRawShape, ZodObject, ZodString, ZodTypeAny, ZodType, ZodOptional } from 'zod';
33
import {
44
Implementation,
55
Tool,
@@ -1008,16 +1008,16 @@ export class ResourceTemplate {
10081008
*/
10091009
export type ToolCallback<Args extends undefined | ZodRawShape = undefined> = Args extends ZodRawShape
10101010
? (
1011-
args: z.objectOutputType<Args, ZodTypeAny>,
1011+
args: z.infer<ZodObject<Args>>,
10121012
extra: RequestHandlerExtra<ServerRequest, ServerNotification>
10131013
) => CallToolResult | Promise<CallToolResult>
10141014
: (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => CallToolResult | Promise<CallToolResult>;
10151015

10161016
export type RegisteredTool = {
10171017
title?: string;
10181018
description?: string;
1019-
inputSchema?: AnyZodObject;
1020-
outputSchema?: AnyZodObject;
1019+
inputSchema?: ZodObject<any>;
1020+
outputSchema?: ZodObject<any>;
10211021
annotations?: ToolAnnotations;
10221022
_meta?: Record<string, unknown>;
10231023
callback: ToolCallback<undefined | ZodRawShape>;
@@ -1138,7 +1138,7 @@ type PromptArgsRawShape = {
11381138

11391139
export type PromptCallback<Args extends undefined | PromptArgsRawShape = undefined> = Args extends PromptArgsRawShape
11401140
? (
1141-
args: z.objectOutputType<Args, ZodTypeAny>,
1141+
args: z.infer<ZodObject<Args>>,
11421142
extra: RequestHandlerExtra<ServerRequest, ServerNotification>
11431143
) => GetPromptResult | Promise<GetPromptResult>
11441144
: (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => GetPromptResult | Promise<GetPromptResult>;

0 commit comments

Comments
 (0)