Fix resource relay to preserve text/blob distinction#4335
Merged
Conversation
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.
Summary
The vMCP relay was concatenating all resource contents into a single
[]bytewith oneMimeType, losing the text/blob distinction, per-item URIs, and per-item MIME types when a resource returned multiple content items. This meant multi-content resources and blob resources were degraded through the relay.This changes
ResourceReadResultfromContents []byte+MimeType stringtoContents []ResourceContent, preserving each item's type (text vs blob), URI, MIME type, and data independently.ResourceContenttype with Text, Data, URI, MimeType fields tovmcp.typesConcatenateResourceContentswithConvertMCPResourceContents/ToMCPResourceContentsround-trip convertersType of change
Test plan
task test)task lint-fix)Changes
pkg/vmcp/types.goResourceContenttype, updateResourceReadResultpkg/vmcp/conversion/content.goConvertMCPResourceContents/ToMCPResourceContents, removeConcatenateResourceContentspkg/vmcp/conversion/conversion_test.gopkg/vmcp/client/client.gopkg/vmcp/server/adapter/handler_factory.gopkg/vmcp/server/adapter/handler_factory_test.gopkg/vmcp/server/sessionmanager/session_manager.gopkg/vmcp/session/internal/backend/mcp_session.goDoes this introduce a user-facing change?
Resource responses from virtual MCP servers now preserve individual content items with their text/blob types, URIs, and MIME types, instead of concatenating everything into a single byte slice.
Special notes for reviewers
This is one of three related PRs fixing vMCP relay fidelity:
Generated with Claude Code