proxy_tool_call
Facilitates dynamic tool execution within the MCP Server For Local by accepting dictionary-formatted requests, enabling seamless integration and interaction with external tools.
Instructions
代理工具,根据工具名动态调用其他服务端的工具,输入格式为字典:{'tool': 'tool_name', 'args': {...}}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- src/mcp/proxy/proxy_server.py:131-154 (handler)The proxy_tool_call handler function that dynamically routes tool calls to appropriate backend servers based on tool_mapping.@mcp.tool(description="代理工具,根据工具名动态调用其他服务端的工具,输入格式为字典:{'tool': 'tool_name', 'args': {...}}") async def proxy_tool_call(params: Dict[str, Any]) -> str: """代理工具调用""" try: tool_name = params.get("tool") tool_args = params.get("args", {}) if not tool_name: return "⚠️ 工具名称缺失" if tool_name not in tool_mapping: return f"⚠️ 未知工具: {tool_name}" server_name = tool_mapping[tool_name] if server_name not in sessions: return f"⚠️ 服务器 {server_name} 未连接" session = sessions[server_name] result = await session.call_tool(tool_name, tool_args) return result.content[0].text except Exception as e: logger.error(f"Tool call error: {str(e)}") return f"⚠️ 工具调用失败: {str(e)}"