Skip to main content
Glama

search_messages

Read-only

Searches the text and captions of messages from the last 90 days, across all chats or within one chat, using full-text search. Returns { chats, senders?, messages }, newest first: each message has its id, timestamp, chat_jid, sender and text; chats maps each chat_jid to its chat and, for group messages, senders maps each sender_jid to that sender, both with the contact fields (name; name_source: address_book, push_name, group_subject, business, phone or unresolved; canonical_jid: the JID to pass to send_message and read_chat_history; phone_jid and lid_jid: the chat's phone-number and LID forms, null when unknown or for groups; phone_display: the number as +). Media shows up as e.g. "[voice note, 0:42]" or "[image] caption"; captions and the text of transcribed voice notes are searchable (those hits have voice_note: true). A voice note that was transcribed shows its text ("[voice note, 0:42, transcribed] "…""); to read one that wasn't, call transcribe_voice_note with its id (paid plan). An edited message is found and shown by its latest text, with edited: true. Texts longer than about 300 characters are shortened around the match (text_truncated: true); read the chat with read_chat_history for the whole message. A page holds up to limit matches but stops early when they are long; when more may exist, the headline gives the before to pass for the next, older page. For messages older than 90 days or to browse a chat, use read_chat_history.

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

NameRequiredDescriptionDefault
limitNoOptional. Maximum number of results to return (default 20, max 100).
queryYesThe text to search for.
beforeNoOptional. For the next page: the `id` of the last (oldest) message of the previous results, as the headline gives it. Keep the same query and filters.
chat_jidNoOptional. Filter by a specific chat: a JID, a phone number with country code, or a contact name.
sender_jidNoOptional. Filter by who sent the message: a JID (…@s.whatsapp.net or …@lid), a phone number with country code, or a contact name. Every form of the person's number matches. A name that matches several people returns an error listing them.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Far beyond the readOnly/openWorld annotations, it discloses the full result shape ({chats, senders?, messages}, newest first), pagination behavior including early page stops for long matches, truncation around the match with the text_truncated flag, edited-message resolution, and how media and voice notes appear in text. These are the operational traits that determine correct downstream handling.

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 and return shape, and nearly every clause carries information an agent needs given there is no output schema. The long parenthetical enumerating contact fields (name_source values, phone_jid, lid_jid, phone_display) is dense and could be tightened, and the whole thing is one undivided paragraph, but it is not padded.

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 no output schema, the description step-by-step documents the return envelope, per-message fields, and the chat/sender contact maps, plus pagination and truncation escape hatches. For a five-parameter read-only search tool, an agent has everything needed to call it and to interpret or continue from the results.

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 already 100% for all five parameters, so the baseline is 3, but the description adds real meaning: `before` is defined as the id the headline hands back for the next older page, `limit` bounds the matches per page subject to early stopping, and the filter semantics for search hits (media captions, transcriptions) are clarified. It does not restate `query`/`chat_jid`/`sender_jid` details the schema already covers.

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 and resource ("Searches the text and captions of messages"), bounds it in time (last 90 days) and scope (all chats or one chat), and names the mechanism (full-text search). It is clearly distinguishable from read_chat_history and transcribe_voice_note, which are called out by name.

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?

Explicitly routes away from itself: older than 90 days or browsing a chat goes to read_chat_history, and an untranscribed voice note hit requires transcribe_voice_note (with the paid-plan caveat). It even specifies the follow-up call for truncated text, so the agent knows both what this tool is for and what it is not.

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.