#10245·agno

[Bug] MCP tool results with content=None skip structuredContent and become Error

Author: MohammadHijjawi97Created Sep 17, 2026Updated Sep 17, 2026

Description

get_entrypoint_for_tool iterates result.content directly. MCP servers that omit content (JSON null) raise TypeError. That is caught by the generic handler and returned as Error: ..., so a successful structured-only result never reaches the model. An empty list already falls through to structuredContent. Null content should do the same.

Steps to Reproduce

  1. Call an MCP tool whose result has content=None and structuredContent={"id": "u1"}.
  2. Observe the ToolResult.
python
from unittest.mock import AsyncMock, MagicMock
from agno.utils.mcp import get_entrypoint_for_tool

result = MagicMock()
result.is_error = False
result.content = None
result.meta = None
result.structured_content = {"id": "u1"}

session = AsyncMock()
session.send_ping = AsyncMock()
session.call_tool = AsyncMock(return_value=result)

tool_result = await get_entrypoint_for_tool(MagicMock(name="get_data"), session)()
print(tool_result.content)

Expected Behavior

Missing content is treated as an empty list. The structured payload is serialized into the tool result, matching the empty-list path.

Actual Behavior

for content_item in result.content raises TypeError. The caller gets Error: 'NoneType' object is not iterable instead of the structured content.

Environment

  • OS: Windows 11
  • Agno Version: v3.0.10 (current main)
  • Additional Environment Details: Python 3.13

Possible Solutions (optional)

Iterate result.content or [].