Skip to main content
Glama
flt-sudo

gmail-mcp-server

by flt-sudo

Search Gmail threads

gmail_search_threads
Read-onlyIdempotent

Search Gmail threads using full search syntax, across a single account or all accounts at once, returning thread summaries with pagination and per-account error handling.

Instructions

Search threads with full Gmail search syntax, in one account or across all stored accounts.

Args:

  • query (string, required): Gmail search syntax. Examples: 'from:alice@example.com is:unread', 'newer_than:7d', 'has:attachment subject:"invoice"', 'to:me label:starred'.

  • account (string, optional): email or alias to search; the literal 'all' fans out to every stored account concurrently, merges results by date (newest first), and tags each thread with its account. Omit for the default account.

  • max_results (1–50, default 10): per-account cap.

  • page_token (optional): continue a previous single-account search. NOT supported with account:'all' — in that mode each account instead reports has_more; narrow the query or search one account to paginate.

  • response_format: 'markdown' (default) or 'json'.

Returns: thread-level summaries only (thread_id, account, participants, date, subject, snippet, message_count) — never full bodies. Use gmail_get_thread with the thread_id AND the same account to read a thread.

Examples:

  • {"query": "is:unread newer_than:2d"}

  • {"query": "subject:"invoice" has:attachment", "account": "all", "max_results": 20}

Error Handling: in 'all' mode, per-account failures are reported inline without failing the whole call. Expired credentials return a re-auth instruction naming the affected account.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesGmail search query (full Gmail search syntax). Examples: 'from:alice@example.com is:unread', 'newer_than:7d', 'has:attachment subject:"invoice"', 'label:important older_than:1m'.
accountNoEmail or alias to search, or the literal string 'all' to fan out across every stored account (results are merged by date and tagged with their account). Omit to use the default account.
page_tokenNoPagination token from a previous single-account search. Not supported with account: 'all'.
max_resultsNoMaximum threads to return (per account in 'all' mode). 1–50, default 10.
response_formatNoOutput format: 'markdown' for compact human-readable rendering (default), 'json' for the full normalized structure.markdown

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, so the description's confirmation of read-only behavior is redundant. However, it adds valuable behavioral details beyond annotations: the merge-by-date behavior across accounts, per-account caps, per-account failure handling, and the re-auth instruction behavior. It also clearly states what is NOT returned (full bodies), which is a behavioral boundary not covered by annotations. Minor deduction for not mentioning rate limits explicitly, but the added context justifies a strong score.

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?

The description is well-structured with an 'Args' section, examples, and error handling. It front-loads the primary purpose and then details parameters. It is somewhat long, but every section adds useful information. The explicit 'Returns' and 'Error Handling' sections are helpful. A 4 because it could be slightly more succinct without losing critical details.

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?

Given the tool's complexity (multi-account fan-out, pagination limitations, partial failures), the description is remarkably complete. It covers input syntax, output shape, edge cases (page_token limitation), and error handling, so an agent has everything needed to invoke correctly. There is no output schema, so the description's 'Returns' section is essential and provided. Nothing critical is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema fully documents each parameter with descriptions and examples. The description adds a few extra example queries and clarifies the behavior of page_token with account:'all', but these are marginal over the schema. A 3 is appropriate because the schema does the heavy lifting.

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?

The description states a specific verb ('Search') and resource ('threads'), and immediately clarifies the scope (full Gmail syntax, across accounts). It distinguishes itself from gmail_get_thread by noting it returns thread-level summaries only, directing the agent to the sibling for full content.

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?

It gives explicit examples of when to use the tool and nuances like 'account: all' fan-out and pagination limitation, which are crucial for correct invocation. It also explains error handling in 'all' mode, so the agent knows failures are per-account and not fatal.

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