@@ -106,7 +106,7 @@ def test_file_search_call(self) -> None:
106106 def test_mcp_list_tools_call (self ) -> None :
107107 """Test MCP list-tools action summary."""
108108 part = NativeToolCallPart (
109- tool_name = MCPServerTool .kind ,
109+ tool_name = f" { MCPServerTool .kind } :srv" ,
110110 args = {"action" : "list_tools" },
111111 tool_call_id = "mcp-list-1" ,
112112 )
@@ -115,13 +115,26 @@ def test_mcp_list_tools_call(self) -> None:
115115
116116 assert summary is not None
117117 assert summary .name == "mcp_list_tools"
118- assert summary .args == {"server_label" : MCPServerTool . kind }
118+ assert summary .args == {"server_label" : "srv" }
119119 assert summary .type == "mcp_list_tools"
120120
121+ def test_mcp_list_tools_call_with_label (self ) -> None :
122+ """Test labeled MCP list-tools action uses the server label suffix."""
123+ part = NativeToolCallPart (
124+ tool_name = f"{ MCPServerTool .kind } :myserver" ,
125+ args = {"action" : "list_tools" },
126+ tool_call_id = "mcp-list-labeled" ,
127+ )
128+
129+ summary = summarize_native_tool_call (part )
130+
131+ assert summary is not None
132+ assert summary .args == {"server_label" : "myserver" }
133+
121134 def test_mcp_call (self ) -> None :
122135 """Test MCP tool call summary."""
123136 part = NativeToolCallPart (
124- tool_name = MCPServerTool .kind ,
137+ tool_name = f" { MCPServerTool .kind } :srv" ,
125138 args = {
126139 "action" : "call" ,
127140 "tool_name" : "remote_tool" ,
@@ -553,6 +566,19 @@ def test_records_file_search_result(self, turn_state: AgentTurnAccumulator) -> N
553566 assert len (turn_state .turn_summary .referenced_documents ) == 1
554567 assert turn_state .round_increment_pending
555568
569+ def test_records_labeled_mcp_result (self , turn_state : AgentTurnAccumulator ) -> None :
570+ """Test labeled MCP tool return is processed like unlabeled MCP returns."""
571+ part = NativeToolReturnPart (
572+ tool_name = f"{ MCPServerTool .kind } :srv" ,
573+ tool_call_id = "mcp-labeled" ,
574+ content = {"output" : "labeled-output" },
575+ )
576+
577+ result = process_native_tool_result (turn_state , part )
578+
579+ assert result is not None
580+ assert result .content == "labeled-output"
581+
556582 def test_records_web_search_and_mcp_results (
557583 self , turn_state : AgentTurnAccumulator
558584 ) -> None :
@@ -563,7 +589,7 @@ def test_records_web_search_and_mcp_results(
563589 content = {"status" : "success" },
564590 )
565591 mcp_part = NativeToolReturnPart (
566- tool_name = MCPServerTool .kind ,
592+ tool_name = f" { MCPServerTool .kind } :srv" ,
567593 tool_call_id = "mcp-process" ,
568594 content = {"output" : "mcp-output" },
569595 )
0 commit comments