Skip to main content
Glama
telegram-archive-mcp

telegram-archive-mcp

by GeiserX

Search one chat

search_messages
Read-onlyIdempotent

Search a specific Telegram chat for a keyword, newest first, returning matching messages; use each hit's id to read surrounding context.

Instructions

Search the messages of one chat for a keyword, newest first, and return the matching messages with the same fields as get_messages. Use search_all_chats when you do not know the chat. To read the conversation around a hit, pass its id to get_message_context.

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>",
      "query": "<query>"
    },
    "name": "search_messages"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMaximum messages to return, 1 to 200 (default 20).
queryYesText to find in the message text (e.g. "invoice").
chat_idYesThe chat's ref, as list_chats or search_all_chats returns it (an opaque string; not the numeric Telegram id).
topic_idNoForum topic id from get_topics; keeps only that topic's messages. 1 is the General topic. Omit for the whole chat.

Output Schema

NameRequiredDescriptionDefault
messagesNoArchived messages as the viewer returns them: id, date (naive UTC), text, sender fields, reply_to_msg_id, media and more.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed13 schema fields changedv0.4.1
    • addedInput schema / additionalProperties
      Added value: +false
    • changedInput schema / properties / chat_id / description
      Previous value: -"Chat ID to search in"New value: +"The chat's ref, as list_chats or search_all_chats returns it (an opaque string; not the numeric Telegram id)."
    • addedInput schema / properties / chat_id / minLength
      Added value: +1
    • addedInput schema / properties / limit / default
      Added value: +20
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum results to return (default 20)"New value: +"Maximum messages to return, 1 to 200 (default 20)."
    • addedInput schema / properties / limit / maximum
      Added value: +200
    • addedInput schema / properties / limit / minimum
      Added value: +1
    • changedInput schema / properties / limit / type
      Previous value: -"number"New value: +"integer"
    • changedInput schema / properties / query / description
      Previous value: -"Search query string"New value: +"Text to find in the message text (e.g. \"invoice\")."
    • addedInput schema / properties / query / maxLength
      Added value: +500
    • addedInput schema / properties / query / minLength
      Added value: +1
    • addedInput schema / properties / topic_id
      Added value: +{
      +  "description": "Forum topic id from get_topics; keeps only that topic's messages. 1 is the General topic. Omit for the whole chat.",
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "messages": {
      +      "description": "Archived messages as the viewer returns them: id, date (naive UTC), text, sender fields, reply_to_msg_id, media and more.",
      +      "items": {
      +        "type": "object"
      +      },
      +      "type": "array"
      +    }
      +  },
      +  "type": "object"
      +}
  2. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, and non-destructive, so safety is covered; the description adds genuine behavioral context beyond them — result ordering (newest first) and that returned messages mirror get_messages' fields. It stops short of mentioning pagination or result-count behavior when limit truncates, which keeps it from a 5.

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

Conciseness5/5

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

Three short sentences, each doing distinct work: what it does, which sibling to use instead, and how to follow up. The core capability is front-loaded with zero filler.

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?

With an output schema present, the description needn't enumerate return fields, and it still points at get_messages for the shape. For a read-only single-chat search with fully documented parameters, an agent has everything needed to select and invoke it correctly.

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

Parameters3/5

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

Schema coverage is 100%, so the schema already documents chat_id's opaque-ref nature, query's text matching, topic_id, and limit bounds. The description adds only the notion of a 'keyword' search, which is already implied by the schema's query description. Baseline 3 applies when the schema carries parameter semantics.

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

Purpose5/5

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

States a specific verb (search) and scoped resource (messages of one chat), plus ordering ('newest first') and the result shape ('same fields as get_messages'). This clearly distinguishes it from search_all_chats and get_messages, which are named siblings.

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

Usage Guidelines5/5

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

Explicit routing: 'Use search_all_chats when you do not know the chat' names the alternative and the condition that selects it, and 'pass its id to get_message_context' covers the follow-up workflow. Both the when-to-use and the hand-off path are spelled out.

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