@@ -218,49 +218,6 @@ async def mock_awaitable():
218218 assert result ["content" ][0 ]["text" ] == "Test message"
219219
220220
221- @pytest .mark .asyncio
222- async def test_call_tool_async_with_structured_content (mock_transport , mock_session ):
223- """Test that call_tool_async correctly handles structured content."""
224- mock_content = MCPTextContent (type = "text" , text = "Test message" )
225- structured_content = {"result" : 42 , "status" : "completed" }
226- mock_result = MCPCallToolResult (isError = False , content = [mock_content ], structuredContent = structured_content )
227- mock_session .call_tool .return_value = mock_result
228-
229- with MCPClient (mock_transport ["transport_callable" ]) as client :
230- with (
231- patch ("asyncio.run_coroutine_threadsafe" ) as mock_run_coroutine_threadsafe ,
232- patch ("asyncio.wrap_future" ) as mock_wrap_future ,
233- ):
234- # Create a mock future that returns the mock result
235- mock_future = MagicMock ()
236- mock_run_coroutine_threadsafe .return_value = mock_future
237-
238- # Create an async mock that resolves to the mock result
239- async def mock_awaitable ():
240- return mock_result
241-
242- mock_wrap_future .return_value = mock_awaitable ()
243-
244- result = await client .call_tool_async (
245- tool_use_id = "test-123" , name = "test_tool" , arguments = {"param" : "value" }
246- )
247-
248- # Verify the asyncio functions were called correctly
249- mock_run_coroutine_threadsafe .assert_called_once ()
250- mock_wrap_future .assert_called_once_with (mock_future )
251-
252- assert result ["status" ] == "success"
253- assert result ["toolUseId" ] == "test-123"
254- # Content should only contain the text content, not the structured content
255- assert len (result ["content" ]) == 1
256- assert result ["content" ][0 ]["text" ] == "Test message"
257- # Structured content should be in its own field
258- assert "structuredContent" in result
259- assert result ["structuredContent" ] == structured_content
260- assert result ["structuredContent" ]["result" ] == 42
261- assert result ["structuredContent" ]["status" ] == "completed"
262-
263-
264221@pytest .mark .asyncio
265222async def test_call_tool_async_session_not_active ():
266223 """Test that call_tool_async raises an error when session is not active."""
0 commit comments