Skip to content

Empty tool output incorrectly triggers “Errored MCP tool result” #1035

Open
@dannyhorcajo

Description

@dannyhorcajo

Please read this first

  • Have you read the docs? Agents SDK docs
    Yes
  • Have you searched for related issues? Others may have faced similar issues.
    Yes

Describe the bug

If an MCP tool is registered but returns an empty value (e.g.: None, [], {}), the MCPServer.call_tool() response does not create a ContentBlock in the CallToolResult object. As a result, MCPUtil.invoke_mcp_tool() in agents.mcp.utils.py logs the error Errored MCP tool result:

Errored MCP tool result: meta=None content=[] structuredContent={'result': None} isError=False

Debug information

  • Agents SDK version: v0.1.0
  • Python version Python 3.11

Repro steps

This is what a sample MCP tool to fetch a DB may look like. If no results are found (an empty list is returned), the tool logs an Errored MCP tool result instead of returning the empty list.

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("my_db")


@mcp.tool()
def fetch_items_by_id(ids: list[int]) -> list[dict]:
    """
    Fetch the items in the database by their IDs.

    Returns:
        A list of items in dict (JSON) format.
    """
    results: list[dict] = []

    # ...some app logic

    return results

Expected behavior

The tool call returns a string with an empty object (e.g., en empty list) to let the LLM know the tool returned no results, without it being considered an error. This would improve tool-call reliability and prevent false negatives when no data is legitimately found.

Non-MCP tools work as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions