Skip to main content
Glama

search

Read-only

Locate Gmail threads using native query syntax by sender, subject, date, label, or read state, and return thread summaries for inspection.

Instructions

Search Gmail with native query syntax (e.g. 'in:inbox from:foo@bar.com newer_than:7d'). Returns thread summaries; read-state/category predicates are re-verified against each hit's live labels. from, subject and date are the thread's FIRST message (its origin); snippet is Gmail's and comes from the LAST. lastMessageDate and lastMessageId name that last message, so 'did anything new arrive?' is a comparison of lastMessageId against the one you saw, not of messageCount against a remembered count — and get_thread with afterMessageId: <the id you saw> then returns only what is new. lastMessageFrom names who wrote that last message and lastMessageSent is true when it was this mailbox, so 'has the other side answered?' is lastMessageSent: false. unread is true when any message of the thread is unread, read off the live labels rather than the search index. attachments lists what is attached (filename, declared mimeType, size; at most 10, attachmentCount is the total), so 'is there a PDF to keep before archiving?' needs no get_thread — the mimeType is what the sender declared, so check the filename too when it says application/octet-stream. Each summary carries signals derived from the thread's first message headers/MIME — newsletter (List-Id/List-Unsubscribe/Precedence bulk, junk or list), automated (Auto-Submitted, auto-reply/suppress headers, no-reply-style senders), calendar (text/calendar or .ics part), replyToMismatch (a Reply-To on another domain than From — a subdomain of the same domain counts as the same), displayNameSpoof (the From display name shows an address or URL on another domain than the one the mail came from), lookalikeDomain (a From domain label mixing Latin with Cyrillic, Greek or Armenian letters); empty when nothing is declared. Paginated: when more results exist, the response carries a nextPageToken — pass it back via pageToken to fetch the next page. A page can come back with FEWER threads than maxResults and still have a nextPageToken: false positives from the index consume the scan window, and on a mailbox whose read state the index has fallen behind on, most candidates for an is:unread query can be already-read mail. A short page is therefore not evidence that the result set is exhausted — only an absent nextPageToken is. SPAM AND TRASH ARE EXCLUDED unless the query names them. Gmail leaves both out of any query that does not say in:spam / in:trash, so a plain from:someone returns nothing for a mail that is sitting in spam — measured against a live mailbox, not assumed. Nothing in the result marks the omission, so treat 'no hits' as 'none outside spam and trash'. When mail the user expects is missing, retry with in:spam before reporting that it does not exist: mail is often filed as spam because of something the user just did — a signup, a password reset, an order confirmation — which is precisely what a spam filter cannot know and the caller often can. USE WHEN: locating threads by sender, subject, date, label, or read state. DO NOT USE: to fetch a thread you already have the ID of (use get_thread). SIDE EFFECTS: none.

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

Input Schema

NameRequiredDescriptionDefault
queryYes
pageTokenNo
maxResultsNo

Output Schema

NameRequiredDescriptionDefault
threadsYes
nextPageTokenNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.32.0
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • changedOutput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
  2. Changed10 schema fields changedv0.25.0
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedOutput schema / properties / threads / items / properties / attachmentCount
      Added value: +{
      +  "type": "number"
      +}
    • addedOutput schema / properties / threads / items / properties / attachments
      Added value: +{
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "filename": {
      +        "type": "string"
      +      },
      +      "mimeType": {
      +        "type": "string"
      +      },
      +      "size": {
      +        "type": "number"
      +      }
      +    },
      +    "required": [
      +      "filename",
      +      "mimeType",
      +      "size"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / threads / items / properties / lastMessageDate
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / threads / items / properties / lastMessageFrom
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / threads / items / properties / lastMessageId
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / threads / items / properties / lastMessageSent
      Added value: +{
      +  "type": "boolean"
      +}
    • changedOutput schema / properties / threads / items / properties / signals / items / enum
      Previous value: -[
      -  "newsletter",
      -  "automated",
      -  "calendar",
      -  "replyToMismatch"
      -]New value: +[
      +  "newsletter",
      +  "automated",
      +  "calendar",
      +  "replyToMismatch",
      +  "displayNameSpoof",
      +  "lookalikeDomain"
      +]
    • addedOutput schema / properties / threads / items / properties / unread
      Added value: +{
      +  "type": "boolean"
      +}
    • changedOutput schema / properties / threads / items / required
      Previous value: -[
      -  "threadId",
      -  "messageCount",
      -  "from",
      -  "subject",
      -  "date",
      -  "labelIds",
      -  "snippet",
      -  "hasAttachments",
      -  "signals"
      -]New value: +[
      +  "threadId",
      +  "messageCount",
      +  "from",
      +  "subject",
      +  "date",
      +  "lastMessageId",
      +  "lastMessageDate",
      +  "lastMessageFrom",
      +  "lastMessageSent",
      +  "unread",
      +  "labelIds",
      +  "snippet",
      +  "hasAttachments",
      +  "attachments",
      +  "attachmentCount",
      +  "signals"
      +]
  3. Changed2 schema fields changedv0.11.0
    • addedOutput schema / properties / threads / items / properties / signals
      Added value: +{
      +  "items": {
      +    "enum": [
      +      "newsletter",
      +      "automated",
      +      "calendar",
      +      "replyToMismatch"
      +    ],
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • changedOutput schema / properties / threads / items / required
      Previous value: -[
      -  "threadId",
      -  "messageCount",
      -  "from",
      -  "subject",
      -  "date",
      -  "labelIds",
      -  "snippet",
      -  "hasAttachments"
      -]New value: +[
      +  "threadId",
      +  "messageCount",
      +  "from",
      +  "subject",
      +  "date",
      +  "labelIds",
      +  "snippet",
      +  "hasAttachments",
      +  "signals"
      +]
  4. First observedv0.1.8

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 (readOnlyHint=true), and the description is consistent with that ("SIDE EFFECTS: none"). Beyond annotations it discloses non-obvious behavior: read-state and category predicates are re-verified against live labels rather than the index, spam and trash are silently excluded from any query that does not name them, and short pages can still carry a nextPageToken.

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 most important points (query syntax, get_thread exclusion, pagination caveat, spam exclusion) are front-loaded or clearly cued, but the body runs several hundred words and includes rhetorical asides ("measured against a live mailbox, not assumed") and a long signals enumeration that could be compressed. Dense and largely load-bearing, yet longer than it needs to be for a 3-parameter tool.

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?

An output schema exists, yet the description still explains the semantics of the returned fields that the schema cannot convey — first-message vs last-message attribution, lastMessageId comparison for detecting new mail, attachment mimeType caveats, and signal derivation. For a search tool with a subtle result model, nothing an agent needs to interpret results correctly is missing.

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

Parameters5/5

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

Schema coverage is 0%, so the description carries the full burden and does: `query` gets Gmail native syntax with a worked example, `pageToken` is tied to the returned `nextPageToken`, and `maxResults` is implicitly framed by the warning that a page may return fewer threads than maxResults without being exhausted. This is substantially more than the bare string/integer types in the schema.

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 and resource ("Search Gmail with native query syntax") plus a concrete example query, then explicitly separates itself from the sibling: "DO NOT USE: to fetch a thread you already have the ID of (use get_thread)." An agent can route between search and get_thread 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?

Has explicit USE WHEN criteria (sender, subject, date, label, read state) and an explicit DO NOT USE with the named alternative. It additionally gives conditional guidance the agent would otherwise get wrong: retry with `in:spam` before reporting mail as nonexistent, and only an absent nextPageToken means exhaustion.

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