工具:get_thread
从经过身份验证的用户的 Gmail 账号中检索特定邮件会话串,包括其邮件列表。
可选的 messageFormat 参数用于控制返回的消息的格式。默认情况下(或使用 FULL_CONTENT 时),它会返回消息的完整内容。使用 MINIMAL 仅包含主题和摘要(不包含正文)。使用 METADATA_ONLY 可以仅包含基本元数据(消息 ID、线程 ID、标签、时间戳和大小估计值)。
以下示例演示了如何使用 curl 调用 get_thread MCP 工具。
| Curl 请求 |
|---|
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": "get_thread", "arguments": { // provide these details according to the tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
输入架构
针对 GetThread RPC 的请求消息。
GetThreadRequest
| JSON 表示法 |
|---|
{
"threadId": string,
"messageFormat": enum ( |
| 字段 | |
|---|---|
threadId |
必需。要提取的线程的唯一标识符。 |
messageFormat |
可选。指定线程中返回的消息的格式。默认值为 FULL_CONTENT。注意:MINIMAL 格式会返回 id、snippet、subject、from、to、cc、date、labelIds。METADATA_ONLY 格式会返回 id、from、to、cc、date、labelIds。FULL_CONTENT 会返回 id、snippet、subject、from、to、cc、date、labelIds、attachmentIds、plaintextBody、htmlBody、attachments。 |
MessageFormat
用于控制线程中消息的详细程度的枚举。
| 枚举 | |
|---|---|
MESSAGE_FORMAT_UNSPECIFIED |
默认值为 FULL_CONTENT。 |
MINIMAL |
返回邮件摘要和关键标头(主题、发件人、收件人、抄送、日期)。 |
FULL_CONTENT |
返回“MINIMAL”中的所有信息,以及每封邮件的完整正文内容。 |
METADATA_ONLY |
仅限元数据:不包括主题、摘要、正文、附件文件名。 |
输出架构
包含消息列表的线程。
线程
| JSON 表示法 |
|---|
{
"id": string,
"messages": [
{
object ( |
| 字段 | |
|---|---|
id |
线程的唯一标识符。 |
messages[] |
相应线程中的消息列表,按时间顺序排序。 |
消息
| JSON 表示法 |
|---|
{
"id": string,
"snippet": string,
"subject": string,
"sender": string,
"toRecipients": [
string
],
"ccRecipients": [
string
],
"date": string,
"plaintextBody": string,
"attachmentIds": [
string
],
"htmlBody": string,
"attachments": [
{
object ( |
| 字段 | |
|---|---|
id |
消息的唯一标识符。 |
snippet |
消息正文的简短内容。 |
subject |
从标头中提取的邮件主题: |
sender |
发件人的电子邮件地址。 |
toRecipients[] |
收件人电子邮件地址。 |
ccRecipients[] |
抄送收件人的电子邮件地址。 |
date |
消息的日期,采用 ISO 8601 格式 (YYYY-MM-DD)。 |
plaintextBody |
完整正文内容,仅在 MessageFormat 为 FULL_CONTENT 时填充。 |
attachmentIds[] |
仅限输出。附件 ID,仅当 MessageFormat 为 FULL_CONTENT 时填充。 |
htmlBody |
电子邮件的 HTML 内容,仅在 MessageFormat 为 FULL_CONTENT 时填充。 |
attachments[] |
仅限输出。附件,仅当 MessageFormat 为 FULL_CONTENT 时填充。 |
labelIds[] |
附加到消息的标签的 ID。包含用户标签和标准系统标签的 ID,但仅限于 |
AttachmentMetadata
| JSON 表示法 |
|---|
{ "id": string, "mimeType": string, "filename": string } |
| 字段 | |
|---|---|
id |
仅限输出。附件的 ID。 |
mimeType |
附件的 MIME 类型。 |
filename |
附件的文件名。 |
工具注释
破坏性提示:❌ | 等幂性提示:✅ | 只读提示:✅ | 开放世界提示:❌
授权范围
需要以下 OAuth 范围之一:
https://mail.google.com/https://www.googleapis.com/auth/gmail.modifyhttps://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.metadata