[Bug] MCP tool results keep only the first content block
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
- Run a stdio MCP server (SDK 1.30) with two tools.
multireturns text blocksBLOCK-ONE,BLOCK-TWO,BLOCK-THREE.imgfirstreturns an image block (data: "AAAA") followed by a text blockCAPTION. - Connect with
MCPClient.connectToServer(...). - Call
client.callTool('multi', {})andclient.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 948a4e74)
Suggested fix
source/mcp/mcp-client.ts:1172(insideexecuteToolCall): loop overresult.content. Join text blocks with a newline. Replace image and audio blocks with a short placeholder (type and size). Keep the existingTool executed successfully (no output)message for empty results.- This is separate from PR #1926, which only adds
isErrorhandling.
Hi @addyCooks, I'm picking this one up. Could you assign it to me? Thanks.
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.