Skip to content

Commit 5f25643

Browse files
committed
unwrap mcp results
1 parent 5dbad7c commit 5f25643

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
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.1"
7+
version = "1.1.2"
88
authors = [
99
{ name = "UTCP Contributors" },
1010
]

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ def _process_tool_result(self, result, tool_name: str) -> Any:
387387
# Check for structured output first - this is the expected behavior
388388
if hasattr(result, 'structuredContent'):
389389
self._log_info(f"Found structuredContent: {result.structuredContent}")
390+
# If structuredContent has a 'result' key, unwrap it
391+
if isinstance(result.structuredContent, dict) and 'result' in result.structuredContent:
392+
return result.structuredContent['result']
390393
return result.structuredContent
391394

392395
# Process content if available (fallback)

plugins/communication_protocols/mcp/tests/test_mcp_http_transport.py

Lines changed: 5 additions & 5 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 == {"result": "Hello, Alice!"}
139+
assert result == "Hello, Alice!"
140140

141141

142142
@pytest.mark.asyncio
@@ -152,9 +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, dict)
156-
assert "result" in result
157-
assert result == {"result": ["item_0", "item_1", "item_2"]}
155+
assert isinstance(result, list)
156+
assert len(result) == 3
157+
assert result == ["item_0", "item_1", "item_2"]
158158

159159

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

173-
assert result == {"result": 12}
173+
assert result == 12
174174

175175

176176
@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 == {"result": "Hello, Alice!"}
101+
assert 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, dict)
112-
assert "result" in result
113-
assert result == {"result": ["item_0", "item_1", "item_2"]}
111+
assert isinstance(result, list)
112+
assert len(result) == 3
113+
assert 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 == {"result": 12}
123+
assert result == 12
124124

125125

126126
@pytest.mark.asyncio

0 commit comments

Comments
 (0)