Skip to main content
Glama

Get one chat's history

telegram_get_messages
Read-onlyIdempotent

Read or summarize one Telegram conversation or channel, recover agreements, or gather context for a reply. Returns message text/captions and available voice/video transcripts, not just links. Resolve the chat with telegram_find_chat first. The tools choose the account archive or connected Session. Use source/coverage/partial and message dates to interpret the result. Set since inclusively and before exclusively for a time range. When has_more=true, pass next_cursor as cursor with the same chat_id, since and before; never construct a cursor or page by subtracting time. Equal-second messages are preserved. Archive pages contain at most 200 messages; Session pages at most 50. Use effective_limit. A short or empty visible page can still have has_more=true; continue only when needed for the question. Stop at range_exhausted=true, sufficient context, or an error/no progress. range_exhausted means this traversal of the selected source reached its end, not that the archive contains all Telegram history. Results are not a fixed snapshot or an edit/deletion change log. Cursors expire after 15 minutes and can be invalidated by restart, cache eviction, account/route changes or Session replacement. Explain the interruption and restart the range explicitly; do not silently switch source or reconnect a working account. State the dates and coverage actually read; do not claim an exhaustive review from a limited sample. Archive history is limited to saved/imported messages; Session can read older messages accessible to that Telegram account without importing them. Reading through Session does not require channel ownership or a bot administrator. Existing readable archive content needs no new connection. Reading does not mark messages as read or send a reply. Messages include is_forwarded and forward_origin (original author/channel and Unix date when available). For forwards, from identifies who forwarded it in this chat, not the original author. Missing origin data does not prove authorship; never infer a hidden author's identity. Interpret errors and empty results separately, and explain the relevant next step briefly in the user's language. A thrown tool error or an error field in the response is not a successful empty read. Explain only the reported cause; respect retry delays and do not describe a timeout or temporary service failure as missing chats or lost permissions. If the cause is unknown, say so and suggest retrying or support at https://t.me/hellolemma. If the chat is missing from the archive or Session reports chat_not_available, resolve it again with telegram_find_chat using the known name, @username or public link. For a name lookup miss, follow telegram_find_chat guidance: try at most 3 untried name variants before asking for an exact reference. Confirm candidates found via a changed name before reading history or sending. Clarify ambiguous matches; do not invent a chat_id or claim that the chat does not exist in Telegram. If discovery still fails, follow that tool's recovery guidance. If the chat is found but count=0, check the requested since/before range and returned history_notice, setup_required, source, coverage and partial when present. For this read, use the user's known timezone; if none is known, silently use UTC without asking or adding a timezone caveat. Do not infer timezone from language. For calendar days such as today or yesterday, calculate since as inclusive midnight and before as the exclusive next midnight in that timezone, passing ISO 8601 timestamps with the correct UTC offset at each boundary rather than literal today/yesterday or offset-free dates. Keep rolling windows such as the last 24 hours distinct from calendar days. Do not silently broaden an explicitly requested period. Say that no messages were returned in the available history for that range, not that the conversation has never had messages. Use returned connection/history facts to distinguish an empty period, limited saved history and missing or disabled setup; a missing field does not establish a cause. For limited Bot API history, explain that only new messages delivered from included chats after connection are collected. Offer /import in https://t.me/lemma_telepath_bot for older exported history. Do not claim imports never happened if history_notice says otherwise. When setup is actually needed, offer only the relevant route: private chats via Telegram Chat Automation with @lemma_telepath_bot, selected chats and saved settings (/setup in the bot for device steps); channels you own or administer via /channels and adding the bot as administrator; groups via an administrator adding the bot as group administrator while the user is a member. Do not require reconnecting a working Session or connecting again to read usable archive content. Do not repeat identical empty requests or offer import/setup for every empty page. Use an already connected Session where supported; preserve source, coverage and actual errors. Do not suggest connecting or reconnecting Session unless the user explicitly asks for Session setup. Never switch sender automatically or request login codes/passwords in chat.

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": {
      "chat_id": "<chat_id>"
    },
    "name": "telegram_get_messages"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoHow many messages to return. Default 50; archive maximum 200, Session maximum 50 even when a larger limit is requested.
sinceNoOnly messages at or after this time. Accepts an ISO 8601 timestamp, unix seconds, 'today', 'yesterday', or a relative window like '24h' / '7d'.
beforeNoExclusive upper date bound. Keep unchanged with cursor. Accepts an ISO 8601 timestamp, unix seconds, 'today', 'yesterday', or a relative window like '24h' / '7d'.
cursorNoOpaque next_cursor from the previous history page. Keep chat_id, since and before unchanged.
chat_idYesChat id, from telegram_find_chat or telegram_list_chats.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • changedInput schema / properties / before / description
      Previous value: -"Only messages strictly older than this time, for paging back. Accepts an ISO 8601 timestamp, unix seconds, 'today', 'yesterday', or a relative window like '24h' / '7d'."New value: +"Exclusive upper date bound. Keep unchanged with cursor. Accepts an ISO 8601 timestamp, unix seconds, 'today', 'yesterday', or a relative window like '24h' / '7d'."
    • addedInput schema / properties / cursor
      Added value: +{
      +  "description": "Opaque next_cursor from the previous history page. Keep chat_id, since and before unchanged.",
      +  "maxLength": 4096,
      +  "minLength": 1,
      +  "type": "string"
      +}
  2. Changed1 schema field changed
    • changedInput schema / properties / limit / description
      Previous value: -"How many messages to return. Default 50."New value: +"How many messages to return. Default 50; archive maximum 200, Session maximum 50 even when a larger limit is requested."
  3. First observed

TDQS

A4.1/5.0
Behavior5/5

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

Annotations already declare a safe read (readOnlyHint, idempotentHint, destructiveHint=false), yet the description adds substantial behavior beyond them: source selection (archive vs Session), page sizes (200 vs 50), inclusive since/exclusive before semantics, cursor expiry after 15 minutes and what invalidates it, and that reading does not mark messages read. It also discloses limits ('Archive history is limited to saved/imported messages', Session can read older messages) and forward-provenance caveats about not inferring hidden authors. This is well beyond the annotation bar.

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

Conciseness2/5

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

Purpose and returns are front-loaded well, but the body is a single very long block that mixes pagination mechanics, timezone rules, error triage, import/setup upsell policies, and user-facing phrasing guidance. Several instructions are restated (not reconnecting a working Session, not repeating empty requests, not claiming imports never happened), which inflates length without adding decision value. Much of the error-recovery prose belongs in a separate guidance surface rather than a tool description.

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

Completeness5/5

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

For a paginated, multi-source read with no output schema, the description covers everything an agent needs: how to resolve the chat, how to iterate pages, how to tell empty from error, how to interpret source/coverage/partial/history_notice, and how to report results honestly. The behavioral and failure-mode coverage is thorough enough that an agent can act correctly without guessing.

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 coverage is 100%, so the baseline is 3; the description justifies going above it by adding cross-parameter rules the schema cannot express — cursor must be passed with the same chat_id, since and before, cursors must never be constructed or paged by subtracting time, and effective_limit should be used. The inclusive/exclusive boundary semantics are echoed from the schema, slightly redundant, but the cursor-consistency and limit guidance are genuinely additive.

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 specific verb and resource ('Read or summarize one Telegram conversation or channel') and clarifies the return surface ('message text/captions and available voice/video transcripts, not just links'), which separates it from link-only or metadata tools. It does not differentiate itself from close siblings such as telegram_recent_messages or telegram_search_messages, so an agent must infer that boundary. Still clearly more than a restatement of the name.

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?

Provides a concrete prerequisite ('Resolve the chat with telegram_find_chat first'), a continuation loop with explicit stop conditions ('range_exhausted=true, sufficient context, or an error/no progress'), and guidance on not broadening an explicitly requested period. It does not name keyword or recent-message siblings as alternatives for other use cases, leaving that inference to the agent. Overall strong context, but no explicit when-not-to-use routing.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources