[BUG] MCP tools pass only the first content block of a tool result to the agent
Description
When an MCP tool returns more than one content block, CrewAI hands only result.content[0] to the agent and drops the rest. If the first block is not text (an image, say), the agent gets the pydantic repr of that block, base64 data included, and the text after it is lost.
The same first-block logic exists in three places on main (c6e500ab):
MCPClient._call_tool_impl(client.py#L623-L629). This is the path formcps=[MCPServerStdio(...) / MCPServerHTTP(...) / MCPServerSSE(...)]and AMP references, throughMCPNativeTool.MCPToolWrapper._execute_tool(mcp_tool_wrapper.py#L182-L187). This is the path for plainmcps=["https://..."]URLs.MCPNativeTool._extract_content(mcp_native_tool.py#L150-L163). Today this is only a fallback, becauseMCPClientalready returns a string, but it has the same logic.
MCPServerAdapter in crewai-tools already keeps every text block (mcp_adapter.py#L61-L74), which suggests that dropping blocks in the native paths is not intended.
Steps to Reproduce
- Save this MCP server as
server.py:
import logging
from mcp.server.fastmcp import FastMCP
from mcp.types import ImageContent, TextContent
logging.disable(logging.INFO)
server = FastMCP("demo")
@server.tool(structured_output=False)
def three_blocks() -> list[TextContent]:
"""Return three text blocks."""
return [TextContent(type="text", text=t) for t in ("first", "second", "third")]
@server.tool(structured_output=False)
def chart() -> list[ImageContent | TextContent]:
"""Return an image followed by its caption."""
return [
ImageContent(type="image", data="iVBORw0KGgoAAAANSUhEUgAA", mimeType="image/png"),
TextContent(type="text", text="Revenue grew 12% in Q3."),
]
server.run()
- Save this next to it as
repro.py:
import os
import sys
from crewai import Agent
from crewai.mcp import MCPServerStdio
server = os.path.join(os.path.dirname(os.path.abspath(__file__)), "server.py")
agent = Agent(
role="r",
goal="g",
backstory="b",
llm="gpt-4o-mini", # never called; tools are resolved and run directly
mcps=[MCPServerStdio(command=sys.executable, args=[server])],
)
for tool in agent.get_mcp_tools(agent.mcps):
print(f"RESULT {tool.original_tool_name}: {tool.run()!r}")
- Run
python repro.py | grep RESULT. No API key or network access is needed.
Expected behavior
The agent sees every text block, in order. A non-text block should not hide the text around it and should not put base64 data into the prompt; a short marker such as [image: image/png] is enough.
Screenshots/Code snippets
MCPClient._call_tool_impl on main:
if hasattr(result, "content") and result.content:
if isinstance(result.content, list) and len(result.content) > 0:
content_item = result.content[0]
if hasattr(content_item, "text"):
return _MCPToolResult(str(content_item.text), is_error)
return _MCPToolResult(str(content_item), is_error)
return _MCPToolResult(str(result.content), is_error)
MCPToolWrapper._execute_tool and MCPNativeTool._extract_content repeat the same result.content[0] pattern.
Operating System
Other (specify in additional context)
Python Version
3.10
crewAI Version
1.15.28 (main at c6e500ab)
crewAI Tools Version
1.15.28
Virtual Environment
Venv
Evidence
Output of repro.py on main (c6e500ab) with mcp 1.30.0, the same on Python 3.10.19 and 3.13.16:
RESULT three_blocks: 'first'
RESULT chart: "type='image' data='iVBORw0KGgoAAAANSUhEUgAA' mimeType='image/png' annotations=None meta=None"
second and third never reach the agent. For chart, the agent gets the image repr with its base64 data, and the caption is gone.
Possible Solution
One small helper used by all three call sites: join text blocks (and embedded text resources) with newlines, and render image, audio, blob and link blocks as a short typed placeholder such as [image: image/png] or [resource: file:///report.pdf]. A result with a single text block stays exactly as it is today.
A PR with this fix and regression tests for each call site follows and links this issue.
Additional context
- OS: macOS 27.0.1 (not in the dropdown).
- #5226 tried to fix the
MCPClientcopy in April. It was closed unmerged on 2026-09-17 with theneeds-issuelabel because it had no linked issue; the change itself was never reviewed. It also left the other two copies alone. - Open PRs touching the same files: #7643 (isError on the
MCPToolWrapperpath, edits the same lines in_execute_tool), #6744 (MCPClient connection and retry changes, does not touch_call_tool_impl), #7448 and #7756 (event-loop handling, no overlap with result flattening). - AI disclosure: Claude Code (Claude Opus 5.5) found the bug, ran the reproduction above and wrote this report. I reviewed the draft, and Claude Code filed it on my behalf. Please add the
llm-generatedlabel; I don't have permission to add labels.