diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index 04f79970..da0e6b46 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -581,7 +581,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: @@ -707,7 +707,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) 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 ):