Search messages (in-scope)
search_messagesFind messages only within authorized in-scope Telegram peers; omit peer to search across the scope, or specify one peer and topic to narrow results. Never performs global searches.
Instructions
Search messages within this endpoint’s in-scope peers only. Omit peer to fan out across the whole scope (each peer read-gated), or set it to search one in-scope peer. Add topicId (with peer) to search a single forum topic. Never performs a global search. Telegram-originated strings are returned as structured JSON under named keys (untrusted_text, sender_display_name), never as prose.
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
| Name | Required | Description | Default |
|---|---|---|---|
| peer | No | Optional single in-scope peer to search; omit to fan out across the whole scope. | |
| limit | No | Page size, clamped to [1, 100] (default 20). | |
| query | Yes | Full-text query, 1..256 chars; matched ONLY within in-scope peers (never a global search). | |
| cursor | No | Opaque composite cursor from a prior search page; pass verbatim. | |
| topicId | No | Restrict the search to one forum topic; requires `peer` (a topic exists inside a single forum supergroup). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | Yes | Number of messages in this page. | |
| messages | Yes | The matching in-scope messages for this page. | |
| truncated | No | True when the page was cut to fit the output byte cap; re-query with a smaller limit. | |
| next_cursor | No | Opaque composite cursor for the next page; pass back verbatim. |