77
88import pytest
99from mcp import types
10+ from mcp .types import CallToolRequestParams as MCPToolCall
1011
1112from hud .mcp .base import BaseMCPAgent
1213from hud .tools .executors .base import BaseExecutor
@@ -102,7 +103,7 @@ def test_init_with_params(self):
102103 async def test_initialize_no_client (self ):
103104 """Test initialize fails without client."""
104105 agent = MockMCPAgent ()
105- agent .client = None
106+ agent .client = None # type: ignore
106107
107108 with pytest .raises (ValueError , match = "Client is not initialized" ):
108109 await agent .initialize ()
@@ -218,12 +219,12 @@ async def mock_call_tool(name, args):
218219
219220 assert agent .client is not None
220221 agent .client .get_all_active_sessions = MagicMock (return_value = {"server1" : mock_session })
221- agent .client .get_session = MagicMock (return_value = mock_session )
222222
223223 await agent .initialize ()
224224
225225 # Call the tool
226- result = await agent .call_tool ({"name" : "test_tool" , "arguments" : {"param" : "value" }})
226+ tool_call = MCPToolCall (name = "test_tool" , arguments = {"param" : "value" })
227+ result = await agent .call_tool (tool_call )
227228
228229 assert result == mock_result
229230 assert not result .isError
@@ -247,15 +248,17 @@ async def mock_list_tools():
247248
248249 # Try to call unknown tool
249250 with pytest .raises (ValueError , match = "Tool 'unknown_tool' not found" ):
250- await agent .call_tool ({"name" : "unknown_tool" , "arguments" : {}})
251+ tool_call = MCPToolCall (name = "unknown_tool" , arguments = {})
252+ await agent .call_tool (tool_call )
251253
252254 @pytest .mark .asyncio
253255 async def test_call_tool_no_name (self ):
254256 """Test calling tool without name."""
255- agent = MockMCPAgent ()
257+ from pydantic import ValidationError
256258
257- with pytest .raises (ValueError , match = "Tool call must have a 'name' field" ):
258- await agent .call_tool ({"arguments" : {}})
259+ # MCPToolCall requires name, so it will raise ValidationError
260+ with pytest .raises (ValidationError ):
261+ MCPToolCall (name = "" , arguments = {}) # Empty name should fail validation
259262
260263 def test_get_system_prompt_default (self ):
261264 """Test get_system_prompt with default settings."""
@@ -362,34 +365,14 @@ async def mock_call_tool(name, args):
362365
363366 assert agent .client is not None
364367 agent .client .get_all_active_sessions = MagicMock (return_value = {"server1" : mock_session })
365- agent .client .get_session = MagicMock (return_value = mock_session )
366368
367369 await agent .initialize ()
368370
369371 screenshot = await agent .capture_screenshot ()
370372 assert screenshot == "base64imagedata"
371373
372- def test_process_tool_results_extracts_text (self ):
373- """Test processing tool results extracts text content."""
374- agent = MockMCPAgent ()
375-
376- # Create a proper CallToolResult object
377- result = types .CallToolResult (
378- content = [
379- types .TextContent (type = "text" , text = "Result text" ),
380- types .ImageContent (type = "image" , data = "imagedata" , mimeType = "image/png" ),
381- ],
382- isError = False ,
383- )
384-
385- tool_results = [{"tool_name" : "test_tool" , "result" : result }]
386-
387- processed = agent .process_tool_results (tool_results )
388-
389- assert "text" in processed
390- assert "Result text" in processed ["text" ]
391- assert "results" in processed
392- assert len (processed ["results" ]) == 1
374+ # process_tool_results method was removed from base class
375+ # This functionality is now handled internally
393376
394377 def test_get_tools_by_server (self ):
395378 """Test getting tools grouped by server."""
0 commit comments