Skip to main content
Glama

search_emails

Read-onlyIdempotent

Search connected mailboxes. Results are compact summaries; use get_email to read a message. Without folderId, search uses Inbox in the selected connected mailbox(es); when accountId is omitted, it searches the connected mailboxes available to your account. To search Sent, Drafts, or another folder, first call list_mail_folders, then pass that folder's folderId together with the same accountId. This tool has no all-folders selector. Results may combine indexed matches with provider search. A nextCursor continues this same search and may advance provider traversal even when messages is empty; resume with that exact cursor and unchanged account, query, filters, and limit. Prefer that continuation over starting a new search. pendingAccountIds identifies mailboxes still searching. semanticPending:true means semantic results are not ready yet, even when messages is empty and nextCursor is absent. This is independent of provider freshness and pendingAccountIds. freshness.checkedAt is the last confirmed check for this result scope: treat recent results as usable within the ten-minute freshness window and do not raise a freshness warning within the thirty-minute tolerance window. A recent checkedAt stays usable when freshness.stale is true or freshness.refreshing is true; those flags can reflect cache maintenance or an incomplete snapshot, not a provider failure. Missing checkedAt means the age is unknown and is not itself evidence that messages are stale. coverage.complete and cachedSubset describe search coverage independently from the age of returned messages. Only when there is no nextCursor and semanticPending is true, retry the identical query and filters once after about five seconds, omitting cursor, and setting waitForFresh:false. Check semanticPending on the follow-up; if it remains true, treat results as incomplete rather than as no matches. failures identifies settled errors. Without nextCursor, a pending provider search can be checked later by repeating the identical query and filters without a cursor and with waitForFresh:false. A pending cursor or incomplete coverage is not proof that a mailbox is empty; continue that exact search when a complete answer is required. Set waitForFresh only when the user explicitly asks for a live refresh. If that bounded wait expires, return the cached matches and last confirmed check time without describing the timeout itself as a mail failure.

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_emails"
  }
}

Input Schema

NameRequiredDescriptionDefault
toNo
fromNo
sortNoText searches default to relevance. Inbox and folder lists default to newest first. Choose relevance, newest first, or oldest first explicitly.
afterNo
limitNo
queryNo
beforeNo
cursorNo
isReadNo
subjectNo
folderIdNoOpaque folder ID from list_mail_folders. Requires the same accountId because folders belong to one mailbox.
accountIdNo
isStarredNo
maxWaitMsNoMaximum refresh wait in milliseconds (up to 15000). At the deadline, a cached copy may be returned with freshness metadata; this is not a guarantee of a fresh response.
waitForFreshNoWait briefly for a provider refresh instead of immediately returning a cached copy. Check the returned freshness timestamps and stale/refreshing flags.
hasAttachmentsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added
  2. Removed
  3. First observed

TDQS

A4.3/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive, openWorld), and the description adds substantial non-obvious behavior: continuation semantics for nextCursor (resume with identical account/query/filters/limit, may advance even when messages is empty), pendingAccountIds and semanticPending signaling, freshness/checkedAt tolerances (ten-minute window, thirty-minute tolerance, stale/refreshing not implying provider failure), coverage.complete vs cachedSubset, and the single bounded retry with waitForFresh:false. It even instructs how to report a timeout without framing it as a mail failure.

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

Conciseness3/5

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

The purpose and folder-scope rules are front-loaded, which is good, but the remainder is a single dense paragraph of chained freshness clauses with no visual structure, and it repeats itself ('A pending cursor or incomplete coverage is not proof that a mailbox is empty' restates the earlier empty-results point). Given the genuine complexity some length is justified, but the freshness/pending material could be tightened considerably.

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

Completeness4/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 usefully documents the response envelope (messages, nextCursor, pendingAccountIds, semanticPending, freshness.checkedAt/stale/refreshing, coverage, failures) and the retry protocol, which is exactly what an agent needs to interpret results. The gap is on the input side: half the filter parameters are never given meaning beyond their names, so completeness for a 16-parameter tool is strong but not full.

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 description coverage is only 25% across 16 params, so the description must carry weight, and it does for the highest-risk ones: folderId defaults and pairing with accountId, accountId defaulting to all available mailboxes, cursor as an exact-resume token with unchanged companion inputs, and waitForFresh/maxWaitMs semantics. It says nothing about to, from, subject, after, before, isRead, isStarred, hasAttachments, or limit, which are largely self-describing but leave the filter surface undocumented.

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?

Opens with a specific verb+resource ('Search connected mailboxes') and immediately clarifies the output form ('compact summaries') plus the hand-off to get_email for full bodies. It does not, however, distinguish itself from the several other search-shaped siblings (search_threads_by_recipient, search_cached_threads_by_recipient, search_threads_by_recipient), so an agent must infer which search to pick.

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 about the default scope (Inbox when folderId is omitted), the accountId fallback, and the exact procedure to search other folders ('first call list_mail_folders, then pass that folder's folderId together with the same accountId'), including the negative case 'no all-folders selector'. It also states when to set waitForFresh ('only when the user explicitly asks for a live refresh') and when to prefer cursor continuation over a new query.

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