From 231ae8dfa6fdd5f6e297056ccc60572d4fcbd2b6 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Mon, 16 Jun 2025 23:16:40 +0800 Subject: [PATCH] =?UTF-8?q?update:=E4=BF=AE=E5=A4=8Diot=E4=B8=8D=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/handle/functionHandler.py | 4 ++++ main/xiaozhi-server/core/handle/iotHandle.py | 3 +-- main/xiaozhi-server/core/mcp/manager.py | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/main/xiaozhi-server/core/handle/functionHandler.py b/main/xiaozhi-server/core/handle/functionHandler.py index 9650a31b..4d7c55e9 100644 --- a/main/xiaozhi-server/core/handle/functionHandler.py +++ b/main/xiaozhi-server/core/handle/functionHandler.py @@ -22,6 +22,10 @@ class FunctionHandler: self.register_config_functions() self.functions_desc = self.function_registry.get_all_function_desc() self.finish_init = True + + def upload_functions_desc(self): + self.functions_desc = self.function_registry.get_all_function_desc() + def current_support_functions(self): func_names = [] diff --git a/main/xiaozhi-server/core/handle/iotHandle.py b/main/xiaozhi-server/core/handle/iotHandle.py index 27d751a4..6406c659 100644 --- a/main/xiaozhi-server/core/handle/iotHandle.py +++ b/main/xiaozhi-server/core/handle/iotHandle.py @@ -338,8 +338,7 @@ async def handleIotDescriptors(conn, descriptors): # 如果注册了新函数,更新function描述列表 if functions_changed and hasattr(conn, "func_handler"): - - conn.func_handler.functions_desc = conn.func_handler.function_registry.get_all_function_desc() + conn.func_handler.upload_functions_desc() func_names = conn.func_handler.current_support_functions() conn.logger.bind(tag=TAG).info(f"设备类型: {type_id}") diff --git a/main/xiaozhi-server/core/mcp/manager.py b/main/xiaozhi-server/core/mcp/manager.py index 9580f862..dc2f9de9 100644 --- a/main/xiaozhi-server/core/mcp/manager.py +++ b/main/xiaozhi-server/core/mcp/manager.py @@ -75,6 +75,7 @@ class MCPManager: self.conn.logger.bind(tag=TAG).error( f"Failed to initialize MCP server {name}: {e}" ) + self.conn.func_handler.upload_functions_desc() def get_all_tools(self) -> List[Dict[str, Any]]: """获取所有服务的工具function定义