@@ -132,6 +132,8 @@ def test_call_tool_sync_status(mock_transport, mock_session, is_error, expected_
132132 assert result ["content" ][0 ]["text" ] == "Test message"
133133 # No structured content should be present when not provided by MCP
134134 assert result .get ("structuredContent" ) is None
135+ # isError mirrors the MCP server's explicit value; absent only for protocol/client exceptions
136+ assert result .get ("isError" ) is is_error
135137
136138
137139def test_call_tool_sync_session_not_active ():
@@ -261,6 +263,8 @@ async def mock_awaitable():
261263 assert result ["toolUseId" ] == "test-123"
262264 assert len (result ["content" ]) == 1
263265 assert result ["content" ][0 ]["text" ] == "Test message"
266+ # isError mirrors the MCP server's explicit value; absent only for protocol/client exceptions
267+ assert result .get ("isError" ) is is_error
264268
265269
266270@pytest .mark .asyncio
@@ -408,6 +412,15 @@ def test_mcp_tool_result_type():
408412
409413 assert result_with_structured ["structuredContent" ] == {"key" : "value" }
410414
415+ # isError is optional — absent by default
416+ assert "isError" not in result
417+
418+ # isError can be set to flag tool-reported application errors
419+ result_with_is_error = MCPToolResult (
420+ status = "error" , toolUseId = "test-789" , content = [{"text" : "Tool failed" }], isError = True
421+ )
422+ assert result_with_is_error ["isError" ] is True
423+
411424
412425def test_call_tool_sync_without_structured_content (mock_transport , mock_session ):
413426 """Test that call_tool_sync works correctly when no structured content is provided."""
0 commit comments