Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/fix-elicit-json-schema-compat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@modelcontextprotocol/sdk": patch
---

Widen `requestedSchema` type in `elicitInput()` to accept standard JSON Schema output from generators like Zod's `.toJSONSchema()`.

Added `additionalProperties` as an explicit optional field and an index signature `[key: string]: unknown` to allow extra JSON Schema fields (e.g., `$schema`, `additionalProperties`) that schema generators commonly produce. Also added `.passthrough()` to the Zod validation schema so these extra fields are preserved at runtime.

Fixes modelcontextprotocol/typescript-sdk#1362
6 changes: 6 additions & 0 deletions packages/core/src/types/spec.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,8 @@ export interface Tool extends BaseMetadata, Icons {
type: 'object';
properties?: { [key: string]: JSONValue };
required?: string[];
additionalProperties?: boolean | { [key: string]: unknown };
[key: string]: unknown;
};

/**
Expand All @@ -1759,6 +1761,8 @@ export interface Tool extends BaseMetadata, Icons {
type: 'object';
properties?: { [key: string]: JSONValue };
required?: string[];
additionalProperties?: boolean | { [key: string]: unknown };
[key: string]: unknown;
};

/**
Expand Down Expand Up @@ -2801,6 +2805,8 @@ export interface ElicitRequestFormParams extends TaskAugmentedRequestParams {
[key: string]: PrimitiveSchemaDefinition;
};
required?: string[];
additionalProperties?: boolean | { [key: string]: unknown };
[key: string]: unknown;
};
}

Expand Down
13 changes: 8 additions & 5 deletions packages/core/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2024,11 +2024,14 @@ 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(),
additionalProperties: z.union([z.boolean(), z.record(z.string(), z.unknown())]).optional()
})
.passthrough()
});

/**
Expand Down
Loading