inputSchema with ZodRawShape
Closed this issue · 6 comments
I am using the latest release 1.17.3.
I registered a tool as below
server.registerTool(
"get_file_contents",
{
title: "Fetch File Content",
description: "Fetches the content of a file from either Github or Gitea, given repository details and authentication token.",
inputSchema: {
url: z.string().describe("The base URL of the repository (Github or Gitea)."),
token: z.string().describe("Authentication token for the repository."),
branch: z.string().describe("The branch name to fetch the file from."),
owner: z.string().describe("The owner of the repository."),
repo: z.string().describe("The name of the repository."),
path: z.string().describe("The path to the file within the repository.")
}
},
...
Well, as registerTool expects an inputSchema as ZodRawShape, my given code should work. But in this case, the following error appeared by each property of inputSchema:
Type 'ZodString' is missing the following properties from type 'ZodType<any, any, any>': _type, _parse, _getType, _getOrReturnCtx, and 7 more.ts(2740)
types.d.cts(14, 5): The expected type comes from this index signature.
Any tip or help is much appreciated!
use zod v3; faced the same error but v3 solved it
I use Zod V3 (3.25.76) also. What did you mean "v3 solved it"? :-)
I mean is there a way for you to explicitly infer zod/v3, in your import..
I actually use zod 4.0.17
But i inferred
import z from "zod/v3";
in the MCP tooling script
And the error disappeared
Thank you for your hint @MyRichard12 !
I mean is there a way for you to explicitly infer zod/v3, in your import..
I actually use zod 4.0.17
But i inferred
import z from "zod/v3";in the MCP tooling scriptAnd the error disappeared
Thanks. It helped me.
Looks like this has been resolved thanks @MyRichard12 for responding here.