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
Agreed! As temporary workaround you can use old version of zod in mcp declarations, just add it to package.json and install packages:
"mcp-zod": "npm:zod@3.25.76"
and use it in your declarations:
// import { z } from "zod";import{zasmcpZod}from"mcp-zod";constz=mcpZodasunknownastypeofimport("zod").z;mcpServer.registerTool("roll_dice",{description: "Rolls an N-sided die",inputSchema: {sides: z.number().int().min(2).describe("The number of sides on the die"),},},async({ sides })=>{constvalue=1+Math.floor(Math.random()*sides);return{content: [{type: "text",text: `🎲 You rolled a ${value}!`}],};},);
import{z}from"zod/v3";// More codeserver.tool("filter_character_by_name","Filter a specific character using the character?params endpoint.",{name: z.string().describe("Character name"),},async(args)=>{// 68 lines of code 👀});
Reacted by Alexandre Djerbetian, Adam DeHaven and Rimvydas Naktinis
import{zasmcpZod}from"mcp-zod";constz=mcpZodasunknownastypeofimport("zod").z;// More codeserver.tool("filter_character_by_name","Filter a specific character using the character?params endpoint.",{name: z.string().describe("Character name"),},async(args)=>{// More code});
To the maintainers: if you haven't already, I recommend checking out the Library Authors guide for best practices around peer dependencies and accepting user-defined schemas: https://zod.dev/library-authors
Reacted by Nils 🧮, Vitaly Iegorov and Matthew Gamble
I noticed this library is importing from zod. Until v4 schemas are fully supported, can you at least import from zod/v3 so that people can install v3 or v4 in their own project if they want.
Reacted by RaphaelEscrig, Vitaly Iegorov, Jacob Lauritzen and Ali
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import * as z from 'zod/v3';
const server = new McpServer(mcpServerOptions.serverInfo);
server.tool(
"tool_name",
"tool_description",
{ text: z.string().describe('text_description') },
async (args) => { /* executefunction */ }
);
I have tried changing that 3rd parameter to:
z.object({ text: z.string().describe('text_description') }) -> No overload matches this call. ... Argument of type 'string' is not assignable to parameter of type 'ZodRawShape'.
zodown(z.object({ text: z.string().describe('text_description') })) (with zodown installed) -> same
z.object({ text: z.string().describe('text_description') }).shape -> Type instantiation is excessively deep and possibly infinite.
z.toJSONSchema(z.object({ text: z.string().describe('text_description') })) (with zod 4) -> gives no TS error but input schema becomes empty and request body isn't passed to the tool.
I have tried changing zod import, and even tried to installing zod v3 separately with npm install mcp-zod@npm:zod@3.23.8:
import * as z from 'zod';
import * as z from 'zod/v3';
import { z } from 'zod/v3';
import import { z as mcpZod } from "mcp-zod";
Nothing works. Do you have any suggestions except downgrading zod completely?
Reacted by Ali, Stephane Bischoff, juhsoin, Samuel Pérez, jacksonneal, Alexandre Djerbetian and Adam DeHaven
Hey MCP team! Is there an update regarding the zod v4 support?
Reacted by Stephane Bischoff, Matthew Gamble, Ander Gorostiza, Swastik Kulshreshtha, Rikus Louw, juhsoin, Sam, Samuel Pérez, knifeyspoony, Ondrej Synacek and 8 more
Hi! we just shipped a beta release adding backwards compatible support for zod v4 - if you'd like to try it we're keen for feedback to make sure this works well!
Does the latest version on NPM (1.25.1) support zod v4? @felixweinberger
Hi! we just shipped a beta release adding backwards compatible support for zod v4 - if you'd like to try it we're keen for feedback to make sure this works well!
Activity
orlov-vo commentedon Aug 30, 2025
Agreed! As temporary workaround you can use old version of
zodin mcp declarations, just add it to package.json and install packages:and use it in your declarations:
Karljoy973 commentedon Aug 31, 2025
Im not sure they allow the use of zod 4 as it might create some breaking changes.
tmkn commentedon Sep 1, 2025
@developermau you can import Zod 3 via
import { z } from "zod/v3";from a Zod 4 versiondevelopermau commentedon Sep 2, 2025
Thanks @tmkn ! I tried it (
import { z } from "zod/v3";). However, I have another error:Type instantiation is excessively deep and possibly infinite..Part of the code:
developermau commentedon Sep 2, 2025
Thanks @orlov-vo ! It works!
Part of the code:
justin-schroeder commentedon Sep 4, 2025
I just released this to help this exact problem: https://zodown.com/
colinhacks commentedon Sep 11, 2025
To the maintainers: if you haven't already, I recommend checking out the Library Authors guide for best practices around peer dependencies and accepting user-defined schemas: https://zod.dev/library-authors
tmkn commentedon Sep 12, 2025
@colinhacks can confirm, with the latest zod version, the
Type instantiation is excessively deep and possibly infinite.error is gonegkurt commentedon Sep 16, 2025
I noticed this library is importing from
zod. Until v4 schemas are fully supported, can you at least import fromzod/v3so that people can install v3 or v4 in their own project if they want.Crustan commentedon Oct 2, 2025
How did you guys get this to work? I'm still getting
Type instantiation is excessively deep and possibly infinite.I'm using:
I'm setting up my server like this:
I have tried changing that 3rd parameter to:
z.object({ text: z.string().describe('text_description') })->No overload matches this call. ... Argument of type 'string' is not assignable to parameter of type 'ZodRawShape'.zodown(z.object({ text: z.string().describe('text_description') }))(withzodowninstalled) -> samez.object({ text: z.string().describe('text_description') }).shape->Type instantiation is excessively deep and possibly infinite.z.toJSONSchema(z.object({ text: z.string().describe('text_description') }))(with zod 4) -> gives no TS error but input schema becomes empty and request body isn't passed to the tool.I have tried changing zod import, and even tried to installing zod v3 separately with
npm install mcp-zod@npm:zod@3.23.8:Nothing works. Do you have any suggestions except downgrading zod completely?
luisvinicius09 commentedon Oct 9, 2025
I've also done everything mentioned by Crustan above and could not get it working.
Any help would be great.
codeXLinkX commentedon Oct 22, 2025
Hey MCP team! Is there an update regarding the zod v4 support?
felixweinberger commentedon Nov 21, 2025
Hi! we just shipped a beta release adding backwards compatible support for zod v4 - if you'd like to try it we're keen for feedback to make sure this works well!
josealvarez97 commentedon Dec 21, 2025
Does the latest version on NPM (1.25.1) support zod v4? @felixweinberger
fix: bump @modelcontextprotocol/sdk min to ^1.23.0 for Zod 4 support
remigermain commentedon Jun 17, 2026
if someone have the probleme (from 1.29) , you can change type in mcpServer definition: