mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
@@ -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}"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user