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.
The following sample demonstrate how to use curl to invoke the search_threads MCP tool.
| Curl Request |
|---|
curl --location 'https://gmailmcp.googleapis.com/mcp' \ --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 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. |
Union field
|
|
query |
Optional. A query string to filter the threads, using the same format as the Gmail search bar. If omitted, all threads (excluding spam and trash by default) are listed. Key Operators: from: |
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. |
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 } |
| 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. |
Tool Annotations
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌