Skip to main content
Glama

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
NameRequiredDescriptionDefault
chat_idYes

Implementation Reference

  • 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
  • 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
  • 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:

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