diff --git a/main/xiaozhi-server/core/handle/helloHandle.py b/main/xiaozhi-server/core/handle/helloHandle.py index 129b0aa7..cda7d17f 100644 --- a/main/xiaozhi-server/core/handle/helloHandle.py +++ b/main/xiaozhi-server/core/handle/helloHandle.py @@ -11,8 +11,7 @@ from core.handle.sendAudioHandle import sendAudioMessage, send_tts_message from core.utils.util import remove_punctuation_and_length, opus_datas_to_wav_bytes from core.providers.tools.device_mcp import ( MCPClient, - send_mcp_initialize_message, - send_mcp_tools_list_request, + send_mcp_initialize_message ) TAG = __name__ @@ -56,8 +55,6 @@ async def handleHelloMessage(conn, msg_json): conn.mcp_client = MCPClient() # 发送初始化 asyncio.create_task(send_mcp_initialize_message(conn)) - # 发送mcp消息,获取tools列表 - asyncio.create_task(send_mcp_tools_list_request(conn)) await conn.websocket.send(json.dumps(conn.welcome_msg)) diff --git a/main/xiaozhi-server/core/providers/tools/device_mcp/mcp_handler.py b/main/xiaozhi-server/core/providers/tools/device_mcp/mcp_handler.py index 457b22fc..d41c7adb 100644 --- a/main/xiaozhi-server/core/providers/tools/device_mcp/mcp_handler.py +++ b/main/xiaozhi-server/core/providers/tools/device_mcp/mcp_handler.py @@ -141,6 +141,11 @@ async def handle_mcp_message(conn, mcp_client: MCPClient, payload: dict): logger.bind(tag=TAG).debug( f"客户端MCP服务器信息: name={name}, version={version}" ) + + await asyncio.sleep(1) + logger.bind(tag=TAG).debug("初始化完成,开始请求MCP工具列表") + await send_mcp_tools_list_request(conn) + return elif msg_id == 2: # mcpToolsListID