MCP Tools Reference: gmailmcp.googleapis.com

Tool: search_threads

Lists email threads from the authenticated user's Gmail account.

This tool can filter threads based on a query string and supports pagination. It returns a list of threads, each with its thread id, messageCount (total messages in the thread), viewUrl, and a subset of up to 5 related messages (each with its own message id, viewUrl, sender, recipients, date, and labelIds). Use this tool to find thread ids matching a query before reading full threads or performing actions on matching emails or threads. The view parameter controls which additional fields are populated in the returned message subset. By default (or with THREAD_VIEW_MINIMAL), it includes subject and snippet. Use THREAD_VIEW_METADATA_ONLY to exclude subject and snippet, THREAD_VIEW_SUMMARY to return THREAD_VIEW_MINIMAL fields with only the most recent message per thread, or THREAD_VIEW_IDS_ONLY to return only id on each thread without fetching per-thread message metadata. Full message bodies, attachment metadata, and messages beyond the 5-message subset are not returned by this tool; use the 'get_thread' tool with a thread ID to retrieve all messages (and their message IDs) in a thread or to fetch full message bodies. Threads with excluded criteria may still appear in the results. This occurs because Gmail identifies matching messages first. For example, if you search for -is:starred, Gmail will find an entire thread if it contains at least one unstarred message, even if other emails in that same conversation are starred.

To list threads in a specific inbox category tab, use the category: operator with primary, social, promotions, updates, or forums (e.g. in:inbox category:promotions).

When filtering by date, after: and before: both evaluate against midnight (00:00:00) of the specified date (after: is inclusive, before: is exclusive). To search through a specific day D (or for a date range), set before: to the day after (e.g. after:2026/02/01 before:2026/02/02 for Feb 1, or after:2026/02/01 before:2026/02/06 for Feb 1–5).

When searching for numbers, a space or dash (-) separates numbers while a dot (.) is treated as a decimal (e.g., 01.2047-100 is parsed as two numbers: 01.2047 and 100). To search for hyphenated or dotted identifiers (such as order numbers, tracking IDs, or invoice codes like INV-12345), enclose them in double quotes (e.g. "INV-12345" or "01.2047-100") so the dash is not interpreted as a negation operator.

Note: An empty JSON object {} represents zero matching items, not an error.

The following code sample shows how to use curl to call the search_threads MCP tool.

Curl Request
curl --location 'https://gmailmcp.googleapis.com/mcp/v1' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'content-type: application/json' \
--header 'accept: application/json, text/event-stream' \
--data '{
  "method": "tools/call",
  "params": {
    "name": "search_threads",
    "arguments": {
      // Provide these details according to the MCP tool specification.
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}'

Input Schema

Request message for SearchThreads RPC.

SearchThreadsRequest

JSON representation
{
  "pageSize": integer,
  "pageToken": string,
  "query": string,
  "includeTrash": boolean,
  "view": enum (ThreadView)
}
Fields

Union field _page_size.

_page_size can be only one of the following:

pageSize

integer

Optional. The maximum number of threads to return. If unspecified, defaults to 20. The maximum allowed value is 50.

Union field _page_token.

_page_token can be only one of the following:

pageToken

string

Optional. Page token to retrieve a specific page of results in the list. Leave empty to fetch the first page. This is primarily used for pagination to continue fetching results from where the previous search_threads call left off, especially when the number of threads matching the query exceeds the pageSize limit.

Union field _query.

_query can be only one of the following:

query

string

Optional. A query string to filter the threads. Natural language queries must be pre-converted into Gmail syntax queries to use this tool. If omitted, all threads (excluding spam and trash by default) are listed.

Supported Operators by Category:

Sender & Recipient:

  • from:EMAIL - Sent from a specific person.
  • to:EMAIL - Sent to a specific person.
  • cc:EMAIL - Specific people in Cc.
  • bcc:EMAIL - Specific people in Bcc.
  • deliveredto:EMAIL - Delivered to a specific address.
  • list:EMAIL - From a specific mailing list.

Time & Date:

  • after:YYYY/MM/DD / newer:YYYY/MM/DD - Received after a date (evaluates against midnight 00:00:00 of that day, inclusive).
  • before:YYYY/MM/DD / older:YYYY/MM/DD - Received before a date (evaluates against midnight 00:00:00 of that day, exclusive; excludes that day). To search through a specific day D (or for a single day D), set before: to the day after (for example, after:2026/02/01 before:2026/02/02 for Feb 1, or after:2026/02/01 before:2026/02/06 for Feb 1-5).
  • older_than:DURATION - Older than a duration (for example, 1y, 2d).
  • newer_than:DURATION - Newer than a duration.

Content:

  • subject:WORDS - Words in the subject line.
  • has:TYPE - Has specific content types (attachment, drive, youtube, document).
  • filename:NAME - Attachment with a specific name or type.
  • "PHRASE" - Search for an exact word or phrase. (for example, "holiday", "holiday vacation"). Note: Double quotes enforce strict contiguous phrase matching. For topic, discussion, or keyword queries, prefer unquoted keywords (e.g. partner advertising instead of "partner advertising").
  • +WORD - Match a word exactly. (for example, +holiday, +unicorn)
  • rfc822msgid:ID - Specific message ID header.
  • AROUND N - Find words near each other (for example, holiday AROUND 10 vacation).

Labels & Categories:

  • label:NAME - Under a specific label, matched by its display name (the name from list_labels), for example label:wins. Label IDs such as Label_123 match nothing. Quote a name that contains spaces (label:"Board Prep") or replace its spaces and / with - (label:board-prep).
  • category:NAME - In a category (primary, social, promotions, updates, forums, reservations, purchases).
  • in:LABEL - Search in specific labels (archive, snoozed, trash, sent, inbox). For example, in:trash, in:inbox. Note: Archived and sent messages are included by default; use -in:archive and -in:sent to exclude them. Drafts are always excluded. Use in:inbox to restrict search to the inbox only.
  • has:userlabels - Has any user labels.
  • has:nouserlabels - Does not have any user labels.
  • has:*-star - Specific star colors (if enabled, for example, has:yellow-star).
  • in:sent - Search in sent messages.
  • in:anywhere - Search across all folders, including Trash. Emails that are spam, confidential, encrypted, or suspicious are still filtered out for security. They are usually removed before the search runs and are then not counted in omittedContent, so a missing omittedContent does not mean that nothing was filtered.

Status:

  • is:STATUS - Search by status (important, starred, unread, read, muted).

Size:

  • size:BYTES - Specific size in bytes.
  • larger:SIZE / smaller:SIZE - Larger or smaller than a size (for example, 10M for 10 MB).

Logic & Grouping:

  • AND - Match all criteria (default behavior).
  • OR or { } - Match one or more criteria (for example, from:amy OR from:david, {from:amy from:david}).
  • - (minus) - Exclude criteria (for example, -movie).
  • ( ) - Group multiple search terms (for example, subject:(dinner film)).

Examples:

  • subject:Project Update
  • from:user@example.com
  • to:user2@example.com AND newer_than:7d
  • project proposal has:attachment
  • is:unread -in:sent

A space or a dash (-) separates numbers, while a dot (.) is treated as a decimal. For example, 01.2047-100 is considered two numbers: 01.2047 and 100. To search for hyphenated or dotted identifiers (such as order numbers, tracking IDs, or invoice codes like INV-12345), enclose them in double quotes (e.g., "INV-12345" or "01.2047-100") so the dash is not interpreted as a negation operator and exact phrase matching is preserved.

To prevent overly strict queries, favor concise, keyword-based queries over long subject strings or full sentences. Avoid copying overly detailed subjects from the user prompt verbatim, as this often leads to search misses. Instead, extract the most unique keywords (e.g., subject:amazon "delivery" OR "order" instead of "amazon order"). Use boolean operators to broaden your search coverage. Use OR to search for synonyms or multiple potential senders, and use ( ) for grouping criteria. Note that whitespace between terms acts as an implicit AND.

Union field _include_trash.

_include_trash can be only one of the following:

includeTrash

boolean

Optional. Include threads from TRASH in the results. Defaults to false.

Union field _view.

_view can be only one of the following:

view

enum (ThreadView)

Optional. Controls the fields populated for threads in the thread list. Defaults to THREAD_VIEW_MINIMAL. THREAD_VIEW_MINIMAL returns id, snippet, subject, sender, toRecipients, ccRecipients, bccRecipients, addressDisplayNames, date, labelIds, viewUrl (if applicable). THREAD_VIEW_METADATA_ONLY returns id, sender, toRecipients, ccRecipients, bccRecipients, addressDisplayNames, date, labelIds, viewUrl (if applicable). THREAD_VIEW_IDS_ONLY returns only id on each Thread without fetching per-thread message metadata. THREAD_VIEW_SUMMARY returns THREAD_VIEW_MINIMAL fields with only the most recent message per thread (messages has at most 1 entry), plus messageCount and viewUrl on the thread.

ThreadView

Enum to control the fields populated for threads in the response.

Enums
THREAD_VIEW_UNSPECIFIED Maps to THREAD_VIEW_MINIMAL for backward compatibility.
THREAD_VIEW_METADATA_ONLY Returns id, sender, toRecipients, ccRecipients, bccRecipients, addressDisplayNames, date, labelIds, viewUrl (if applicable).
THREAD_VIEW_MINIMAL Returns id, snippet, subject, sender, toRecipients, ccRecipients, bccRecipients, addressDisplayNames, date, labelIds, viewUrl (if applicable).
THREAD_VIEW_IDS_ONLY Returns only id on each Thread without fetching per-thread message metadata. Useful when collecting thread IDs for batch operations or counting matching threads across pages; counts can include threads that other views omit.
THREAD_VIEW_SUMMARY Returns THREAD_VIEW_MINIMAL fields with only the most recent message per thread (messages has at most 1 entry), plus messageCount and viewUrl (if applicable) on the thread.

Output Schema

Response message for SearchThreads RPC.

SearchThreadsResponse

JSON representation
{
  "threads": [
    {
      object (Thread)
    }
  ],
  "nextPageToken": string,
  "resultCountEstimate": string,
  "omittedContent": {
    object (OmittedContentSummary)
  }
}
Fields
threads[]

object (Thread)

List of thread summaries.

nextPageToken

string

A token that can be used in a subsequent call to retrieve the next page of threads. Present only if there are more results. If the number of threads matching the query exceeds the pageSize limit, the response will contain a nextPageToken. To retrieve the next page of results, pass this token in the pageToken field of the next SearchThreadsRequest.

resultCountEstimate

string (int64 format)

The estimated result count for this query. It should be treated as a lower bound, so for example if it is 500, then the count can be reported to the user as "500+".

omittedContent

object (OmittedContentSummary)

Summary of threads matching the query that were omitted from this page due to security or DLP policy filters. Present only when at least one thread was omitted; omittedReasonCounts gives the number of omitted threads per reason. The counts are a lower bound: emails that are spam, confidential, encrypted, or suspicious are usually removed before the search runs and are then not counted, so a missing omittedContent does not mean that nothing was filtered. Omitted threads cannot be retrieved by retrying, by broadening the query (for example with in:anywhere), or by fetching individual threads or messages. A page may contain fewer threads than pageSize, or no threads at all, while nextPageToken is still set: if threads is empty and nextPageToken is present, continue paginating to find more results. If nextPageToken is absent, there are no more results; tell the user how many threads were omitted and why.

Thread

JSON representation
{
  "id": string,
  "messages": [
    {
      object (Message)
    }
  ],
  "viewUrl": string,
  "messageCount": integer
}
Fields
id

string

The unique identifier of the thread.

messages[]

object (Message)

A list of messages in the thread, ordered chronologically.

viewUrl

string

Output only. Web URL to view the thread in the Gmail Web UI.

Union field _message_count.

_message_count can be only one of the following:

messageCount

integer

Output only. Total number of messages in this thread in Gmail.

Message

JSON representation
{
  "id": string,
  "snippet": string,
  "subject": string,
  "sender": string,
  "toRecipients": [
    string
  ],
  "ccRecipients": [
    string
  ],
  "date": string,
  "plaintextBody": string,
  "attachmentIds": [
    string
  ],
  "htmlBody": string,
  "bccRecipients": [
    string
  ],
  "attachments": [
    {
      object (AttachmentMetadata)
    }
  ],
  "labelIds": [
    string
  ],
  "raw": string,
  "threadId": string,
  "historyId": string,
  "internalDate": string,
  "sizeEstimate": integer,
  "viewUrl": string,
  "addressDisplayNames": [
    {
      object (AddressDisplayName)
    }
  ],
  "originalMessageId": string
}
Fields
id

string

The unique identifier of the message.

snippet

string

Snippet of the message body.

subject

string

The message subject extracted from headers.

sender

string

Sender email address.

toRecipients[]

string

To recipient email addresses.

ccRecipients[]

string

CC recipient email addresses.

date

string

Date of the message in RFC 3339 UTC timestamp format (YYYY-MM-DDTHH:MM:SSZ).

plaintextBody

string

Full body content, only populated if MessageFormat was FULL_CONTENT or PLAIN_TEXT.

attachmentIds[]

string

Output only. The attachment ids, only populated if MessageFormat was FULL_CONTENT or PLAIN_TEXT.

htmlBody

string

The HTML content of the email, only populated if MessageFormat was FULL_CONTENT.

bccRecipients[]

string

BCC recipient email addresses.

attachments[]

object (AttachmentMetadata)

Output only. The attachments, only populated if MessageFormat was FULL_CONTENT or PLAIN_TEXT.

labelIds[]

string

The ids of the labels attached to the message. Includes ids of user labels and standard system labels limited to INBOX, TRASH, UNREAD, STARRED, IMPORTANT, SENT, DRAFT, CHAT, and the inbox category labels CATEGORY_PERSONAL (Primary tab), CATEGORY_SOCIAL, CATEGORY_PROMOTIONS, CATEGORY_UPDATES, CATEGORY_FORUMS.

raw

string

The raw MIME message content, only populated if MessageFormat was RAW.

threadId

string

Output only. The ID of the thread this message belongs to.

historyId

string

Output only. The ID of the last history record that modified this message.

internalDate

string

Output only. The internal message creation timestamp (epoch ms).

sizeEstimate

integer

Output only. Estimated size in bytes of the message.

viewUrl

string

Output only. Web URL to view the message in the Gmail Web UI.

addressDisplayNames[]

object (AddressDisplayName)

Output only. Contains display names from the From, To, Cc, and Bcc headers, with one entry for each address in sender, toRecipients, ccRecipients, or bccRecipients whose header includes a display name. Addresses whose header has no display name are omitted. Use these names verbatim when referring to people instead of inferring a name from an email address.

Union field _original_message_id.

_original_message_id can be only one of the following:

originalMessageId

string

Optional. Output only. The unique identifier of the original message that was forwarded. Only populated for forwarded messages.

AttachmentMetadata

JSON representation
{
  "id": string,
  "mimeType": string,
  "filename": string,
  "partId": string
}
Fields
id

string

Output only. The ID of the attachment.

mimeType

string

The MIME type of the attachment.

filename

string

The filename of the attachment.

partId

string

Output only. The MIME part ID of the attachment (e.g., "1", "0.1").

This represents the 0-indexed hierarchical position of the part within the email MIME tree. The root message container is omitted, so direct top-level parts are indexed as "0", "1", etc. (they do not start with a "0." prefix). Nested multipart children append their sub-index (e.g., "0.1", "0.2").

AddressDisplayName

JSON representation
{
  "emailAddress": string,
  "displayName": string
}
Fields
emailAddress

string

Output only. Specifies the email address, matching a value in sender, toRecipients, ccRecipients, or bccRecipients.

displayName

string

Output only. Specifies the display name exactly as it appears in the header, for example Alice Smith.

OmittedContentSummary

JSON representation
{
  "omittedReasonCounts": [
    {
      object (OmittedReasonCount)
    }
  ]
}
Fields
omittedReasonCounts[]

object (OmittedReasonCount)

Breakdown of the items omitted from this response due to security or policy filters, with one entry per reason. The total number of omitted items is the sum of omittedCount across all entries.

OmittedReasonCount

JSON representation
{
  "reason": enum (OmissionReason),
  "omittedCount": integer
}
Fields
reason

enum (OmissionReason)

The reason the items were omitted.

omittedCount

integer

Number of items omitted for this reason.

OmissionReason

Reason why content was omitted from a response.

Enums
OMISSION_REASON_UNSPECIFIED Unspecified omission reason.
SPAM Filtered because the thread or message is classified as spam.
CONFIDENTIAL Filtered because the thread or message is in Confidential Mode / IRM.
ENCRYPTED Filtered because the thread or message is client-side encrypted.
SUSPICIOUS_SENDER Filtered because the sender is flagged as suspicious or spoofed.
SUSPICIOUS_CONTENT Filtered because the message content is flagged as phishing or suspicious.
PROMPT_INJECTION_SUSPECTED Filtered because live prompt-injection detection flagged content in the item.
DATA_PROTECTION_POLICY Filtered by an enterprise Data Loss Prevention (DLP) or admin data-access policy.

Tool Annotations

Tool annotations are sent to MCP clients to describe the basic risk of a given tool. Most clients treat these hints as untrusted, but they can be used to decide when a confirmation prompt might be sent to a user.

Along with the title string, the following boolean hints are defined as follows:

  • readOnlyHint: If true, the tool doesn't modify its environment. Default: false.
  • destructiveHint: If true, then the tool can perform destructive actions. If false, then the tool can only perform additive actions. Default: true.
  • idempotentHint: If true, then calling the tool repeatedly with the same arguments will have no additional effect on its environment. Default: false.
  • openWorldHint: If true, then the tool can interact with an 'open world' of external entities. If false, then the tool can only interact with internal entities. For example, a web search tool would be open world, while a memory tool would not be open world.

Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://mail.google.com/
  • https://www.googleapis.com/auth/gmail.messages
  • https://www.googleapis.com/auth/gmail.messages.readonly
  • https://www.googleapis.com/auth/gmail.modify
  • https://www.googleapis.com/auth/gmail.readonly