Skip to content

call_tool envelope drops image/audio payloads, result _meta, embedded resources, and content annotations #975

Description

@QuentinBisson

Problem

The call_tool meta-tool envelope and the agent client's unwrapping lose several parts of a downstream tool result. PR #972 fixed structuredContent; the remaining gaps:

  • Image / audio payloads are discarded. SerializeContent serializes them as {type, mimeType, dataSize} only, dropping the base64 Data (internal/metatools/formatters.go:389-400). A downstream tool returning a screenshot or rendered graph arrives as "image, 48000 bytes" with no image.
  • Result _meta is dropped. The envelope carries only {isError, content, structuredContent} (internal/metatools/handlers.go:506-512), so downstream tracing or app-specific hints in _meta never reach the client.
  • EmbeddedResource / ResourceLink content items survive the envelope (unknown-type fallback marshals them as-is) but are dropped by the agent client, which only reconstructs type == "text" items (internal/agent/client.go:925-929).
  • Content Annotations (audience, priority) are stripped in both directions.

Proposal

Round-trip all standard MCP content types and result _meta through the envelope and the client unwrap, as additive JSON fields (same pattern as the structuredContent fix, same three files, no change to existing envelope bytes for results that don't use these features).

Open question: the dataSize-only form for image/audio may be intentional to keep tool results small for LLM consumption. If so, keep the size-only rendering in the text representation but carry the full payload in the reconstructed content items, or gate payload passthrough behind a call_tool argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions