Files
xiaozhi-esp32-server/main/xiaozhi-server/core/handle/textHandler/mcpMessageHandler.py
T

22 lines
735 B
Python
Raw Normal View History

2025-09-03 09:43:34 +08:00
import asyncio
from typing import Dict, Any, TYPE_CHECKING
2025-09-03 09:43:34 +08:00
if TYPE_CHECKING:
from core.connection import ConnectionHandler
2025-09-03 09:43:34 +08:00
from core.handle.textMessageHandler import TextMessageHandler
from core.handle.textMessageType import TextMessageType
from core.providers.tools.device_mcp import handle_mcp_message
class McpTextMessageHandler(TextMessageHandler):
"""MCP消息处理器"""
@property
def message_type(self) -> TextMessageType:
return TextMessageType.MCP
async def handle(self, conn: "ConnectionHandler", msg_json: Dict[str, Any]) -> None:
2025-09-03 09:43:34 +08:00
if "payload" in msg_json:
asyncio.create_task(
handle_mcp_message(conn, conn.mcp_client, msg_json["payload"])
)