bstraehle commited on
Commit
38c4b14
·
verified ·
1 Parent(s): 5574740

Update agents/mcp/mcp_client.py

Browse files
Files changed (1) hide show
  1. agents/mcp/mcp_client.py +2 -14
agents/mcp/mcp_client.py CHANGED
@@ -1,4 +1,4 @@
1
- import anyio, asyncio, concurrent.futures
2
  from mcp.client.sse import sse_client
3
  from mcp.client.session import ClientSession, DEFAULT_CLIENT_INFO
4
 
@@ -53,16 +53,4 @@ def call_mcp_tool(mcp_url: str, tool_name: str, arguments: dict, timeout: int =
53
  Raises:
54
  Exception: If the MCP call fails
55
  """
56
- #return asyncio.run(call_mcp_tool_async(mcp_url, tool_name, arguments, timeout))
57
- try:
58
- loop = asyncio.get_event_loop()
59
-
60
- if loop.is_running():
61
- with concurrent.futures.ThreadPoolExecutor() as executor:
62
- future = executor.submit(asyncio.run, call_mcp_tool_async(mcp_url, tool_name, arguments, timeout))
63
-
64
- return future.result()
65
- else:
66
- return loop.run_until_complete(call_mcp_tool_async(mcp_url, tool_name, arguments, timeout))
67
- except RuntimeError:
68
- return asyncio.run(call_mcp_tool_async(mcp_url, tool_name, arguments, timeout))
 
1
+ import anyio, asyncio
2
  from mcp.client.sse import sse_client
3
  from mcp.client.session import ClientSession, DEFAULT_CLIENT_INFO
4
 
 
53
  Raises:
54
  Exception: If the MCP call fails
55
  """
56
+ return asyncio.run(call_mcp_tool_async(mcp_url, tool_name, arguments, timeout))