Skip to main content
Glama

get_chat_member_info

Retrieve role and user information for a specific chat member by providing chat and user IDs. Use this to check permissions or profile details.

Instructions

Return role and user info for a chat member.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chat_idYes
user_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYes
errorNo
chat_idNo
user_idNo
statusNo
usernameNo
first_nameNo
last_nameNo
language_codeNo
is_botNo

Implementation Reference

  • The actual handler function for the get_chat_member_info tool. It checks if the chat is allowed, calls bot.get_chat_member(), and returns a ChatMemberInfoResult with the member's status and user info.
    @mcp.tool
    async def get_chat_member_info(chat_id: int, user_id: int) -> ChatMemberInfoResult:
        """Return role and user info for a chat member."""
        if not ctx.is_chat_allowed(chat_id):
            result = ChatMemberInfoResult(
                ok=False, error=f"Chat {chat_id} is not allowed."
            )
            if ctx.audit_logger:
                ctx.audit_logger.log(
                    "get_chat_member_info",
                    {"chat_id": chat_id, "user_id": user_id},
                    result.ok,
                    result.error,
                )
            return result
    
        try:
            if ctx.rate_limiter:
                await ctx.rate_limiter.acquire()
            member = await ctx.bot.get_chat_member(chat_id=chat_id, user_id=user_id)
            user = member.user
            status = member.status.value if hasattr(member.status, "value") else str(member.status)
            result = ChatMemberInfoResult(
                ok=True,
                chat_id=chat_id,
                user_id=user.id,
                status=status,
                username=user.username,
                first_name=user.first_name,
                last_name=user.last_name,
                language_code=user.language_code,
                is_bot=user.is_bot,
            )
        except (TelegramBadRequest, TelegramForbiddenError) as exc:
            result = ChatMemberInfoResult(ok=False, error=str(exc))
    
        if ctx.audit_logger:
            ctx.audit_logger.log(
                "get_chat_member_info",
                {"chat_id": chat_id, "user_id": user_id},
                result.ok,
                result.error,
            )
        return result
  • ChatMemberInfoResult Pydantic model defines the output schema for get_chat_member_info, including chat_id, user_id, status, username, first_name, last_name, language_code, is_bot fields.
    class ChatMemberInfoResult(ToolResponse):
        chat_id: int | None = None
        user_id: int | None = None
        status: str | None = None
        username: str | None = None
        first_name: str | None = None
        last_name: str | None = None
        language_code: str | None = None
        is_bot: bool | None = None
  • Registration via @mcp.tool decorator inside register_user_tools(), gated by allowed_tools check for 'get_chat_member_info'. Called from server.py line 89.
    if allowed_tools is None or "get_chat_member_info" in allowed_tools:
    
        @mcp.tool
        async def get_chat_member_info(chat_id: int, user_id: int) -> ChatMemberInfoResult:
            """Return role and user info for a chat member."""
            if not ctx.is_chat_allowed(chat_id):
                result = ChatMemberInfoResult(
                    ok=False, error=f"Chat {chat_id} is not allowed."
                )
                if ctx.audit_logger:
                    ctx.audit_logger.log(
                        "get_chat_member_info",
                        {"chat_id": chat_id, "user_id": user_id},
                        result.ok,
                        result.error,
                    )
                return result
    
            try:
                if ctx.rate_limiter:
                    await ctx.rate_limiter.acquire()
                member = await ctx.bot.get_chat_member(chat_id=chat_id, user_id=user_id)
                user = member.user
                status = member.status.value if hasattr(member.status, "value") else str(member.status)
                result = ChatMemberInfoResult(
                    ok=True,
                    chat_id=chat_id,
                    user_id=user.id,
                    status=status,
                    username=user.username,
                    first_name=user.first_name,
                    last_name=user.last_name,
                    language_code=user.language_code,
                    is_bot=user.is_bot,
                )
            except (TelegramBadRequest, TelegramForbiddenError) as exc:
                result = ChatMemberInfoResult(ok=False, error=str(exc))
    
            if ctx.audit_logger:
                ctx.audit_logger.log(
                    "get_chat_member_info",
                    {"chat_id": chat_id, "user_id": user_id},
                    result.ok,
                    result.error,
                )
            return result
  • Server calls register_user_tools() to register all user tools including get_chat_member_info.
    register_user_tools(self._mcp, self._ctx, allowed_tools=at)
  • Permission mapping: get_chat_member_info is assigned PermissionLevel.READ, meaning it's available at the lowest permission tier.
    "get_chat_member_info": PermissionLevel.READ,
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must fully disclose behavior. It only states that the tool returns data, implying it is read-only, but does not confirm safety (e.g., no side effects, no permissions required). No disclaimers about rate limits or error conditions are provided.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence of 8 words. It immediately states the core function without any fluff or redundancy, making it efficient for AI processing.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the existence of an output schema (which would document return fields), the description can be minimal. However, it lacks any behavioral cues, error handling notes, or usage context. The tool is simple but the description still feels incomplete for an AI agent that needs to decide when to invoke it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage for parameters, and the description does not elaborate on chat_id or user_id (e.g., format, source, constraints). The tool name and description imply the parameters' roles, but the AI must infer their meanings without explicit help.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it returns role and user info for a chat member, and the required parameters (chat_id, user_id) reinforce that it targets a specific member. Among sibling tools, this uniquely retrieves detailed info for a single member, differentiating it from get_chat_info (chat-level) and get_chat_members_count (count-only).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as get_chat_info or get_user_profile_photos. It does not mention prerequisites, excluded cases, or when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Py2755/aiogram-mcp'

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