Skip to main content
Glama
cluic
by cluic

get_recent_groups

Retrieve recent WeChat group chats for automation workflows, enabling AI assistants to access and manage conversation lists through the wxauto MCP Server.

Instructions

获取最近群聊列表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler function for get_recent_groups. This function is decorated with @tool and processes requests to retrieve recent group chats. It calls the WeChatWrapper.get_recent_groups() method, handles exceptions, and formats the result using format_result helper.
    @tool(
        name="get_recent_groups",
        description="获取最近群聊列表"
    )
    def get_recent_groups() -> str:
        """
        获取最近群聊列表
    
        Returns:
            JSON 格式的群聊列表
        """
        wrapper = _get_wrapper()
        if not wrapper:
            return format_result(False, "微信未初始化")
    
        try:
            groups = wrapper.get_recent_groups()
            if not groups:
                return format_result(True, "无群聊数据", {"groups": []})
    
            return format_result(
                True,
                f"获取成功,共 {len(groups)} 个群聊",
                {"groups": [{"name": g} for g in groups]}
            )
        except Exception as e:
            logger.error(f"获取群聊列表失败: {e}")
            return format_result(False, f"获取群聊列表失败: {e}")
  • Tool registration decorator that registers get_recent_groups as an MCP tool with its name and description.
    @tool(
        name="get_recent_groups",
        description="获取最近群聊列表"
    )
  • Core implementation in WeChatWrapper class that calls the wxauto library's GetAllRecentGroups() method to fetch recent group chat list from WeChat. Decorated with @require_online to ensure WeChat is connected.
    def get_recent_groups(self) -> list[str]:
        """
        获取最近群聊列表
    
        Returns:
            list[str]: 群聊名称列表
        """
        try:
            groups = self.wx.GetAllRecentGroups()
            if isinstance(groups, list):
                return groups
            return []
        except Exception as e:
            logger.error(f"获取群聊列表失败: {e}")
            return []

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cluic/wxauto-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server