From 901f868ca60dd75eca7fe1fef84f96f156f974d0 Mon Sep 17 00:00:00 2001 From: Pavan Kumar <66913595+ascender1729@users.noreply.github.com> Date: Sun, 20 Apr 2025 11:29:48 +0000 Subject: [PATCH] fix(mcp): restore imports and fix execution flow in MCP integration --- swarms/structs/agent.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index fb729a8f..be6bc9e1 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -47,6 +47,7 @@ from swarms.structs.safe_loading import ( ) from swarms.telemetry.main import log_agent_data from swarms.tools.base_tool import BaseTool +from swarms.tools.mcp_integration import MCPServerSseParams, batch_mcp_flow, mcp_flow_get_tool_schema from swarms.tools.tool_parse_exec import parse_and_execute_json from swarms.utils.any_to_str import any_to_str from swarms.utils.data_to_text import data_to_text @@ -2777,8 +2778,8 @@ class Agent: def mcp_execution_flow(self, payload: dict) -> str | None: """Forward the tool-call dict to every MCP server in self.mcp_servers""" try: - result = asyncio.run(batch_mcp_flow(self.mcp_servers, [payload])) - return any_to_str(result) + result = batch_mcp_flow(self.mcp_servers, [payload]) + return any_to_str(result) except Exception as err: logger.error(f"MCP flow failed: {err}") return f"[MCP-error] {err}" \ No newline at end of file