Skip to main content
Glama

search_emails

Read-only

Find Gmail messages across one or all enabled accounts using Gmail query syntax for sender, date, attachments, labels, and read status. Returns matches with paging and thread IDs.

Instructions

Search Gmail using standard Gmail query syntax. Omitting account searches all enabled inboxes and merges results; pass account ("personal", "tamu") to scope to one. Returns individual messages, not threads — use get_email_thread with the returned Thread ID to see replies and full message bodies. Supported: from: to: cc: subject: after:/before:YYYY/MM/DD newer_than:/older_than: (e.g. 7d, 1y) has:attachment filename: is:unread/starred/important in:inbox/sent/trash/anywhere category: larger:/smaller:, "exact phrase", - to negate, OR or {a b} to match either, ( ) to group. label: takes the label's DISPLAY NAME, not its id — quote names with spaces: label:"BROH Internship". (A Label_... id would match nothing in Gmail, so this server rewrites recognized ids to the matching display name for you; prefer the name anyway.) Archived and sent mail are included by default; use in:inbox to restrict. Each result lists its label ids and names (UNREAD, STARRED, IMPORTANT, SENT, user labels). Bodies are not included — use read_emails(include_body=true) or get_email_thread. "Estimated Total Matches" is Gmail's own resultSizeEstimate for the whole query and is approximate; use page_token to page through everything.

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

Input Schema

NameRequiredDescriptionDefault
queryYesGmail search query, e.g. `from:alice@example.com newer_than:30d has:attachment`.
accountNoOptional account id ("personal", "tamu"). Omit to aggregate across all enabled accounts.
page_tokenNoToken from a previous call's "Next Page Token" to fetch the next page. Reuse the SAME query, max_results and `account` scope — the token records every queried account's position, including matches already fetched but not shown, and is rejected with an explanation if the scope changed.
max_resultsNoMaximum emails to return per account (1-500).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.6.2

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, non-destructive), and the description goes well beyond them: cross-account result merging, the silent label-id-to-display-name rewrite ("A `Label_...` id would match nothing in Gmail, so this server rewrites recognized ids"), the approximate nature of "Estimated Total Matches" as Gmail's resultSizeEstimate, and bodies being excluded. These are non-obvious behaviors an agent could not infer from the schema.

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 two most decision-relevant facts (messages not threads; account aggregation), and nearly every clause carries information. It is dense and long — the long inline operator enumeration is a wall of backticked tokens that an agent must parse in one pass — but almost nothing is wasted or restated.

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 steps in to describe return shape: per-result label ids and names, the absence of bodies, the "Estimated Total Matches" field and its caveat, and "Next Page Token" for paging. Combined with pagination guidance ("use page_token to page through everything"), an agent has enough to call and consume results 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 the schema already documents all four parameters and the baseline would be 3. The description earns above baseline by giving the query parameter real semantic depth (supported operators, date formats, quoting for display names, negation/OR/grouping) and by explaining what `account` does to result aggregation — none of which the schema's one-line example conveys. It repeats rather than extends the page_token scope-stability rule already in the schema, which keeps it off a 5.

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?

Opens with a specific verb+resource ("Search Gmail using standard Gmail query syntax") and immediately distinguishes its output unit: "Returns individual messages, not threads — use get_email_thread ... to see replies and full message bodies." An agent can tell this apart from read_emails and get_email_thread without opening any 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?

Explicit routing rules in both directions: threads go to get_email_thread, bodies go to read_emails(include_body=true) or get_email_thread, and `in:inbox` is named as the way to restrict to inbox. It also states the default scope behavior ("Omitting `account` searches all enabled inboxes and merges results; pass `account` to scope to one") and that archived/sent mail is included by default — the non-obvious case where an agent would otherwise get wrong results.

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