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, including their IDs and related messages. Each related message contains details like a snippet of the message body, the subject, the sender, the recipients etc. Note that the full message bodies are not returned by this tool; use the 'get_thread' tool with a thread ID to fetch the full message body if needed. 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.
The following sample demonstrate how to use curl to invoke the search_threads MCP tool.
| Curl Request |
|---|
curl --location 'https://gmailmcp.googleapis.com/mcp/v1' \ --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 tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
Input Schema
Request message for SearchThreads RPC.
SearchThreadsRequest
| JSON representation |
|---|
{ "pageSize": integer "pageToken": string "query": string "includeTrash": boolean } |
| 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: from: Time & Date: after:YYYY/MM/DD / newer:YYYY/MM/DD - Received after a date. before:YYYY/MM/DD / older:YYYY/MM/DD - Received before a date. older_than: Content: subject: Labels & Categories: label: Status: is: Size: size: Logic & Grouping: AND - Match all criteria (default behavior). OR or { } - Match one or more criteria (e.g., from:amy OR from:david, {from:amy from:david}). - (minus) - Exclude criteria (e.g., -movie). ( ) - Group multiple search terms (e.g., subject:(dinner film)). Examples: "subject:OneMCP Update" "from:user@example.com" "to:user2@example.com AND newer_than:7d" "project proposal has:attachment" "is:unread -in:draft" |
Union field
|
|
includeTrash |
Optional. Include drafts from TRASH in the results. Defaults to false. |
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 page_size limit, the response will contain a |
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. |
Message
| JSON representation |
|---|
{ "id": string, "snippet": string, "subject": string, "sender": string, "toRecipients": [ string ], "ccRecipients": [ string ], "date": string, "plaintextBody": string, "attachmentIds": [ string ] } |
| 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 ISO 8601 format (YYYY-MM-DD). |
plaintextBody |
Full body content, only populated if MessageFormat was FULL_CONTENT. |
attachmentIds[] |
Output only. The attachment ids, only populated if MessageFormat was FULL_CONTENT. |
Tool Annotations
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌