Preserve prompt message structure through vMCP relay#4334
Merged
Conversation
The vMCP prompt relay flattened all backend messages into a single string with "[role] text\n" format, discarding non-text content and individual message roles. The handler then wrapped this flat string as a single "assistant" message, losing the original conversation structure. Replace the lossy ConvertPromptMessages with structured ConvertMCPPromptMessages/ToMCPPromptMessages that preserve individual messages with their original roles and full content types (text, image, audio, embedded resource, resource link). This removes the documented "Phase 1 limitation" for prompt message handling. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4334 +/- ##
==========================================
- Coverage 69.32% 69.10% -0.23%
==========================================
Files 478 478
Lines 48415 48432 +17
==========================================
- Hits 33564 33469 -95
- Misses 12266 12303 +37
- Partials 2585 2660 +75 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
yrobla
reviewed
Mar 24, 2026
yrobla
approved these changes
Mar 24, 2026
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.
Summary
The vMCP relay was flattening prompt messages into a single
"[role] text\n"string, losing individual message roles, content types (images, audio), and multi-message structure. AI clients receiving prompts through the relay got a degraded single-string representation instead of the structured messages the backend MCP server returned.This changes
PromptGetResult.Messagesfromstringto[]PromptMessage, preserving each message's role and full content structure through the entire relay path (backend → session → client → handler factory → MCP response).PromptMessagetype withRoleandContentfields tovmcp.typesConvertPromptMessages(string concatenation) withConvertMCPPromptMessages/ToMCPPromptMessagesround-trip convertersType of change
Test plan
task test)task lint-fix)Does this introduce a user-facing change?
Prompt responses from virtual MCP servers now preserve the original message structure (roles, content types) from backend servers, instead of flattening them into a single text string.
Special notes for reviewers
This is one of three related PRs fixing vMCP relay fidelity:
Generated with Claude Code