From 5725802d838b428f4e5cf85a624ec39bfed28ac0 Mon Sep 17 00:00:00 2001 From: corvid-agent <0xOpenBytes@gmail.com> Date: Fri, 20 Feb 2026 10:02:07 -0700 Subject: [PATCH] fix(core): allow additional JSON Schema properties in elicitInput requestedSchema Add .catchall(z.unknown()) to the requestedSchema object type in ElicitRequestFormParamsSchema, matching the existing pattern used by inputSchema and outputSchema. This fixes a type incompatibility when passing Zod v4's .toJSONSchema() output (which includes $schema, additionalProperties, etc.) to elicitInput's requestedSchema parameter. Fixes #1362 Co-Authored-By: Claude Opus 4.6 --- .changeset/zod-json-schema-compat.md | 5 +++++ packages/core/src/types/types.ts | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changeset/zod-json-schema-compat.md 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()) }); /**