Skip to main content
Glama

Search email

search_messages
Read-only

Searches email in one mailbox (accountId) or in all mailboxes at once (no accountId). Without folder, searches the whole mailbox: inbox, archive, sent and user folders (not spam, trash or drafts; on Gmail, All Mail). No age limit. Filters can be combined: full text (query), subject only (subject), sender (from), recipient (to), date range (since, before), unread only. Results are newest first, or oldest first with order=oldest. limit applies PER MAILBOX. Returns summaries (account, folder, uid, date, sender, subject; on Gmail accounts also labels (INBOX = in the inbox, ARCHIVED = archived, SENT, IMPORTANT, user labels: Gmail is searched through All Mail, so folder does not tell where the message is) and webUrl, a link that opens the message in Gmail) and, per mailbox, matches and truncated; when truncated, more messages exist and are fetched with before = nextBefore (or since = nextSince with order=oldest). Full content is read with get_message. Unreachable mailboxes are listed in failures. Does not mark anything as read.

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

Input Schema

NameRequiredDescriptionDefault
toNoRecipient address or name.
fromNoSender address or name.
limitNoMaximum number of messages PER MAILBOX (at most 50).
orderNonewest (default): most recent first. oldest: oldest first.newest
queryNoText searched everywhere (subject, body, headers).
sinceNoMessages dated on or after this day (or instant).
beforeNoMessages dated strictly before this day (or instant).
folderNoA specific folder (INBOX, Archive, "[Gmail]/Sent Mail"...). Omit to search the whole mailbox.
subjectNoText searched in the subject only.
accountIdNoA single mailbox. Omit to search all mailboxes.
unreadOnlyNoUnread messages only.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
  2. First observed

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already establish readOnlyHint, destructiveHint=false and openWorldHint, so the safety profile is covered. The description still adds genuinely non-obvious behavior: no age limit, folder search excludes spam/trash/drafts, Gmail is searched through All Mail so `folder` doesn't localize a message, `limit` is per mailbox, and unreachable mailboxes surface in `failures`. It stops short of stating rate limits or cost, but for a read-only search that is a minor omission.

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 the scope decision and dense with useful information; almost every clause carries a fact an agent needs. The one weakness is structure: a single long paragraph mixing filters, return shape, pagination and Gmail caveats, where bullets or an early return-value sentence would aid scanning of 11 parameters.

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?

No output schema exists, so the description carries the full return-shape burden — and it does: per-mailbox summaries with account, folder, uid, date, sender, subject, Gmail `labels` and webUrl, plus `matches`, `truncated` and `failures`. It also closes the state-change question ("Does not mark anything as read"), leaving nothing an agent needs in order to call it correctly.

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 100%, so baseline is 3, but the description adds meaning the schema does not: `limit` is explicitly PER MAILBOX, `order=oldest` reverses sorting, and since/before double as pagination cursors via nextSince/nextBefore. It also frames the filters as combinable and distinguishes query (full text) from subject, which the schema only implies through maxLength-free descriptions.

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 email") plus the two operating scopes — a single mailbox via accountId or all mailboxes when it is omitted. It also names the sibling that handles the follow-up need ("Full content is read with get_message"), so an agent can separate searching from reading without opening either schema.

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?

Gives explicit when-to-use conditions for the main decision points: omit `folder` for a whole-mailbox search, supply it for a specific folder, and switch to get_message for full content. It also tells the agent how to continue partial results (before=nextBefore, or since=nextSince with order=oldest), which is the alternative path an agent would otherwise have to guess.

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