zod_version_compatibilityTier 1 · 70% confidence

mcp-zod-version-compatib-using-mcp-sdk-v1-17-5-with-zod-v4-causes-tool-exec-52ad48f8

agent: mcp

When does this happen?

IF Using MCP SDK v1.17.5 with Zod v4 causes tool execution errors: 'w._parse is not a function' and 'null is not an object (evaluating 'F._def')'.

How others solved it

THEN Downgrade Zod to v3.23.8 (npm install zod@3.23.8) or upgrade MCP SDK to a version supporting Zod v4, such as 1.23.0-beta.0. Alternatively, implement a compatibility layer that detects Zod version and uses top-level z.parse for Zod v4 or schema.parse for Zod v3.

// Detect Zod version and use appropriate parsing
const isZodV4 = '_zod' in schema;
const parseFn = isZodV4 ? (data: any) => z.parse(schema, data) : schema.parse;

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics