Skip to content

Conversation

@mattzcarey
Copy link
Contributor

@mattzcarey mattzcarey commented Dec 1, 2025

Add z.preprocess to convert null values to undefined in the content field of ElicitResultSchema for better leniency while maintaining type compatibility.

Per MCP spec, content is typically omitted for decline/cancel actions but shouldn't error out for null values.

From the spec:

The three response actions are:

Accept (action: "accept"): User explicitly approved and submitted with data
- For form mode: The content field contains the submitted data matching the requested schema
- For URL mode: The content field is omitted
- Example: User clicked “Submit”, “OK”, “Confirm”, etc.

Decline (action: "decline"): User explicitly declined the request
- The content field is typically omitted
- Example: User clicked “Reject”, “Decline”, “No”, etc.

Cancel (action: "cancel"): User dismissed without making an explicit choice
- The content field is typically omitted
- Example: User closed the dialog, clicked outside, pressed Escape, browser failed to load, etc.

Motivation and Context

How Has This Been Tested?

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Add z.preprocess to convert null values to undefined in the content field of ElicitResultSchema for better leniency while maintaining type compatibility. Per MCP spec, content is typically omitted for decline/cancel actions.
@mattzcarey mattzcarey requested a review from a team as a code owner December 1, 2025 16:39
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 1, 2025

Open in StackBlitz

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

commit: d6adb78

@mattzcarey
Copy link
Contributor Author

mattzcarey commented Dec 1, 2025

Fixes the issue which was originally noted here: #967

Closes #966

@mattzcarey mattzcarey enabled auto-merge (squash) December 1, 2025 17:01
@mattzcarey mattzcarey merged commit a6ee2cb into main Dec 1, 2025
10 checks passed
@mattzcarey mattzcarey deleted the fix-normalised-elitication-content branch December 1, 2025 17:02
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.

3 participants