diff --git a/.changeset/zod-json-schema-compat.md b/.changeset/zod-json-schema-compat.md new file mode 100644 index 000000000..5ca1470e8 --- /dev/null +++ b/.changeset/zod-json-schema-compat.md @@ -0,0 +1,5 @@ +--- +'@modelcontextprotocol/core': patch +--- + +Allow additional JSON Schema properties in elicitInput's requestedSchema type by adding .catchall(z.unknown()), matching the pattern used by inputSchema. This fixes type incompatibility when using Zod v4's .toJSONSchema() output which includes extra properties like $schema and additionalProperties. diff --git a/packages/core/src/types/types.ts b/packages/core/src/types/types.ts index 2a79944b9..74bd67fe7 100644 --- a/packages/core/src/types/types.ts +++ b/packages/core/src/types/types.ts @@ -1993,11 +1993,13 @@ export const ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.ex * A restricted subset of JSON Schema. * Only top-level properties are allowed, without nesting. */ - requestedSchema: z.object({ - type: z.literal('object'), - properties: z.record(z.string(), PrimitiveSchemaDefinitionSchema), - required: z.array(z.string()).optional() - }) + requestedSchema: z + .object({ + type: z.literal('object'), + properties: z.record(z.string(), PrimitiveSchemaDefinitionSchema), + required: z.array(z.string()).optional() + }) + .catchall(z.unknown()) }); /**