Skip to main content
Glama
cluic
by cluic

get_my_info

Retrieve your WeChat account details to access profile information and settings for automation workflows.

Instructions

获取我的微信账号信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for get_my_info tool. It's decorated with @tool for registration, gets the WeChatWrapper instance, calls wrapper.wx.GetMyInfo() from the wxautox4 library, and returns the account information as a JSON string.
    @tool(
        name="get_my_info",
        description="获取我的微信账号信息"
    )
    def get_my_info() -> str:
        """
        获取我的微信账号信息
    
        Returns:
            JSON 格式的账号信息
        """
        wrapper = _get_wrapper()
        if not wrapper:
            return format_result(False, "微信未初始化,请先调用 wechat_initialize")
    
        try:
            my_info = wrapper.wx.GetMyInfo()
            if not my_info:
                return format_result(False, "无法获取账号信息")
    
            return format_result(True, "获取成功", my_info)
        except Exception as e:
            logger.error(f"获取账号信息失败: {e}")
            return format_result(False, f"获取账号信息失败: {e}")
  • Tool registration using the @tool decorator from rpc module, registering get_my_info with its name and description for the MCP protocol.
    @tool(
        name="get_my_info",
        description="获取我的微信账号信息"
    )
  • Helper method in WeChatWrapper that also calls wrapper.wx.GetMyInfo() to get account info and returns it as a structured WeChatStatus object.
    def get_status(self) -> WeChatStatus:
        """
        获取微信状态
    
        Returns:
            WeChatStatus: 状态信息
        """
        try:
            if not self.is_online():
                return WeChatStatus(is_online=False, is_activated=self._is_activated)
    
            my_info = self.wx.GetMyInfo()
            return WeChatStatus(
                is_online=True,
                account_name=my_info.get("微信名"),
                account_id=my_info.get("微信号"),
                is_activated=self._is_activated
            )
        except Exception as e:
            logger.error(f"获取状态失败: {e}")
            return WeChatStatus(is_online=False, is_activated=self._is_activated)
  • Data schema/model defining the structure for WeChat account information including account_name and account_id fields which are populated from GetMyInfo() results.
    @dataclass
    class WeChatStatus:
        """
        微信状态模型
    
        Attributes:
            is_online: 是否在线
            account_name: 账号名称
            account_id: 微信号
            is_activated: 是否已激活
        """
        is_online: bool
        account_name: Optional[str] = None
        account_id: Optional[str] = None
        is_activated: bool = False
    
        def to_dict(self) -> dict[str, Any]:
            """转换为字典"""
            return {
                "is_online": self.is_online,
                "account_name": self.account_name,
                "account_id": self.account_id,
                "is_activated": self.is_activated
            }
  • Helper function used by get_my_info to retrieve the WeChatWrapper singleton instance, handling import errors gracefully.
    def _get_wrapper() -> Optional["WeChatWrapper"]:
        """获取 WeChatWrapper 实例"""
        if not WECHAT_AVAILABLE:
            return None
        try:
            return get_wechat()
        except Exception as e:
            logger.error(f"获取 WeChat 实例失败: {e}")
            return None

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