mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 00:53:54 +08:00
独立处理MCP Message
This commit is contained in:
@@ -4,6 +4,7 @@ import json
|
||||
import random
|
||||
import shutil
|
||||
import asyncio
|
||||
from core.handle.mcpHandle import send_mcp_initialized, send_mcp_tools_list
|
||||
from core.handle.sendAudioHandle import send_stt_message
|
||||
from core.utils.util import remove_punctuation_and_length
|
||||
from core.providers.tts.dto.dto import ContentType, InterfaceType
|
||||
@@ -38,24 +39,9 @@ async def handleHelloMessage(conn, msg_json):
|
||||
if features.get("mcp"):
|
||||
conn.logger.bind(tag=TAG).info("客户端支持MCP")
|
||||
# 发送初始化
|
||||
await conn.websocket.send(json.dumps({
|
||||
"type": "mcp",
|
||||
"payload": {
|
||||
"jsonrpc": "2.0",
|
||||
"method": "notifications/initialized"
|
||||
}
|
||||
}))
|
||||
asyncio.create_task(send_mcp_initialized(conn))
|
||||
# 发送mcp消息,获取tools列表
|
||||
await conn.websocket.send(json.dumps( {
|
||||
"type": "mcp",
|
||||
"payload": {
|
||||
"jsonrpc": "2.0",
|
||||
"method": "tools/list",
|
||||
"id": 10001,
|
||||
"params": {
|
||||
}
|
||||
}
|
||||
}))
|
||||
asyncio.create_task(send_mcp_tools_list(conn))
|
||||
|
||||
await conn.websocket.send(json.dumps(conn.welcome_msg))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user