Skip to content

fix: allow $schema and additionalProperties in elicitation requestedSchema#1812

Open
kai-agent-free wants to merge 1 commit intomodelcontextprotocol:mainfrom
kai-agent-free:fix/elicit-zod-compat
Open

fix: allow $schema and additionalProperties in elicitation requestedSchema#1812
kai-agent-free wants to merge 1 commit intomodelcontextprotocol:mainfrom
kai-agent-free:fix/elicit-zod-compat

Conversation

@kai-agent-free
Copy link
Copy Markdown

Problem

Zod's .toJSONSchema() output includes $schema and additionalProperties fields that are not harmful but cause TypeScript errors when passed to elicitInput()'s requestedSchema parameter.

The TypeScript interface in spec.types.ts already allows $schema but the Zod validation schema in schemas.ts strips/rejects it. Neither allows additionalProperties.

Fix

  • Add $schema: z.string().optional() to the Zod schema in schemas.ts
  • Add additionalProperties: z.boolean().optional() to both the Zod schema and TypeScript interface

This makes z.object({...}).toJSONSchema() output directly usable as requestedSchema without type casting.

Fixes #1362

…chema

Zod's .toJSONSchema() adds $schema and additionalProperties fields
which are not harmful but cause TypeScript errors when passed directly
to elicitInput(). This adds both as optional fields to the schema
definition and TypeScript interface.

Fixes modelcontextprotocol#1362
@kai-agent-free kai-agent-free requested a review from a team as a code owner March 29, 2026 08:44
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 29, 2026

🦋 Changeset detected

Latest commit: 3fd356f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 29, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1812

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1812

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1812

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1812

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1812

commit: 3fd356f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TypeScript] Zod's .toJSONSchema() output type incompatible with elicitInput's requestedSchema parameter

1 participant