diff --git a/.changeset/widen-elicit-requested-schema.md b/.changeset/widen-elicit-requested-schema.md new file mode 100644 index 000000000..c0447b082 --- /dev/null +++ b/.changeset/widen-elicit-requested-schema.md @@ -0,0 +1,5 @@ +--- +'@modelcontextprotocol/core': patch +--- + +Widen `requestedSchema` type in `ElicitRequestFormParams` to accept additional JSON Schema fields (e.g., `$schema`, `additionalProperties`) that tools like Zod's `.toJSONSchema()` produce. This removes the need for users to cast through `unknown` when passing Zod-generated schemas to `elicitInput()`. diff --git a/packages/core/src/types/spec.types.ts b/packages/core/src/types/spec.types.ts index f36434bef..89bacc20d 100644 --- a/packages/core/src/types/spec.types.ts +++ b/packages/core/src/types/spec.types.ts @@ -2795,6 +2795,7 @@ export interface ElicitRequestFormParams extends TaskAugmentedRequestParams { * Only top-level properties are allowed, without nesting. */ requestedSchema: { + [key: string]: unknown; $schema?: string; type: 'object'; properties: { diff --git a/packages/core/src/types/types.ts b/packages/core/src/types/types.ts index 6ac79777b..76929ab95 100644 --- a/packages/core/src/types/types.ts +++ b/packages/core/src/types/types.ts @@ -2024,11 +2024,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() + }) + .passthrough() }); /**