1111from mcp .server .mcpserver .exceptions import ToolError
1212from mcp .server .mcpserver .tools import Tool , ToolManager
1313from mcp .server .mcpserver .utilities .func_metadata import ArgModelBase , FuncMetadata
14- from mcp .types import TextContent , ToolAnnotations
14+ from mcp .types import CallToolResult , TextContent , ToolAnnotations
1515
1616
1717class TestAddTools :
@@ -455,7 +455,8 @@ def get_user(user_id: int) -> UserOutput:
455455 manager .add_tool (get_user )
456456 result = await manager .call_tool ("get_user" , {"user_id" : 1 }, Context (), convert_result = True )
457457 # don't test unstructured output here, just the structured conversion
458- assert len (result ) == 2 and result [1 ] == {"name" : "John" , "age" : 30 }
458+ assert isinstance (result , CallToolResult )
459+ assert result .structured_content == {"name" : "John" , "age" : 30 }
459460
460461 @pytest .mark .anyio
461462 async def test_tool_with_primitive_output (self ):
@@ -470,7 +471,8 @@ def double_number(n: int) -> int:
470471 result = await manager .call_tool ("double_number" , {"n" : 5 }, Context ())
471472 assert result == 10
472473 result = await manager .call_tool ("double_number" , {"n" : 5 }, Context (), convert_result = True )
473- assert isinstance (result [0 ][0 ], TextContent ) and result [1 ] == {"result" : 10 }
474+ assert isinstance (result , CallToolResult )
475+ assert isinstance (result .content [0 ], TextContent ) and result .structured_content == {"result" : 10 }
474476
475477 @pytest .mark .anyio
476478 async def test_tool_with_typeddict_output (self ):
@@ -510,7 +512,8 @@ def get_person() -> Person:
510512 manager .add_tool (get_person )
511513 result = await manager .call_tool ("get_person" , {}, Context (), convert_result = True )
512514 # don't test unstructured output here, just the structured conversion
513- assert len (result ) == 2 and result [1 ] == expected_output
515+ assert isinstance (result , CallToolResult )
516+ assert result .structured_content == expected_output
514517
515518 @pytest .mark .anyio
516519 async def test_tool_with_list_output (self ):
@@ -528,7 +531,8 @@ def get_numbers() -> list[int]:
528531 result = await manager .call_tool ("get_numbers" , {}, Context ())
529532 assert result == expected_list
530533 result = await manager .call_tool ("get_numbers" , {}, Context (), convert_result = True )
531- assert isinstance (result [0 ][0 ], TextContent ) and result [1 ] == expected_output
534+ assert isinstance (result , CallToolResult )
535+ assert isinstance (result .content [0 ], TextContent ) and result .structured_content == expected_output
532536
533537 @pytest .mark .anyio
534538 async def test_tool_without_structured_output (self ):
0 commit comments