Skip to content

Commit d8c0937

Browse files
committed
plugging
Signed-off-by: rakdutta <[email protected]>
1 parent 0d23a92 commit d8c0937

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mcpgateway/services/tool_service.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,16 @@ async def connect_to_streamablehttp_server(server_url: str, headers: dict = head
14331433
# Reconstruct ToolResult from modified result
14341434
modified_result = post_result.modified_payload.result
14351435
if isinstance(modified_result, dict) and "content" in modified_result:
1436-
tool_result = ToolResult(content=modified_result["content"], structured_content=modified_result["structuredContent"] if "structuredContent" in modified_result else modified_result["structured_content"])
1436+
# Safely obtain structured content using .get() to avoid KeyError when
1437+
# plugins provide only the content without structured content fields.
1438+
structured = None
1439+
if isinstance(modified_result, dict):
1440+
structured = modified_result.get("structuredContent") if "structuredContent" in modified_result else modified_result.get("structured_content")
1441+
1442+
tool_result = ToolResult(
1443+
content=modified_result["content"],
1444+
structured_content=structured
1445+
)
14371446
else:
14381447
# If result is not in expected format, convert it to text content
14391448
tool_result = ToolResult(content=[TextContent(type="text", text=str(modified_result))])

0 commit comments

Comments
 (0)