Skip to main content
Glama

messages_read_history

Read-onlyIdempotent

Read messages from a conversation thread. Use text_contains to find specific messages by content; media_type (photo, document, video, voice, link), date_from/date_to (YYYY-MM-DD, inclusive) and direction (incoming, outgoing) narrow the search and work without text: a photo with no caption sent by the other side in a given month is media_type='photo', direction='incoming' and the dates. A search runs over the loaded part of the conversation and, when that is not all of it, asks the channel's own server (Telegram) to search the rest and stores the hits (a search with text_contains also stores the neighbouring messages of its first 20 hits; one without words stores the hits alone). search_coverage says which: complete = true with a source, or complete = false with the reason, in which case an empty list is not proof the text is absent. sync.loaded_from is the date since which EVERY message is stored (null when unknown); sync.oldest_stored_at is the oldest message stored at all, gaps or not. Returns the most recent messages, including sender info and timestamps. A message in a forum topic (Telegram supergroup with Topics) carries topic_id and, when known, topic (its name); pass that topic_id to messages.send to post into the same topic. A message people reacted to carries reactions (which emoji, who, when): a reaction is often the answer itself, e.g. a thumbs-up under a draft.

Voice calls: each row carries a meta object with allowlisted keys (event_type ∈ 'call_started'|'call_ended'|null, source ∈ 'voice_transcript'|null, call_id, speaker_display_name, duration_seconds, outcome, direction) plus per-message channel. To find calls without scanning every row, use calls.list_history instead.

An outgoing message the channel reported as NOT delivered (an e-mail bounce, a WhatsApp Business failed status) carries meta.delivery_error (the reason) and, for e-mail, meta.delivery_error_recipient: it was accepted for sending but did not arrive, so do not treat it as delivered. With meta.delivery_error_guessed the bounce did not say which mail failed and the latest one to that address was marked: say it probably did not arrive.

A file that was never received carries meta.media_skipped (reason, e.g. 'too_large', size_bytes, limit_bytes): the channel did not let us download it, so there is no file to read; the sender can send a link instead.

Usage:

  1. Get thread_id from threads.list first, OR

  2. Use contact_name to auto-resolve thread_id

Examples:

  • User: 'show me messages from chat with [contact]' → read_history(contact_name='[contact]', limit=10)

  • User: 'last 5 messages from thread 571' → read_history(thread_id=571, limit=5)

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "messages_read_history"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMaximum number of messages to return (default: 10, max: 100)
beforeNoCursor for the page of OLDER messages of a chat read live (`source: "live"`, a Discord channel that is not synced): pass the previous answer's `next_before`. Pages hold at most 100 messages (limit). A stored chat pages with offset instead (the answer's `next_offset`). OMIT for the newest page.
offsetNoNumber of messages to skip (for pagination, default: 0)
date_toNoFilter: only messages sent on or before this day (YYYY-MM-DD, UTC).
date_fromNoFilter: only messages sent on or after this day (YYYY-MM-DD, UTC).
directionNoFilter: 'incoming' = written by the other side, 'outgoing' = written by the owner of the connected account. OMIT for both.
thread_idNoThread ID from threads.list (e.g. '571'), or a channel_ref (e.g. 'telegram:1306644770'). Optional if contact_name provided.
load_untilNoLoad this conversation's history down to this day (YYYY-MM-DD, UTC) in the background, a page at a time. For a channel whose server cannot search (WhatsApp), or to read everything around a date. The answer's `history_load` says how far back the history reaches now and, once the run is over, why it stopped; call again to follow it. OMIT for a normal read.
media_typeNoFilter: only messages carrying this kind of attachment. Works without text_contains, which is how a photo or document sent without a caption is found. OMIT for every kind.
contact_nameNoContact/thread name to search for (optional if thread_id provided). Example: 'Jane Smith', 'John Doe'
in_workspaceNoRun this one call in this workspace id instead of the session's. Nothing is stored; other sessions are not affected.
text_containsNoFilter: only return messages containing this text (case-insensitive substring match)
include_outgoingNoInclude messages sent by you (default: true)
channel_account_idNoConnected account the conversation must belong to, when you know it (from channels.list). Scopes the lookup to that account, so the same person reached on two connected accounts cannot be confused for one, and a chat that does not exist on this account is 'not found' instead of someone else's thread with a matching id.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / before
      Added value: +{
      +  "description": "Cursor for the page of OLDER messages of a chat read live (`source: \"live\"`, a Discord channel that is not synced): pass the previous answer's `next_before`. Pages hold at most 100 messages (limit). A stored chat pages with offset instead (the answer's `next_offset`). OMIT for the newest page.",
      +  "type": "string"
      +}
  2. Changed1 schema field changed
    • addedInput schema / properties / load_until
      Added value: +{
      +  "description": "Load this conversation's history down to this day (YYYY-MM-DD, UTC) in the background, a page at a time. For a channel whose server cannot search (WhatsApp), or to read everything around a date. The answer's `history_load` says how far back the history reaches now and, once the run is over, why it stopped; call again to follow it. OMIT for a normal read.",
      +  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      +  "type": "string"
      +}
  3. Changed4 schema fields changed
    • addedInput schema / properties / date_from
      Added value: +{
      +  "description": "Filter: only messages sent on or after this day (YYYY-MM-DD, UTC).",
      +  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      +  "type": "string"
      +}
    • addedInput schema / properties / date_to
      Added value: +{
      +  "description": "Filter: only messages sent on or before this day (YYYY-MM-DD, UTC).",
      +  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      +  "type": "string"
      +}
    • addedInput schema / properties / direction
      Added value: +{
      +  "description": "Filter: 'incoming' = written by the other side, 'outgoing' = written by the owner of the connected account. OMIT for both.",
      +  "enum": [
      +    "incoming",
      +    "outgoing"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / media_type
      Added value: +{
      +  "description": "Filter: only messages carrying this kind of attachment. Works without text_contains, which is how a photo or document sent without a caption is found. OMIT for every kind.",
      +  "enum": [
      +    "photo",
      +    "document",
      +    "video",
      +    "voice",
      +    "link"
      +  ],
      +  "type": "string"
      +}
  4. Changed1 schema field changed
    • addedInput schema / properties / channel_account_id
      Added value: +{
      +  "description": "Connected account the conversation must belong to, when you know it (from channels.list). Scopes the lookup to that account, so the same person reached on two connected accounts cannot be confused for one, and a chat that does not exist on this account is 'not found' instead of someone else's thread with a matching id.",
      +  "type": "string"
      +}
  5. Changed1 schema field changed
    • addedInput schema / properties / in_workspace
      Added value: +{
      +  "description": "Run this one call in this workspace id instead of the session's. Nothing is stored; other sessions are not affected.",
      +  "type": "integer"
      +}
  6. Added
  7. Removed
  8. Changed1 schema field changed
    • removedInput schema / properties / offset / default
      Removed value: -0
  9. First observed

TDQS

A4.3/5.0
Behavior5/5

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

Annotations only declare readOnly/idempotent/non-destructive; the description goes far beyond by disclosing that a search may query the channel's own server and store the hits plus neighbouring messages, and by explaining `search_coverage.complete`, `sync.loaded_from` vs `sync.oldest_stored_at`, and that an empty list is not proof of absence. It also pre-decodes return fields an agent would otherwise misread: `meta.delivery_error` (accepted but not delivered), `media_skipped` (no file exists to read), reactions, and forum `topic_id` reuse.

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?

Front-loaded with purpose, then filters, then return-field semantics, then usage and examples — a sensible ordering with no filler sentences. The long parenthetical sentence describing search-hit storage is dense and would read better split, costing it the top score.

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 14-parameter tool with no output schema, the description carries the return-value burden thoroughly: coverage semantics, sync bounds, delivery failures, skipped media, topic ids, and call metadata. An agent has enough to interpret an empty result correctly and to avoid treating an undelivered message as delivered.

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?

With 100% schema coverage the baseline is 3, and the description earns above that by showing how filters compose without text: 'photo with no caption sent by the other side in a given month is media_type=photo, direction=incoming and the dates'. It adds less for limit/offset/before/load_until, whose semantics live almost entirely in the schema.

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?

"Read messages from a conversation thread" is a specific verb+resource, and the tool's scope (a single thread, with filter narrowing) is stated up front. It explicitly routes voice-call lookups to `calls.list_history`, but never distinguishes itself from the obvious cross-thread alternative `search_messages`, leaving one sibling boundary to inference.

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?

The numbered Usage block gives concrete prerequisites (get thread_id from threads.list, or auto-resolve via contact_name) and two worked examples mapping user phrasing to arguments. It also names a when-not case (calls → `calls.list_history`), but gives no guidance on when to prefer this over a global message search.

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