Commit 2cfd6f7
committed
fix: ensure tool inputSchema includes type: "object" for non-object Zod schemas
z.toJSONSchema() on z.discriminatedUnion() produces { oneOf: [...] }
without a top-level type field. The MCP protocol requires
inputSchema.type === "object" (spec.types.ts), so clients that
validate the tools/list response reject discriminated union schemas.
Since discriminated unions are always unions of object types (each
variant shares a discriminator key), type: "object" is semantically
correct at the top level. Spreading it before the schema output
is a no-op for z.object() (already has type) and adds the required
field for unions, intersections, etc.
Fixes: #16431 parent 8cdb4bb commit 2cfd6f7
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
0 commit comments