Skip to content

Conversation

@jeffhandley
Copy link
Collaborator

Fixes #955 - Skip unexpected properties when deserializing ContentBlock

Motivation and Context

This issue was encountered and reported by a colleague working with a server that returned data in an old/unexpected structure.

How Has This Been Tested?

Repro console app and a failing unit test were created. The new tests now succeed.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

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

@jeffhandley jeffhandley force-pushed the jeffhandley/structuredcontent-parse-failure branch from 2b15f2c to 019075c Compare November 9, 2025 04:21
@jeffhandley
Copy link
Collaborator Author

@stephentoub / @eiriktsarpalis - After fixing the reported case, Copilot and I looked at all other JsonConverter<T> implementations and found several others where we're not skipping unknown props. It seemed to me we should be defensive in all of these cases, but I wasn't sure if it would be more appropriate to throw an InvalidDataException in any of these cases.

While looking through this, Copilot found that Reference.Title was getting dropped on the floor too.

All of these extra fixes are in a separate commit from the original fix, in case you think we should drop the auxiliary changes.

@jeffhandley jeffhandley merged commit d4ee787 into modelcontextprotocol:main Nov 9, 2025
5 of 7 checks passed
@jeffhandley jeffhandley deleted the jeffhandley/structuredcontent-parse-failure branch November 9, 2025 09:01
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.

CallToolResult deserialization fails when content block contains unexpected properties

2 participants