连接器指南阅读约 4 分钟15 个 MCP 工具7 种语言

如何通过 MCP 将 Gmail 连接到 Claude

让你的 AI 在 Gmail 中工作:用 Gmail 自己的搜索语法搜索邮箱,读取邮件和会话,把邮件标为已读、归档、加星标或加标签,撰写、回复和发送邮件,或者保存草稿供你先检查。支持个人 Gmail 和 Google Workspace,使用你自己的 Google OAuth 客户端。

HC作者:HelpCode 团队更新于 4 分钟阅读 在 GitHub 开源

无需信用卡 · 7 天试用 · 提供自托管方案

Gmail

Gmail

Let your AI work in Gmail: search the mailbox with Gmail's own search syntax, read messages and conversations as plain text, see labels and unread counts, mark mail as read, archive, star or label it, write and send new mail, reply in a conversation, and save or send drafts. Personal Gmail and Google Workspace, signed in with your Google account.

个工具

15

区域

INTL

类别

电子邮件

身份验证

OAuth 2.0

所需环境变量

GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRET
在 Cloud 上一键安装

7 天免费试用 · 无需信用卡

  • 7 天免费试用
    无需信用卡
  • 符合 GDPR,SOC 2 就绪
    数据驻留欧盟,审计日志
  • 在 GitHub 开源
    开源 · AGPL-3.0
  • 支持 ChatGPT、Claude、Gemini
    任何兼容 MCP 的客户端

跳过安装。2 分钟内即可运行。

在 cloud.anythingmcp.com 开始免费试用,一键添加 Gmail,然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。

开始免费试用

AnythingMCP 已收录在 Claude 的连接器目录中:一键添加到 Claude (在新标签页中打开),然后登录并选择 Claude 可以使用哪些 MCP 服务器。

摘要

让你的 AI 在 Gmail 中工作:用 Gmail 自己的搜索语法搜索邮箱,读取邮件和会话,把邮件标为已读、归档、加星标或加标签,撰写、回复和发送邮件,或者保存草稿供你先检查。支持个人 Gmail 和 Google Workspace,使用你自己的 Google OAuth 客户端。

试试这样问

Gmail 的示例提示

点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。

Gmail · 通过 MCP 实时
分享
Opus 4.7

Claude 是 AI,可能会出错。请核对回答。

💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → Gmail、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无 git clone、无本地服务器。

Gmail + Claude

让你的 AI 在 Gmail 中工作:用 Gmail 自己的搜索语法搜索邮箱,读取邮件和会话,把邮件标为已读、归档、加星标或加标签,撰写、回复和发送邮件,或者保存草稿供你先检查。支持个人 Gmail 和 Google Workspace,使用你自己的 Google OAuth 客户端。

前提条件

完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:

GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET

步骤 1 — 获取凭证

  1. 打开 console.cloud.google.com,选择或创建一个项目,然后进入 APIs & Services → Library 启用 Gmail API。
  2. 打开 APIs & Services → OAuth consent screen。如果邮箱在 Google Workspace 中,选择 Internal(最简单),否则选择 External。选择 External 时,请把发布状态设为 In production:应用处于 Testing 状态时,Google 会在 7 天后撤销它的刷新令牌,连接器每周都会停止工作。
  3. 打开 APIs & Services → Credentials → Create credentials → OAuth client ID,应用类型选择 Web application,并添加已授权的重定向 URI https://cloud.anythingmcp.com/api/mcp-oauth/callback。如果你自行托管 AnythingMCP,请改填 https://your-anythingmcp-host/api/mcp-oauth/callback。
  4. 把客户端 ID 填入 GOOGLE_CLIENT_ID,把客户端密钥填入 GOOGLE_CLIENT_SECRET,然后安装连接器。
  5. 在连接器页面点击 Authorize with Provider,用 AI 要使用的 Gmail 账户登录。刷新令牌会加密存储,访问令牌会自动续期。
  6. 让 AI 调用 gmail_get_profile:它会返回连接器所用的邮箱地址,以及邮箱中的邮件数和会话数。

一个 Google 客户端服务所有 Google 连接器:同一个 Cloud 项目和 OAuth 客户端可以服务所有 Google 连接器:Gmail、Google Calendar、Google Drive、Google Sheets、Google Docs、Google Tasks、Search Console、Analytics 和 Ads。在该项目中启用每个 API,复用同一个客户端 ID 和密钥,并为每个连接器各授权一次。每个连接器只请求它自己需要的权限。

Google 验证:Google 把这个连接器使用的 Gmail 权限(gmail.modify,只读设置时为 gmail.readonly)列为受限(restricted)权限。Internal 应用只供拥有该 Cloud 项目的 Workspace 组织内的账户使用,无需验证,对公司来说这是最直接的方式。供其他人使用的 External 应用会显示“Google hasn't verified this app”警告,并且在通过 Google 验证之前最多只能有 100 个用户;对于受限权限,验证还包括安全评估。如果只是单个个人 Gmail 账户,只有你自己使用的、处于 In production 状态的 External 应用在跳过警告后即可使用。

权限:连接器请求 https://www.googleapis.com/auth/gmail.modify:读取邮件、更改标签(标为已读、归档、加星标)、创建草稿和发送邮件。它以授权它的 Google 账户身份工作,看到的内容与该账户完全相同。它无法永久删除任何内容。

哪些工具会真正发出邮件:gmail_send_message(新邮件)、gmail_reply(会话中的回复)和 gmail_send_draft(按原样发送现有草稿)会立即从已登录的地址发送,发送后无法撤回。gmail_create_draft 只保存草稿(也可以是会话中的回复草稿),由你在 Gmail 中检查并发送;如果你没有明确要求发送,连接器会让 AI 优先保存草稿。一封邮件最多发给 500 个收件人。AI 读取的邮件中可能含有要求它发送内容的文字:如果 AI 只需要准备邮件,请停用 gmail_send_message、gmail_reply 和 gmail_send_draft,由你自己发送草稿。

只读设置:在连接器的 OAuth 设置中把 scope 改为 https://www.googleapis.com/auth/gmail.readonly,重新授权,并停用 gmail_modify_message_labels、gmail_modify_thread_labels、gmail_create_draft、gmail_send_draft、gmail_send_message 和 gmail_reply。

读取和整理邮件:搜索使用与 Gmail 搜索框相同的语法,例如 from:[email protected] is:unread newer_than:7d 或 has:attachment。邮件和会话以纯文本返回(只有 HTML 的邮件会被转换成文本);很长的正文在 20,000 个字符处截断,整个会话则在 100,000 个字符处截断。附件会列出名称、类型和大小,但不会下载。标为已读、归档、加星标和按标签归类,都是对单封邮件或整个会话更改标签。

速率限制:Gmail 允许每个用户每分钟 6,000 个配额单位。一次搜索花费 5 个,读取一封邮件 20 个,读取一个会话 40 个,发送一封邮件或草稿 100 个。超出限制时 Gmail 返回 429(或 403 userRateLimitExceeded):请等一分钟后重试。

常见错误:401 表示授权已过期或被撤销(同意屏幕处于 Testing 状态时,7 天后必然发生):请再次点击 Authorize with Provider。403 accessNotConfigured 表示 Cloud 项目中没有启用 Gmail API。403 insufficientPermissions 或 ACCESS_TOKEN_SCOPE_INSUFFICIENT 表示 scope 不允许该调用,例如在只读设置下更改标签。404 表示此邮箱中不存在该 ID;草稿 ID(以 r- 开头)不是邮件 ID。400 invalidArgument 通常表示标签 ID 不存在:自建标签的 ID 形如 Label_12,可以通过 gmail_list_labels 获取。

连接器不发送或下载附件,不连同原始附件转发邮件,不把邮件移到回收站,也不删除邮件,并且不处理过滤器、设置、发件别名或其他人的邮箱。

步骤 2 — 安装 adapter

curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d

步骤 3 — 在 Claude 中添加连接器

你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(https://cloud.anythingmcp.com/mcp/…)。本指南中出现 YOUR_SERVER_ID 的地方都用它替换。

推荐路径:在 claude.ai web 上工作,无需触碰任何配置文件。

  1. 在 Claude 中打开 Customize → Connectors。
  2. 点击 +,然后点击 Add custom connector。
  3. 输入名称(例如 Gmail)和远程 MCP 服务器 URL https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID,然后点击 Add。
  4. 点击 Connect,登录 AnythingMCP(OAuth)并允许访问。

下面所有工具都会出现在你的聊天中,开始输入提示。

可用工具

ToolWhat it does
gmail_get_profileReturn the Gmail account the connector works with: its email address, the total number of messages and threads in the mailbox, and the…
gmail_list_messagesSearch or list messages in the mailbox with Gmail search syntax and optional label filters
gmail_get_messageGet one message by id, decoded: sender, recipients, subject, date, Message-ID and References, labels and the body as plain text (HTML-only…
gmail_list_threadsSearch or list conversations (threads) with Gmail search syntax and optional label filters
gmail_get_threadGet one conversation by thread id with all its messages in order, each decoded like gmail_get_message: sender, recipients, subject, date…
gmail_list_labelsList all labels of the mailbox, system labels (INBOX, UNREAD, STARRED, SENT, SPAM, TRASH, categories) and the user's own, with id, name and…
gmail_get_labelGet one label by id with its message and thread counts, total and unread, plus its visibility settings and colour
gmail_modify_message_labelsAdd and remove labels on one message: mark it read (remove UNREAD) or unread (add UNREAD), archive it (remove INBOX), star it (add STARRED)…
gmail_modify_thread_labelsAdd and remove labels on every message of a conversation at once, e.g. archive a whole thread (remove INBOX) or mark it read (remove UNREAD)
gmail_list_draftsList the drafts in the mailbox, optionally filtered with Gmail search syntax
gmail_get_draftGet one draft by draft id with its message decoded: recipients, subject and the body as plain text, to check it before it is sent with…
gmail_create_draftSave a new email as a draft in the mailbox without sending it, so the user can review it in Gmail; send it later with gmail_send_draft
gmail_send_draftSend an existing draft to its recipients exactly as it is written
gmail_send_messageWrite and send a new email from the signed-in Gmail account right away
gmail_replySend a reply inside an existing conversation

示例提示

  • “过去 3 天里哪些未读邮件还需要我回复?每封用一句话概括。”
  • “找到 [email protected] 关于报价的最新一封邮件,写一份接受新日期的回复草稿。先不要发送,我会在 Gmail 里检查。”
  • “把收件箱里一周以前的所有新闻通讯标为已读并归档,然后列出你归档了哪些。”
  • “列出 10 月 1 日以来所有看起来像发票的带附件邮件,包括发件人、日期、主题和文件名。”

FAQ

Claude Code 和 Claude Desktop 一样工作吗? 是的,两者都指向 https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID。

下一步

这份指南对你有帮助吗?

你的 Gmail 智能体只差一次点击。

安装连接器,粘贴密钥,向 Claude 提问。免费试用 7 天,无需信用卡。

相关指南

连接器

如何通过 MCP 将 Gmail 连接到 ChatGPT

让你的 AI 在 Gmail 中工作:用 Gmail 自己的搜索语法搜索邮箱,读取邮件和会话,把邮件标为已读、归档、加星标或加标签,撰写、回复和发送邮件,或者保存草稿供你先检查。支持个人 Gmail 和 Google Workspace,使用你自己的 Google OAuth 客户端。

连接器

如何通过 MCP 将 Gmail 连接到 Cursor

让你的 AI 在 Gmail 中工作:用 Gmail 自己的搜索语法搜索邮箱,读取邮件和会话,把邮件标为已读、归档、加星标或加标签,撰写、回复和发送邮件,或者保存草稿供你先检查。支持个人 Gmail 和 Google Workspace,使用你自己的 Google OAuth 客户端。

连接器

如何通过 MCP 将 Gmail 连接到 Gemini

让你的 AI 在 Gmail 中工作:用 Gmail 自己的搜索语法搜索邮箱,读取邮件和会话,把邮件标为已读、归档、加星标或加标签,撰写、回复和发送邮件,或者保存草稿供你先检查。支持个人 Gmail 和 Google Workspace,使用你自己的 Google OAuth 客户端。

连接器

如何通过 MCP 将 Gmail 连接到 Meta Muse

让你的 AI 在 Gmail 中工作:用 Gmail 自己的搜索语法搜索邮箱,读取邮件和会话,把邮件标为已读、归档、加星标或加标签,撰写、回复和发送邮件,或者保存草稿供你先检查。支持个人 Gmail 和 Google Workspace,使用你自己的 Google OAuth 客户端。

连接器

Gmail 接入 MCP:从任意 AI 代理驱动 Gmail

让你的 AI 在 Gmail 中工作:用 Gmail 自己的搜索语法搜索邮箱,读取邮件和会话,把邮件标为已读、归档、加星标或加标签,撰写、回复和发送邮件,或者保存草稿供你先检查。支持个人 Gmail 和 Google Workspace,使用你自己的 Google OAuth 客户端。

连接器

如何通过 MCP 将 Canva 连接到 Claude

让你的 AI 在 Canva 中工作:查找和读取设计,创建新设计,将设计导出为 PDF、PNG、PowerPoint 或视频并获取下载链接,整理文件夹,通过链接上传图片,读取品牌模板,并在设计上发表评论。