Skip to content

Incompatible with Zod 4 #107

@shihangw

Description

@shihangw

Description

When using Zod schemas with server.tool(), the tools/list response returns empty properties: {} in the inputSchema instead of the actual schema properties. This suggests the package is missing Zod-to-JSON-Schema conversion logic.

Minimal Reproduction Code

// app/api/[transport]/route.ts  
import { createMcpHandler } from "mcp-handler";  
import { z } from "zod";  
  
const handler = createMcpHandler(  
  (server) => {  
    server.tool(  
      "test_tool",  
      "Test tool with Zod schema",  
      {  
        name: z.string().describe("A name parameter"),  
        count: z.number().min(1).max(10).describe("A count parameter")  
      },  
      async ({ name, count }) => ({  
        content: [{ type: "text", text: `Hello ${name}, count: ${count}` }]  
      })  
    );  
  },  
  {},  
  { basePath: "/api" }  
);  
  
export { handler as GET, handler as POST };

Expected Behavior

The tools/list response should show schema like this:

{
"inputSchema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "A name parameter"
},
"count": {
"type": "number",
"minimum": 1,
"maximum": 10,
"description": "A count parameter"
}
},
"required": ["name", "count"]
}
}

Actual Behavior

The tools/list response actually like this:

event: message
data: {"result":{"tools":[{"name":"test_tool","description":"Test tool with Zod schema","inputSchema":{"type":"object","properties":{},"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}]},"jsonrpc":"2.0","id":1}

Environment

"mcp-handler": "1.0.2",
"zod": "4.1.9"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions