Skip to content

Commit 5dbad7c

Browse files
committed
Fix bug in mcp plugin
1 parent 4e3205d commit 5dbad7c

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

plugins/communication_protocols/mcp/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "utcp-mcp"
7-
version = "1.1.0"
7+
version = "1.1.1"
88
authors = [
99
{ name = "UTCP Contributors" },
1010
]

plugins/communication_protocols/mcp/src/utcp_mcp/mcp_communication_protocol.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,12 @@ async def call_tool_streaming(self, caller: 'UtcpClient', tool_name: str, tool_a
384384
def _process_tool_result(self, result, tool_name: str) -> Any:
385385
self._log_info(f"Processing tool result for '{tool_name}', type: {type(result)}")
386386

387-
# Check for structured output first
387+
# Check for structured output first - this is the expected behavior
388388
if hasattr(result, 'structuredContent'):
389389
self._log_info(f"Found structuredContent: {result.structuredContent}")
390390
return result.structuredContent
391391

392-
# Process content if available
392+
# Process content if available (fallback)
393393
if hasattr(result, 'content'):
394394
content = result.content
395395
self._log_info(f"Content type: {type(content)}")
@@ -427,6 +427,10 @@ def _process_tool_result(self, result, tool_name: str) -> Any:
427427

428428
return content
429429

430+
# Handle dictionary with 'result' key
431+
if isinstance(result, dict) and 'result' in result:
432+
return result['result']
433+
430434
# Fallback to result attribute
431435
if hasattr(result, 'result'):
432436
return result.result

plugins/communication_protocols/mcp/tests/test_mcp_http_transport.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ async def test_http_unstructured_output(
136136

137137
# Call the greet tool and verify the result
138138
result = await transport.call_tool(None, f"{HTTP_SERVER_NAME}.greet", {"name": "Alice"}, http_mcp_provider)
139-
assert result == "Hello, Alice!"
139+
assert result == {"result": "Hello, Alice!"}
140140

141141

142142
@pytest.mark.asyncio
@@ -152,11 +152,9 @@ async def test_http_list_output(
152152
# Call the list_items tool and verify the result
153153
result = await transport.call_tool(None, f"{HTTP_SERVER_NAME}.list_items", {"count": 3}, http_mcp_provider)
154154

155-
assert isinstance(result, list)
156-
assert len(result) == 3
157-
assert result[0] == "item_0"
158-
assert result[1] == "item_1"
159-
assert result[2] == "item_2"
155+
assert isinstance(result, dict)
156+
assert "result" in result
157+
assert result == {"result": ["item_0", "item_1", "item_2"]}
160158

161159

162160
@pytest.mark.asyncio
@@ -172,7 +170,7 @@ async def test_http_numeric_output(
172170
# Call the add_numbers tool and verify the result
173171
result = await transport.call_tool(None, f"{HTTP_SERVER_NAME}.add_numbers", {"a": 5, "b": 7}, http_mcp_provider)
174172

175-
assert result == 12
173+
assert result == {"result": 12}
176174

177175

178176
@pytest.mark.asyncio

plugins/communication_protocols/mcp/tests/test_mcp_transport.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def test_unstructured_string_output(transport: McpCommunicationProtocol, m
9898
await transport.register_manual(None, mcp_manual)
9999

100100
result = await transport.call_tool(None, f"{SERVER_NAME}.greet", {"name": "Alice"}, mcp_manual)
101-
assert result == "Hello, Alice!"
101+
assert result == {"result": "Hello, Alice!"}
102102

103103

104104
@pytest.mark.asyncio
@@ -108,9 +108,9 @@ async def test_list_output(transport: McpCommunicationProtocol, mcp_manual: McpC
108108

109109
result = await transport.call_tool(None, f"{SERVER_NAME}.list_items", {"count": 3}, mcp_manual)
110110

111-
assert isinstance(result, list)
112-
assert len(result) == 3
113-
assert result == ["item_0", "item_1", "item_2"]
111+
assert isinstance(result, dict)
112+
assert "result" in result
113+
assert result == {"result": ["item_0", "item_1", "item_2"]}
114114

115115

116116
@pytest.mark.asyncio
@@ -120,7 +120,7 @@ async def test_numeric_output(transport: McpCommunicationProtocol, mcp_manual: M
120120

121121
result = await transport.call_tool(None, f"{SERVER_NAME}.add_numbers", {"a": 5, "b": 7}, mcp_manual)
122122

123-
assert result == 12
123+
assert result == {"result": 12}
124124

125125

126126
@pytest.mark.asyncio

0 commit comments

Comments
 (0)