Skip to content

[Bug] MCP tool results keep only the first content block #1932

Closed

Description

@addyCooks

Summary

MCPClient returns only result.content[0]. Text in later blocks is dropped, and a leading image block is returned to the model as raw base64 JSON.

Steps to reproduce

  1. Run a stdio MCP server (SDK 1.30) with two tools. multi returns text blocks BLOCK-ONE, BLOCK-TWO, BLOCK-THREE. imgfirst returns an image block (data: "AAAA") followed by a text block CAPTION.
  2. Connect with MCPClient.connectToServer(...).
  3. Call client.callTool('multi', {}) and client.callTool('imgfirst', {}).

Expected behaviour

All text blocks are returned. Non-text blocks are summarised, for example [image/png, 4 bytes], not dumped.

Actual behaviour

multi    -> "BLOCK-ONE"
imgfirst -> "{\"type\":\"image\",\"data\":\"AAAA\",\"mimeType\":\"image/png\"}"

A spec asserting all three blocks fails with t.true(out.includes('BLOCK-TWO')) -> false. The CAPTION text is lost.

Environment

Windows 11, Node v22.22.3, Nanocoder 1.31.0 (main at 948a4e7)

Suggested fix

  • source/mcp/mcp-client.ts:1172 (inside executeToolCall): loop over result.content. Join text blocks with a newline. Replace image and audio blocks with a short placeholder (type and size). Keep the existing Tool executed successfully (no output) message for empty results.
  • This is separate from PR fix(mcp): report an MCP isError result as a failed tool call #1926, which only adds isError handling.

Activity

  1. added
    bug
    area:mcp
    on Nov 2, 2026
  2. added theissue type on Nov 2, 2026
  3. added
    needs-triage
    on Nov 2, 2026
  4. removed
    needs-triage
    on Nov 2, 2026
  5. Mahdi-Hasan commented on Nov 4, 2026

    @Mahdi-Hasan
    Contributor

    Hi @addyCooks, I'm picking this one up. Could you assign it to me? Thanks.

  6. Mahdi-Hasan commented on Nov 5, 2026

    @Mahdi-Hasan
    Contributor

    Hi @addyCooks, I've opened #1960 for this. It formats every content block: text is joined, and image, audio and binary resources become a short [mime, N bytes] placeholder. Could you assign the issue to me when you get a chance? Thanks.

  7. added a commit that references this issue on Nov 7, 2026
    ed66109
  8. added a commit that references this issue on Nov 12, 2026
    4f20a58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:mcpbug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions