fix(mcp): restore imports and fix execution flow in MCP integration

pull/819/head
Pavan Kumar 3 months ago committed by ascender1729
parent b8c712cc41
commit 901f868ca6

@ -47,6 +47,7 @@ from swarms.structs.safe_loading import (
) )
from swarms.telemetry.main import log_agent_data from swarms.telemetry.main import log_agent_data
from swarms.tools.base_tool import BaseTool 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.tools.tool_parse_exec import parse_and_execute_json
from swarms.utils.any_to_str import any_to_str from swarms.utils.any_to_str import any_to_str
from swarms.utils.data_to_text import data_to_text 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: def mcp_execution_flow(self, payload: dict) -> str | None:
"""Forward the tool-call dict to every MCP server in self.mcp_servers""" """Forward the tool-call dict to every MCP server in self.mcp_servers"""
try: try:
result = asyncio.run(batch_mcp_flow(self.mcp_servers, [payload])) result = batch_mcp_flow(self.mcp_servers, [payload])
return any_to_str(result) return any_to_str(result)
except Exception as err: except Exception as err:
logger.error(f"MCP flow failed: {err}") logger.error(f"MCP flow failed: {err}")
return f"[MCP-error] {err}" return f"[MCP-error] {err}"
Loading…
Cancel
Save