Skip to content

Commit e5b1274

Browse files
travisbreaksclaude
andcommitted
fix: widen elicitInput requestedSchema type to accept Zod's toJSONSchema output
Zod v4's `.toJSONSchema()` produces standard JSON Schema output that includes fields like `$schema` and `additionalProperties`. The `requestedSchema` type in `ElicitRequestFormParams` was too narrow to accept these extra fields, forcing users to cast through `unknown`. This adds `.passthrough()` to the Zod runtime schema and an index signature to the spec type, allowing any additional JSON Schema fields through while keeping the required fields (`type`, `properties`) strictly typed. Fixes #1362 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ccb78f2 commit e5b1274

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/core': patch
3+
---
4+
5+
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()`.

packages/core/src/types/spec.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,6 +2795,7 @@ export interface ElicitRequestFormParams extends TaskAugmentedRequestParams {
27952795
* Only top-level properties are allowed, without nesting.
27962796
*/
27972797
requestedSchema: {
2798+
[key: string]: unknown;
27982799
$schema?: string;
27992800
type: 'object';
28002801
properties: {

packages/core/src/types/types.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,11 +2024,13 @@ export const ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.ex
20242024
* A restricted subset of JSON Schema.
20252025
* Only top-level properties are allowed, without nesting.
20262026
*/
2027-
requestedSchema: z.object({
2028-
type: z.literal('object'),
2029-
properties: z.record(z.string(), PrimitiveSchemaDefinitionSchema),
2030-
required: z.array(z.string()).optional()
2031-
})
2027+
requestedSchema: z
2028+
.object({
2029+
type: z.literal('object'),
2030+
properties: z.record(z.string(), PrimitiveSchemaDefinitionSchema),
2031+
required: z.array(z.string()).optional()
2032+
})
2033+
.passthrough()
20322034
});
20332035

20342036
/**

0 commit comments

Comments
 (0)