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 ( |
| Fields | |
|---|---|
Union field
|
|
pageSize |
Optional. The maximum number of threads to return. If unspecified, defaults to 20. The maximum allowed value is 50. |
Union field
|
|
pageToken |
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 |
Union field
|
|
query |
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:
Time & Date:
Content:
Labels & Categories:
Status:
Size:
Logic & Grouping:
Examples:
A space or a dash ( 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., |
Union field
|
|
includeTrash |
Optional. Include threads from TRASH in the results. Defaults to false. |
Union field
|
|
view |
Optional. Controls the fields populated for threads in the thread list. Defaults to |
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 ( |
| Fields | |
|---|---|
threads[] |
List of thread summaries. |
nextPageToken |
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 |
resultCountEstimate |
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 |
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; |
Thread
| JSON representation |
|---|
{
"id": string,
"messages": [
{
object ( |
| Fields | |
|---|---|
id |
The unique identifier of the thread. |
messages[] |
A list of messages in the thread, ordered chronologically. |
viewUrl |
Output only. Web URL to view the thread in the Gmail Web UI. |
Union field
|
|
messageCount |
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 ( |
| Fields | |
|---|---|
id |
The unique identifier of the message. |
snippet |
Snippet of the message body. |
subject |
The message subject extracted from headers. |
sender |
Sender email address. |
toRecipients[] |
To recipient email addresses. |
ccRecipients[] |
CC recipient email addresses. |
date |
Date of the message in RFC 3339 UTC timestamp format (YYYY-MM-DDTHH:MM:SSZ). |
plaintextBody |
Full body content, only populated if MessageFormat was FULL_CONTENT or PLAIN_TEXT. |
attachmentIds[] |
Output only. The attachment ids, only populated if MessageFormat was FULL_CONTENT or PLAIN_TEXT. |
htmlBody |
The HTML content of the email, only populated if MessageFormat was FULL_CONTENT. |
bccRecipients[] |
BCC recipient email addresses. |
attachments[] |
Output only. The attachments, only populated if MessageFormat was FULL_CONTENT or PLAIN_TEXT. |
labelIds[] |
The ids of the labels attached to the message. Includes ids of user labels and standard system labels limited to |
raw |
The raw MIME message content, only populated if MessageFormat was RAW. |
threadId |
Output only. The ID of the thread this message belongs to. |
historyId |
Output only. The ID of the last history record that modified this message. |
internalDate |
Output only. The internal message creation timestamp (epoch ms). |
sizeEstimate |
Output only. Estimated size in bytes of the message. |
viewUrl |
Output only. Web URL to view the message in the Gmail Web UI. |
addressDisplayNames[] |
Output only. Contains display names from the |
Union field
|
|
originalMessageId |
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 |
Output only. The ID of the attachment. |
mimeType |
The MIME type of the attachment. |
filename |
The filename of the attachment. |
partId |
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 |
Output only. Specifies the email address, matching a value in |
displayName |
Output only. Specifies the display name exactly as it appears in the header, for example |
OmittedContentSummary
| JSON representation |
|---|
{
"omittedReasonCounts": [
{
object ( |
| Fields | |
|---|---|
omittedReasonCounts[] |
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 |
OmittedReasonCount
| JSON representation |
|---|
{
"reason": enum ( |
| Fields | |
|---|---|
reason |
The reason the items were omitted. |
omittedCount |
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.messageshttps://www.googleapis.com/auth/gmail.messages.readonlyhttps://www.googleapis.com/auth/gmail.modifyhttps://www.googleapis.com/auth/gmail.readonly