Repository navigation
Conversation
ToAIContent(ResourceContents) records the resource's URI in AdditionalProperties["uri"], but ToAIContent(ContentBlock) then assigned the block's _meta to AdditionalProperties, replacing that dictionary. An EmbeddedResourceBlock without _meta therefore lost its URI entirely, and one with _meta kept only the _meta entries. This has been the case since modelcontextprotocol#976 started copying block _meta into AdditionalProperties. Merge the block's _meta into the existing properties instead. When a _meta entry has the same key as a property the conversion set itself, the conversion's value wins, since it describes the content directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
ToAIContent(ResourceContents)stores the resource URI inAdditionalProperties["uri"].ToAIContent(ContentBlock)calls it for anEmbeddedResourceBlock, then replacesAdditionalPropertieswith the block's_meta:So an embedded resource converted this way (as
McpClientTool,ToChatMessageandToAIContentsdo) loses its URI. If the block has_meta, only the_metaentries are kept. This started with #976, and no test covered the URI.The fix merges
_metainto the properties the conversion already set. If_metahas its ownurikey, the resource URI wins. TheToAdditionalPropertieshelper had no other callers and is removed.One side effect:
ToContentBlockwritesAdditionalPropertiesback as_meta, so a round trip now leavesuriin the block's_meta, as it did before #976. Separately,ToContentBlockhas always created blob resources withUri = "". Both could be fixed by reading the URI fromAdditionalProperties["uri"]and keeping it out of_meta. I left that out to keep this PR to the regression, but I'm happy to add it here or in a follow-up.New tests in
AIContentExtensionsTestscover:_meta;uriprecedence;_metacopying for other content types.The URI tests fail without the fix.
Written by Claude Opus 5.5 (Claude Code), guided and reviewed by me.
🤖 Generated with Claude Code