get_chat_member_info
Retrieve role and user information for Telegram chat members by providing chat and user IDs.
Instructions
Return role and user info for a chat member.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chat_id | Yes | ||
| user_id | Yes |
Implementation Reference
- aiogram_mcp/tools/users.py:67-100 (handler)The handler function for the 'get_chat_member_info' MCP tool, which fetches chat member details using the aiogram bot instance.
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)) - aiogram_mcp/tools/users.py:66-67 (registration)Registration of the 'get_chat_member_info' tool using the @mcp.tool decorator.
@mcp.tool async def get_chat_member_info(chat_id: int, user_id: int) -> ChatMemberInfoResult: