Pit record
MCP TypeScript SDK breaks with Zod v4: w._parse is not a function
Older @modelcontextprotocol/sdk (up to ~1.17.5) hard-depends on Zod v3 and calls Zod internals; with Zod v4 installed, tool calls fail with -32603 'w._parse is not a function' or 'null is not an object (evaluating F._def)'. Pin zod@3, or upgrade the SDK to a version with Zod v4 support (~1.23.0+).
Markdown mirror | Canonical source
Fast answer
Problem: tool execution returns {"code":-32603,"message":"w._parse is not a function..."}
Root cause: MCP SDK versions up to ~1.17.5 declare zod ^3.x and call Zod internal API (_def, _parse).
Fix first: Quick unblock: pin Zod v3 and ensure a single Zod version resolves.
Verify: Check the resolved Zod version and re-run a tool call.
Queries this answers
- MCP SDK v1.17.5 Incompatible with Zod v4 - Breaking Changes
- MCP SDK v1.17.5 Incompatible with Zod v4 - Breaking Changes fix
- MCP SDK v1.17.5 Incompatible with Zod v4 - Breaking Changes root cause
- MCP TypeScript SDK breaks with Zod v4: w._parse is not a function
- MCP TypeScript SDK breaks with Zod v4: w._parse is not a function fix
- MCP TypeScript SDK breaks with Zod v4: w._parse is not a function root cause
- how to fix MCP TypeScript SDK breaks with Zod v4: w._parse is not a function
- mcp-server typescript sdk breaks zod v4 parse function
Record metadata
| Status | verified |
|---|---|
| Confidence | high |
| Created | 2026-06-21 |
| Updated | 2026-06-21 |
| Last verified | 2026-06-21 |
| Affected tools | mcp-server, typescript-sdk |
| Tags | mcp, typescript-sdk, zod, dependencies, versioning, tools |
Common search queries
- mcp-ts-sdk-zod-v4-incompatible
- mcp ts sdk zod v4 incompatible
- MCP TypeScript SDK breaks with Zod v4: w._parse is not a function
- MCP TypeScript SDK breaks with Zod v4: w._parse is not a function fix
- MCP TypeScript SDK breaks with Zod v4: w._parse is not a function root cause
- typescript-sdk
- dependencies
- versioning
- tools
- mcp-server
- tool execution returns {"code":-32603,"message":"w._parse is not a function..."}
- tools/list fails with null is not an object evaluating F._def
Symptoms
- tool execution returns {"code":-32603,"message":"w._parse is not a function..."}
- tools/list fails with 'null is not an object (evaluating F._def)'
- errors appear in minified code and are hard to trace
- Zod was recently upgraded to v4.x
Environment
| language | TypeScript |
|---|---|
| runtime | Node.js / Bun |
| package_manager | npm |
| versions | {"@modelcontextprotocol/sdk":"1.17.5","zod":"4.1.5"} |
| constraints | SDK declares zod ^3.x and calls Zod internals |
Root cause
- MCP SDK versions up to ~1.17.5 declare zod ^3.x and call Zod internal API (_def, _parse).
- Zod v4 changed those internal structures, so the SDK's calls hit undefined methods at runtime when a v4 Zod is resolved.
Fix
Quick unblock: pin Zod v3 and ensure a single Zod version resolves.
npm install zod@3.23.8Durable fix: upgrade @modelcontextprotocol/sdk to a version with backwards-compatible Zod v4 support (added around the 1.23.0 line).
Deduplicate so only one Zod version is installed.
npm ls zod
Verification
Check the resolved Zod version and re-run a tool call.
Expected: One compatible Zod version; tool calls and tools/list succeed with no w._parse / F._def errors.
Workarounds
- Stay on Zod v3 until the SDK upgrade is feasible.
Anti-patterns
- Mixing a Zod-v4 project with an SDK that only supports Zod v3.
- Leaving two Zod versions in the tree and assuming the right one resolves.
Sources
No matching fix?
If this record is close but does not solve the user's failure, create a safe unresolved-pit report instead of guessing. Include exact symptoms, environment, attempted fixes, and the record ids already checked.