From a58ddd588085acf19fcbfafbcc42804064753ae0 Mon Sep 17 00:00:00 2001 From: myifeng Date: Fri, 30 May 2025 09:20:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E5=88=A4=E6=96=AD=E5=A4=84?= =?UTF-8?q?=E7=90=86=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/connection.py | 4 ++-- main/xiaozhi-server/core/handle/mcpHandle.py | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index 1ea88e9b..b4d8dbfd 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -561,7 +561,7 @@ class ConnectionHandler: functions = None if self.intent_type == "function_call" and hasattr(self, "func_handler"): functions = self.func_handler.get_functions() - if self.mcp_client is not None: + if hasattr(self, "mcp_client"): mcp_tools = self.mcp_client.get_available_tools() if mcp_tools is not None and len(mcp_tools) > 0: if functions is None: @@ -688,7 +688,7 @@ class ConnectionHandler: # 处理MCP工具调用 if self.mcp_manager.is_mcp_tool(function_name): result = self._handle_mcp_tool_call(function_call_data) - elif self.mcp_client is not None and self.mcp_client.has_tool(function_name): + elif hasattr(self, "mcp_client") and self.mcp_client.has_tool(function_name): # 如果是MCP工具调用 self.logger.bind(tag=TAG).debug( f"调用MCP工具: {function_name}, 参数: {function_arguments}" diff --git a/main/xiaozhi-server/core/handle/mcpHandle.py b/main/xiaozhi-server/core/handle/mcpHandle.py index 838fb6bd..e03fe72f 100644 --- a/main/xiaozhi-server/core/handle/mcpHandle.py +++ b/main/xiaozhi-server/core/handle/mcpHandle.py @@ -164,8 +164,6 @@ async def handle_mcp_message(conn, mcp_client: MCPClient, payload: dict): else: await mcp_client.set_ready(True) conn.logger.bind(tag=TAG).info("所有工具已获取,MCP客户端准备就绪") - tool_result = await call_mcp_tool(conn, mcp_client, "self.get_device_status", {}) - print(f"Tool call result: {tool_result}") return # Handle method calls (requests from the client)