Skip to content

[BUG] MCP image/audio tool results emitted as spec-v3 image-data/file-data in the v5 tool-result output — dropped by spec-v2 providers, rejected by spec-v4 (Bedrock throws) #26481

Closed

Description

@BlueX888

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/media tool-result content parts, so the image-data item becomes undefined and the image is silently dropped from the request.
  • spec-v4 (v7) providers: aiV5PromptToAIV7Prompt only converts media/image-url/file-url parts, so image-data passes through unconverted and providers reject it with unsupported tool content part type: image-data — the [BUG] Image tool-results encoded as spec-v3 image-data sent to spec-v4 (LanguageModelV4) providers — throws on Bedrock #19658 symptom; Bedrock throws on it.
  • spec-v3 (v6) providers only work by accident: aiV5PromptToAIV6Prompt leaves image-data/file-data untouched, 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

  1. git clone https://github.com/BlueX888/mastra-mcp-media-repro && cd mastra-mcp-media-repro
  2. npm 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)
  1. 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

https://github.com/BlueX888/mastra-mcp-media-repro

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

  1. dane-ai-mastra commented on Oct 9, 2026

    @dane-ai-mastra
    Contributor

    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.

  2. mastra-platform commented on Oct 11, 2026

    @mastra-platform
    Contributor
    Type bug — the MCP tool-result converter puts spec-v3 image-data and file-data parts into v5 tool-result output
    Route Plan fix
    Severity 🟠 high — images and audio returned by MCP tools are silently dropped on v5 providers, and v7 providers (Bedrock) reject the request
    Confidence high — the problem is visible in the code on main and in the reporter's repro
    Effort low — one converter plus tests
    Impact medium — multimodal MCP tools break on most provider specs
    Next step Change the MCP converter to emit media parts and add tests for v5, v6 and v7

    Understanding

    convertMcpContentToolResultOutput in packages/core/src/agent/message-list/conversion/output-converter.ts converts MCP image content to image-data (line 519) and MCP audio content to file-data (line 523). It places these parts inside a v5 (spec-v2) {type:'content'} tool-result output. Spec-v2 only allows text and media parts there.

    The other places where conversion happens all expect media at this point:

    What each provider spec does with the current output:

    • v2: drops the parts.
    • v4: rejects them with unsupported tool content part type: image-data.
    • v3: works only by accident, because image-data happens 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

    • Severity rests on reading the code and on the reporter's repro. No live Bedrock run was done.

    Open questions

    Reproduction

    Not reproduced live. The reporter's repro (https://github.com/BlueX888/mastra-mcp-media-repro) shows convertMessages(...).to('AIV5.Model') producing an image-data part. Lines 519 and 523 on the factory/issue-26481 branch confirm the emitting code.

  3. added
    bugSomething isn't working
    @mastra/coreIssues whose primary fix belongs in @mastra/core
    MCPIssues regarding Mastra's MCP implementation
    and removed on Oct 11, 2026
  4. dane-ai-mastra commented on Oct 16, 2026

    @dane-ai-mastra
    Contributor

    This issue has been resolved and is available in the latest stable release.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @mastra/coreIssues whose primary fix belongs in @mastra/coreMCPIssues regarding Mastra's MCP implementationbugSomething isn't workingeffort:lowimpact:mediumTriage impact: mediumstatus: auto-triagedIssue has been auto-triaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions