get_chat_info
Retrieve current chat window details including participants and conversation context for WeChat automation workflows.
Instructions
获取当前聊天窗口信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/wxauto_mcp/wxauto_mcp/api_contacts.py:121-124 (registration)Tool registration using @tool decorator with name and description
@tool( name="get_chat_info", description="获取当前聊天窗口信息" ) - Handler function that retrieves and formats chat information from WeChatWrapper
def get_chat_info() -> str: """ 获取当前聊天信息 Returns: JSON 格式的聊天信息 """ wrapper = _get_wrapper() if not wrapper: return format_result(False, "微信未初始化") try: info = wrapper.get_chat_info() if not info: return format_result(False, "无法获取聊天信息") return format_result(True, "获取成功", {"chat_info": info}) except Exception as e: logger.error(f"获取聊天信息失败: {e}") return format_result(False, f"获取聊天信息失败: {e}") - Core implementation that calls wxautox4's ChatInfo() method to retrieve current chat window information
@require_online def get_chat_info(self) -> dict[str, Any]: """ 获取当前聊天信息 Returns: dict: 聊天信息 """ try: return self.wx.ChatInfo() except Exception as e: logger.error(f"获取聊天信息失败: {e}") return {}