Repository navigation
Description
Describe the Bug
convertMcpContentToolResultOutput (packages/core/src/agent/message-list/conversion/output-converter.ts:497, emitting at :519/:523 on current main) converts MCP-style tool results ({ content: [...] }) into the v5 tool-result output, but emits image-data/file-data parts — the spec-v3 (AI SDK v6) shapes — inside the v5 content value. LanguageModelV2ToolResultOutput only accepts text and media parts.
What that causes per provider spec:
- spec-v2 (v5) providers map only
text/mediatool-result content parts, so theimage-dataitem becomesundefinedand the image is silently dropped from the request. - spec-v4 (v7) providers:
aiV5PromptToAIV7Promptonly convertsmedia/image-url/file-urlparts, soimage-datapasses through unconverted and providers reject it withunsupported tool content part type: image-data— the [BUG] Image tool-results encoded as spec-v3image-datasent to spec-v4 (LanguageModelV4) providers — throws on Bedrock #19658 symptom; Bedrock throws on it. - spec-v3 (v6) providers only work by accident:
aiV5PromptToAIV6Promptleavesimage-data/file-datauntouched, which happens to be the valid v3 shape.
This is the remaining gap after #19755 fixed the toModelOutput path reported in #19658: MCP auto-detected tool results still emit image-data directly, so image/audio results from MCP tools still never reach spec-v2/spec-v4 providers.
Steps To Reproduce
git clone https://github.com/BlueX888/mastra-mcp-media-repro && cd mastra-mcp-media-repronpm install && node repro.js
The repro stores an MCP-shaped tool result ({ content: [{ type: "image", data: "base64image", mimeType: "image/png" }] }) as a DB tool-invocation part, converts it through the public convertMessages(dbMessages).to('AIV5.Model') path, and prints the emitted tool-result output:
part types: text, image-data
BUG: invalid part types for LanguageModelV2ToolResultOutput content union (text | media)
- For the provider-visible failure, run an agent whose MCP tool returns image content: with a spec-v4 provider (e.g. Bedrock) the request is rejected with
unsupported tool content part type: image-data; with a spec-v2 provider the image is silently missing from the outgoing request.
Link to Minimal Reproducible Example
Expected Behavior
MCP image/audio tool results should be emitted as media parts in the v5 tool-result output — the shape the pipeline already standardizes on elsewhere (normalizeModelOutput, #17879) — so the spec-boundary converters translate them for v6 (image-data/file-data) and v7 (file) providers. Images and audio from MCP tool results should reach the model on every provider spec.
Environment Information
@mastra/core 1.75.0 (latest release) and current main
(output-converter.ts:519/:523 verified on main, 2026-10-09)
LLM provider: any spec-v2 (v5) / spec-v4 (v7) provider; spec-v4 on Bedrock throws
Node v22.23.2, macOS 15 (arm64)
Verification
- I have searched the existing issues to make sure this is not a duplicate
- I have included sufficient information for the team to reproduce and understand the issue
Fix with tests is ready in #25093 (4 of its 5 regression tests fail on main).
Report prepared with LLM assistance; the repro output above is verbatim from my runs against the versions cited above.
Activity
dane-ai-mastra commentedon Oct 9, 2026
Thank you for opening this issue. It is waiting for maintainer triage or approval.
Please wait until maintainers remove the triage or approval label before opening a pull request.
mastra-platform commentedon Oct 11, 2026
image-dataandfile-dataparts into v5 tool-result outputmainand in the reporter's repromediaparts and add tests for v5, v6 and v7Understanding
convertMcpContentToolResultOutputinpackages/core/src/agent/message-list/conversion/output-converter.tsconverts MCPimagecontent toimage-data(line 519) and MCPaudiocontent tofile-data(line 523). It places these parts inside a v5 (spec-v2){type:'content'}tool-result output. Spec-v2 only allowstextandmediaparts there.The other places where conversion happens all expect
mediaat this point:normalizeModelOutput(fix(core): preserve multimodal tool result content shape for toModelOutput #17879, fix(core): route tool result media for AI SDK v7 #19755) already mapsimage-dataandfile-datatomediaon thetoModelOutputpath. The MCP path doesn't go through it.aiV5PromptToAIV6PromptandaiV5PromptToAIV7Promptonly translatemediaand URL parts when converting to the provider spec.What each provider spec does with the current output:
unsupported tool content part type: image-data.image-datahappens to be valid there.Fix direction: emit
{type:'media', data, mediaType}for MCP image and audio parts. The existing conversions to v6 and v7 then produce the right shape. Closed PR #25093 contains a fix along these lines with tests that could be reused. Open PR #26652 edits the same file, so a rebase may be needed.Assumptions
Open questions
Reproduction
Not reproduced live. The reporter's repro (https://github.com/BlueX888/mastra-mcp-media-repro) shows
convertMessages(...).to('AIV5.Model')producing animage-datapart. Lines 519 and 523 on thefactory/issue-26481branch confirm the emitting code.dane-ai-mastra commentedon Oct 16, 2026
This issue has been resolved and is available in the latest stable release.