Skip to main content
Glama
Telegram Context MCP

Telegram Context MCP

by egor-fedorov

search_messages

Read-only

Search permitted Telegram chats for messages by keyword, date range, chat or folder, sender, link presence, content type, or direction, with cursor-based pagination.

Instructions

Search permitted chats with early results, sorted within each page by default.

    ordering=page visits sources fairly without waiting for every source. Ordering
    between pages is not guaranteed. Use ordering=global for a strictly ordered
    traversal, which can require empty preparation pages. The response reports the
    actual ordering guarantee. order chooses newest_first or oldest_first. Repeat
    both parameters with a cursor. Restricted searches only fetch permitted chats.

    Dates include a timezone; interval is [date_from, date_to). Folder IDs form a union;
    explicit chat_ids intersect that union. Omitted selectors use all permitted dialogs.
    has_link=true selects URL-bearing posts, independently of content_type.
    include_button_urls=true also matches links in buttons and implies has_link=true.
    Supply chat_ids or folder_ids and both dates. Keywords still search the post text.
    An empty query also permits direction=incoming/outgoing with explicit chat_ids or
    folder_ids. Direction uses Telegram's outgoing flag; repeat it with the cursor.
    has_link=false excludes links. Omit it for either kind.
    Uses Telegram keyword search, not semantic search. Native sender search and local
    date/content filtering are combined. Partial/empty pages may carry next_cursor.
    Configured public-channel access applies only to explicit chat_ids, never implicit scope.
    Temporary failures retain next_cursor; respect retry_after_seconds before continuing.
    

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>"
    },
    "name": "search_messages"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
orderNonewest_first
queryYes
cursorNo
date_toNo
chat_idsNo
has_linkNo
orderingNopage
date_fromNo
directionNoall
sender_idNo
folder_idsNo
content_typeNo
include_button_urlsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.8.1
    • addedInput schema / properties / include_button_urls
      Added value: +{
      +  "default": false,
      +  "title": "Include Button Urls",
      +  "type": "boolean"
      +}
  2. Changed1 schema field changedv0.7.0
    • addedInput schema / properties / direction
      Added value: +{
      +  "default": "all",
      +  "enum": [
      +    "all",
      +    "incoming",
      +    "outgoing"
      +  ],
      +  "title": "Direction",
      +  "type": "string"
      +}
  3. First observedv0.6.0

TDQS

A4.1/5.0
Behavior5/5

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

With readOnlyHint and openWorldHint already covering the safety profile, the description adds substantial non-obvious behavior: ordering is only guaranteed within a page, pages may be empty while preparing, partial/empty pages may still carry next_cursor, temporary failures retain the cursor and require respecting retry_after_seconds. These are exactly the operational caveats an agent needs and cannot get from annotations or schema.

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

Conciseness3/5

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

Almost every sentence carries information, but the text is a run-on block with the purpose buried behind a pagination aside ('sorted within each page by default') rather than front-loaded. Grouping into ordering, filtering, and error/retry sections would make the same content far easier to scan.

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

Completeness4/5

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

For a 14-parameter search tool with no output schema, the description covers ordering guarantees, cursor reuse, filtering semantics, retry behavior, and what the response reports. The remaining shortfall is that page size (limit) and the concrete shape of returned results are left entirely to the schema.

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

Parameters4/5

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

Schema description coverage is 0%, so the description carries the burden, and it does so for most parameters: the date interval is half-open [date_from, date_to), folder_ids form a union while explicit chat_ids intersect it, omitted selectors default to all dialogs, has_link=false excludes links and omitting it means either, and include_button_urls implies has_link=true. Gaps remain: limit is never mentioned, and sender_id is only obliquely implied by 'Native sender search'.

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

Purpose4/5

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

The opening states a concrete verb and resource ('Search permitted chats') and adds scope-defining qualifiers — Telegram keyword search, not semantic, restricted to permitted chats, with configured public-channel access only via explicit chat_ids. That distinguishes it well from search_public_channels behaviorally, though it never names a sibling tool outright.

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

Usage Guidelines4/5

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

Rich conditional guidance: ordering=page vs ordering=global for a strictly ordered traversal, has_link/include_button_urls for URL filtering, and the rule that an empty query permits direction=incoming/outgoing only with explicit chat_ids or folder_ids. It stops short of naming alternative tools or stating when not to use this one.

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