get_chat_info
Retrieve chat details like members, permissions, and settings from Telegram groups or channels using chat ID.
Instructions
Get details about a chat.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chat_id | Yes |
Implementation Reference
- aiogram_mcp/tools/chats.py:48-77 (handler)The implementation of the 'get_chat_info' MCP tool, which fetches chat details and member counts from the Telegram bot.
async def get_chat_info(chat_id: int) -> ChatInfoResult: """Get details about a chat.""" try: if ctx.rate_limiter: await ctx.rate_limiter.acquire() chat = await ctx.bot.get_chat(chat_id) member_count = None try: member_count = await ctx.bot.get_chat_member_count(chat_id=chat_id) except (TelegramBadRequest, TelegramForbiddenError): member_count = None result = ChatInfoResult( ok=True, id=chat.id, type=getattr(chat.type, "value", str(chat.type)), title=getattr(chat, "title", None), username=getattr(chat, "username", None), description=getattr(chat, "description", None), member_count=member_count, is_forum=getattr(chat, "is_forum", False), ) except (TelegramBadRequest, TelegramForbiddenError) as exc: result = ChatInfoResult(ok=False, error=str(exc)) if ctx.audit_logger: ctx.audit_logger.log( "get_chat_info", {"chat_id": chat_id}, result.ok, result.error ) return result - aiogram_mcp/tools/chats.py:14-22 (schema)Pydantic model defining the result structure for 'get_chat_info'.
class ChatInfoResult(ToolResponse): id: int | None = None type: str | None = None title: str | None = None username: str | None = None description: str | None = None member_count: int | None = None is_forum: bool | None = None - aiogram_mcp/tools/chats.py:45-45 (registration)Registration of the 'get_chat_info' tool within the FastMCP instance, inside the 'register_chat_tools' function.
if allowed_tools is None or "get_chat_info" in allowed_tools: