Repository navigation
Fix serialization of annotated content blocks in tool results - #2013
Open
pbuffolino wants to merge 1 commit into
Open
pbuffolino wants to merge 1 commit into
pbuffolino wants to merge 1 commit into
Conversation
ContentBlock.Converter.CreateNestedOptions added McpJsonUtilities.JsonContext.Default to a copy of the caller's options unconditionally. When the caller's resolver is already that context, as it is when the server writes a CallToolResult, System.Text.Json throws and the tool call fails with -32603. Skip the add in that case. Fixes modelcontextprotocol#2012 Co-Authored-By: Claude Fable 5.2 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2012.
ContentBlock.Converter.CreateNestedOptionscopies the caller's options and always addsMcpJsonUtilities.JsonContext.Defaultto the copy's resolver chain. When the caller's resolver is already that context, which is the case when the server writes aCallToolResult, System.Text.Json refuses the add and the tool call fails with-32603.This skips the add in that one case. Other callers behave as before.
Tests
Two client/server tests in
McpServerToolAnnotatedContentTests:Both fail on
mainwith the exception from the issue and pass with the change. The second one covers icons because they go through the same helper.What I ran
Only
net10.0, on macOS.tests/ModelContextProtocol.Tests: 3676 passed, 5 skipped, 1 failed. The failure isDockerEverythingServerTests.Sampling_Sse_EverythingServer("Unknown tool: trigger-sampling-request"), and it fails the same way without this change.tests/ModelContextProtocol.AspNetCore.Tests: 754 passed, 45 skipped.Note
This PR was prepared with AI assistance (Claude Code). I reviewed the change and the test results before opening it.