Skip to main content
Glama

Search messages

tg_search_messages
Read-only

Search messages by keyword within a specific Telegram chat or across all joined chats to quickly locate relevant conversations and message context.

Instructions

Keyword search in one chat (if chat is given) or across all joined chats.

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": "tg_search_messages"
  }
}

Input Schema

NameRequiredDescriptionDefault
chatNoChat: @username, username, t.me link, t.me/c/<id> link, or numeric id such as -100123…
limitNo
queryYes
fieldsNoKeep only these fields in list items (e.g. ["message_id","name","size"])
formatNocompact = lists as {columns, rows} tables; saves a lot of context for long listingsjson
accountNoAccount id (see tg_list_accounts). Defaults to the default account.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.5/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true, openWorldHint=true and destructiveHint=false, so the safety profile is covered. The description adds the genuinely useful scoping behavior (omitting 'chat' means a cross-chat sweep), but stays silent on result ordering, matching semantics (substring vs full-text), and the cap of 100 results per call.

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?

A single sentence, front-loaded with the operation and immediately followed by the branch condition that governs scope. Nothing is padded and nothing essential is buried.

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

Completeness3/5

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

For a six-parameter search tool with no output schema, the definition covers the scoping question but leaves the return shape, pagination beyond 'limit', and result ordering unexplained. An agent can call it, but cannot predict whether results are ranked or whether truncation occurred.

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 67%; 'chat', 'fields', 'format' and 'account' are documented inline, while 'limit' and 'query' rely on type/default alone. The description contributes one real semantic point beyond the schema — that a missing 'chat' triggers search across all joined chats — which earns the baseline rather than exceeding it.

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 description pairs a specific verb (keyword search) with a specific resource (messages) and states the two scopes: one chat when 'chat' is supplied, all joined chats otherwise. It implicitly separates itself from tg_search_files and tg_search_archive by naming the message resource, but it never names those siblings explicitly to sharpen the distinction.

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

Usage Guidelines3/5

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

Usage is implied by the 'if chat is given' clause, which tells the agent how to broaden or narrow scope. However, there is no explicit guidance on when to prefer tg_search_archive, tg_search_files, or tg_get_messages, and no mention of whether search covers message text only or media captions too.

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