From b37543ef053adcbdc0bd00d244e017230ec337c4 Mon Sep 17 00:00:00 2001 From: corvid-agent <0xOpenBytes@gmail.com> Date: Thu, 26 Mar 2026 16:13:01 +0000 Subject: [PATCH] fix(core): allow additional JSON Schema properties in elicitInput requestedSchema Adds .catchall(z.unknown()) to requestedSchema, matching the pattern used by inputSchema/outputSchema. Fixes type incompatibility when using Zod v4's .toJSONSchema() output which includes extra properties like $schema and additionalProperties. Fixes #1362 --- .changeset/zod-json-schema-compat.md | 5 +++++ packages/core/src/types/schemas.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/schemas.ts b/packages/core/src/types/schemas.ts index 1c0e6086d..85854e69a 100644 --- a/packages/core/src/types/schemas.ts +++ b/packages/core/src/types/schemas.ts @@ -1855,11 +1855,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()) }); /**