Skip to main content
Glama
sparfenyuk

Telegram MCP Server

ListDialogs

Retrieve available Telegram dialogs, chats, and channels with filtering options for unread, archived, or pinned conversations.

Instructions

List available dialogs, chats and channels.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
unreadNo
archivedNo
ignore_pinnedNo

Implementation Reference

  • The main handler function for the ListDialogs tool. It connects to Telegram, iterates over dialogs with specified filters (unread, archived, ignore_pinned), and returns formatted text contents listing dialog details.
    @tool_runner.register
    async def list_dialogs(
        args: ListDialogs,
    ) -> t.Sequence[TextContent | ImageContent | EmbeddedResource]:
        client: TelegramClient
        logger.info("method[ListDialogs] args[%s]", args)
    
        response: list[TextContent] = []
        async with create_client() as client:
            dialog: custom.dialog.Dialog
            async for dialog in client.iter_dialogs(archived=args.archived, ignore_pinned=args.ignore_pinned):
                if args.unread and dialog.unread_count == 0:
                    continue
                msg = (
                    f"name='{dialog.name}' id={dialog.id} "
                    f"unread={dialog.unread_count} mentions={dialog.unread_mentions_count}"
                )
                response.append(TextContent(type="text", text=msg))
    
        return response
  • Pydantic model defining the input schema for the ListDialogs tool, including optional filters for unread messages, archived dialogs, and ignoring pinned dialogs.
    class ListDialogs(ToolArgs):
        """List available dialogs, chats and channels."""
    
        unread: bool = False
        archived: bool = False
        ignore_pinned: bool = False
  • Dynamically discovers and registers all tools (including ListDialogs) by inspecting subclasses of ToolArgs in the tools module, creating Tool descriptions used in list_tools().
    @cache
    def enumerate_available_tools() -> t.Generator[tuple[str, Tool], t.Any, None]:
        for _, tool_args in inspect.getmembers(tools, inspect.isclass):
            if issubclass(tool_args, tools.ToolArgs) and tool_args != tools.ToolArgs:
                logger.debug("Found tool: %s", tool_args)
                description = tools.tool_description(tool_args)
                yield description.name, description
    
    
    mapping: dict[str, Tool] = dict(enumerate_available_tools())
  • MCP server endpoint that lists all registered tools, including ListDialogs, from the mapping.
    @app.list_tools()
    async def list_tools() -> list[Tool]:
        """List available tools."""
        return list(mapping.values())
  • MCP server endpoint that handles calls to tools like ListDialogs by parsing arguments, instantiating the schema, and dispatching to the tool_runner.
    @app.call_tool()
    async def call_tool(name: str, arguments: t.Any) -> Sequence[TextContent | ImageContent | EmbeddedResource]:  # noqa: ANN401
        """Handle tool calls for command line run."""
    
        if not isinstance(arguments, dict):
            raise TypeError("arguments must be dictionary")
    
        tool = mapping.get(name)
        if not tool:
            raise ValueError(f"Unknown tool: {name}")
    
        try:
            args = tools.tool_args(tool, **arguments)
            return await tools.tool_runner(args)
        except Exception as e:
            logger.exception("Error running tool: %s", name)
            raise RuntimeError(f"Caught Exception. Error: {e}") from e
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states what the tool does (listing) without mentioning permissions, rate limits, pagination, or response format. For a list tool with zero annotation coverage, this leaves critical behavioral traits unspecified, making it inadequate for safe and effective use.

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

Conciseness4/5

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

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, making it easy to parse quickly. However, it lacks depth, which affects completeness but not conciseness.

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

Completeness2/5

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

Given the tool's complexity (a list operation with 3 parameters), no annotations, no output schema, and low schema coverage, the description is incomplete. It doesn't explain what 'available' means, how results are returned, or parameter usage, leaving significant gaps for the agent to operate effectively.

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 description repeats the tool name and provides no information about parameters. With 3 parameters (unread, archived, ignore_pinned) and 0% schema description coverage, the schema only provides titles and types without explanations. The description fails to compensate by adding any meaning or context for these parameters, leaving them undocumented.

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

Purpose3/5

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

The description states the tool's purpose as listing available dialogs, chats, and channels, which is clear but vague. It uses the verb 'list' with the resources 'dialogs, chats and channels', but doesn't specify scope (e.g., all or filtered) or distinguish it from the sibling tool ListMessages. This makes it adequate but with gaps in specificity.

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. It doesn't mention the sibling tool ListMessages, prerequisites, or exclusions. Without any usage context, the agent must infer when this tool is appropriate, which is insufficient for effective tool selection.

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/sparfenyuk/mcp-telegram'

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