From a03a0a73db278a1428d4a4413627a95878d39dfa Mon Sep 17 00:00:00 2001 From: yillkid Date: Fri, 4 Sep 2026 19:00:24 +0800 Subject: [PATCH] fix: send server hello before MCP initialize The MCP initialize task was scheduled before the server hello was sent, so the MCP frame could reach the device first. ESP32 firmware waits for the server hello before it treats the channel as ready, so the device never answered the initialize request. Refs #3347 --- main/xiaozhi-server/core/handle/helloHandle.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/xiaozhi-server/core/handle/helloHandle.py b/main/xiaozhi-server/core/handle/helloHandle.py index 2f84a7b16..3f4a11e3b 100644 --- a/main/xiaozhi-server/core/handle/helloHandle.py +++ b/main/xiaozhi-server/core/handle/helloHandle.py @@ -54,14 +54,16 @@ async def handleHelloMessage(conn: "ConnectionHandler", msg_json): if features.get("mcp"): conn.logger.bind(tag=TAG).debug("客户端支持MCP") conn.mcp_client = MCPClient() - # 发送初始化 - asyncio.create_task(send_mcp_initialize_message(conn)) if features.get("aec"): conn.logger.bind(tag=TAG).debug("客户端启用了服务端AEC") conn.client_aec = True await conn.websocket.send(json.dumps(conn.welcome_msg)) + # The device waits for the server hello before processing MCP messages. + if features and features.get("mcp"): + asyncio.create_task(send_mcp_initialize_message(conn)) + async def checkWakeupWords(conn: "ConnectionHandler", text): enable_wakeup_words_response_cache = conn.config[