Python: normalize empty MCP tool output to null (#4683)

* Python: normalize empty MCP tool output to null

* Python: hardcode null for empty MCP output
This commit is contained in:
Eduard van Valkenburg
2026-03-13 21:03:48 +01:00
committed by GitHub
Unverified
parent c67d3523ae
commit 052ba7be07
2 changed files with 7 additions and 5 deletions
+5 -2
View File
@@ -195,13 +195,16 @@ def test_parse_tool_result_from_mcp_meta_not_in_string():
def test_parse_tool_result_from_mcp_empty_content():
"""Test that empty content produces list with empty text Content."""
"""Test that empty MCP content normalizes to JSON null text content."""
mcp_result = types.CallToolResult(content=[])
result = _parse_tool_result_from_mcp(mcp_result)
assert isinstance(result, list)
assert len(result) == 1
assert result[0].type == "text"
assert result[0].text == ""
assert result[0].text == "null"
function_result = Content.from_function_result(call_id="call_null", result=result)
assert function_result.result == "null"
def test_parse_tool_result_from_mcp_audio_content():