调通mcp tool

This commit is contained in:
玄凤科技
2025-03-20 11:52:37 +08:00
parent 8504c181c0
commit 2b81ebca8e
3 changed files with 53 additions and 59 deletions
+3 -2
View File
@@ -80,14 +80,15 @@ class MCPManager:
"""执行工具调用
Args:
tool_name: 工具名称
arguments: 工具参数
arguments: 工具参数
Returns:
Any: 工具执行结果
Raises:
ValueError: 工具未找到时抛出
"""
self.logger.bind(tag=TAG).info(f"Executing tool {tool_name} with arguments: {arguments}")
for client in self.client.values():
if any(tool_name == tool["name"] for tool in client.tools):
if client.has_tool(tool_name):
return await client.call_tool(tool_name, arguments)
raise ValueError(f"Tool {tool_name} not found in any MCP server")