Skip to content

Fix resource relay to preserve text/blob distinction#4335

Merged
JAORMX merged 2 commits intomainfrom
fix-resource-relay
Mar 25, 2026
Merged

Fix resource relay to preserve text/blob distinction#4335
JAORMX merged 2 commits intomainfrom
fix-resource-relay

Conversation

@JAORMX
Copy link
Collaborator

@JAORMX JAORMX commented Mar 24, 2026

Summary

The vMCP relay was concatenating all resource contents into a single []byte with one MimeType, 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 ResourceReadResult from Contents []byte + MimeType string to Contents []ResourceContent, preserving each item's type (text vs blob), URI, MIME type, and data independently.

  • Add ResourceContent type with Text, Data, URI, MimeType fields to vmcp.types
  • Replace lossy ConcatenateResourceContents with ConvertMCPResourceContents / ToMCPResourceContents round-trip converters
  • Update handler factory to relay structured resource contents instead of reconstructing from concatenated bytes
  • Remove the now-unused concatenation helper and its tests
  • Update all tests to assert on structured resource content

Type of change

  • Bug fix

Test plan

  • Unit tests (task test)
  • Linting (task lint-fix)

Changes

File Change
pkg/vmcp/types.go Add ResourceContent type, update ResourceReadResult
pkg/vmcp/conversion/content.go Add ConvertMCPResourceContents / ToMCPResourceContents, remove ConcatenateResourceContents
pkg/vmcp/conversion/conversion_test.go Add round-trip tests for resource contents
pkg/vmcp/client/client.go Use structured conversion instead of concatenation
pkg/vmcp/server/adapter/handler_factory.go Relay structured contents directly
pkg/vmcp/server/adapter/handler_factory_test.go Update to use structured resource content
pkg/vmcp/server/sessionmanager/session_manager.go Update resource content handling
pkg/vmcp/session/internal/backend/mcp_session.go Use structured conversion

Does 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:

  • fix-prompt-messages: prompt message structure
  • This PR: resource text/blob distinction and per-item metadata
  • fix-content-annotations: per-content annotations (audience, priority, lastModified)

Generated with Claude Code

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants