From a58ddd588085acf19fcbfafbcc42804064753ae0 Mon Sep 17 00:00:00 2001 From: myifeng Date: Fri, 30 May 2025 09:20:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=A4=84=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) From 33d5761194f64ae5ce8475179d7e64cdbcd000dc Mon Sep 17 00:00:00 2001 From: myifeng Date: Fri, 30 May 2025 09:30:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?FIX=20=E9=94=99=E8=AF=AF=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins_func/functions/handle_speaker_or_screen.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main/xiaozhi-server/plugins_func/functions/handle_speaker_or_screen.py b/main/xiaozhi-server/plugins_func/functions/handle_speaker_or_screen.py index 8547c985..f89f30b0 100644 --- a/main/xiaozhi-server/plugins_func/functions/handle_speaker_or_screen.py +++ b/main/xiaozhi-server/plugins_func/functions/handle_speaker_or_screen.py @@ -102,11 +102,11 @@ handle_device_function_desc = { } -# @register_function( -# "handle_speaker_volume_or_screen_brightness", -# handle_device_function_desc, -# ToolType.IOT_CTL, -# ) +@register_function( + "handle_speaker_volume_or_screen_brightness", + handle_device_function_desc, + ToolType.IOT_CTL, +) def handle_speaker_volume_or_screen_brightness( conn, device_type: str, action: str, value: int = None ):