-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Because of the way prompt arguments are constructed from Zod 4 schemas, there is currently no way to mark them as optional.
To Reproduce
Steps to reproduce the behavior:
- Create an mcp server
- Register a prompt and add a Zod 4 defined optional field to it's
argsSchema - When testing the response from the server, it will be marked as
required: true
I will also link a branch/MR with a commit testing this behaviour in unit test.
Expected behavior
Fields defined as optional should not be presented as required on the MCP interface.
Additional context
I've looked into the code causing this, I'm pretty sure it's src/server/zod-compat.ts:241. There, specifically for the v4 branch, typeName is checked on the _def object, however Zod v4 has no typeName property. It should probably be replaced with .type === "optional" (and the ZodV4Internal type should be adjusted as well).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working