
Google Mail Mcp
io.github.mmedum由 GitHub 账号 mmedum 发布v4.0.2更新于 Nov 4, 2026
Gmail over MCP from your own account: search, read threads and messages, labels and drafts.
概览
本地 stdio MCP 服务器,让助手以你的账号访问 Gmail:搜索、读取会话与邮件、管理标签和草稿。
- 可以做什么
- 搜索与读取邮件:用 Gmail 搜索语法查找会话或单封邮件,在预算内读取会话或单封邮件、读取附件文本,并按 history id 列出变更
- 查看账号信息:个人资料与统计、带计数的标签、草稿、设置与过滤器(只读)
- 处理草稿:新建、修改、删除草稿,包括回复与转发;不会发送
- 整理邮件:增删标签、将最多 100 项移入或移出垃圾箱、创建与重命名标签
- 把附件保存到指定的本地目录,且不覆盖已有文件
- 可选且默认关闭:发送草稿、永久删除、修改签名、过滤器或假期回复
- 适用场景
- 适合个人希望助手以自己的身份在自己的 Gmail 邮箱内工作:查找会话、总结邮件串、整理标签、准备草稿,并在未主动开启时保持发送与破坏性操作关闭。
- 运行要求
- 以本地进程(Go 二进制或 Claude Desktop 安装包)通过 stdio 运行,无托管端点。需要启用 Gmail API 的 Google Cloud 项目和一个桌面应用 OAuth 客户端,并一次性登录,刷新令牌保存在操作系统钥匙串中。设置通过 GMAIL_* 环境变量提供,例如 GMAIL_READ_ONLY、GMAIL_LOCAL_DIR、GMAIL_PROFILE。安装包本身不负责登录,需另装二进制完成。
安装
在 SourceWeft 中
- 打开 控制台中的 Google Mail Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
google-mail-mcp
[CI] [Latest release] [Go Reference] [License: Apache 2.0]
Gmail as MCP tools. Read your mail without letting it read your assistant.
A single Go binary that speaks MCP over stdio. It runs as a subprocess of your client, on your own machine, against your own Google account. There is no server to host and no service account: you create a Google OAuth client, log in once, and the refresh token stays in your OS keyring.
It is for one person who uses Gmail, on a Workspace or a personal Google account, and wants an assistant to search, read, organize and draft mail as them. It works inside a mailbox: a calendar invitation's event, a linked Drive file and a Chat space belong to servers built on those APIs.
Goals and non-goals
Goals:
- Mail never steers the assistant through the server. It comes back marked as data, hidden text is removed and counted, nothing it links to is fetched, and the writes that redirect mail do not exist.
- Nothing reaches another person, or is lost for good, unless you turn it on. Sending, permanent deletion and settings changes are not registered by default, and removal is trash.
- A write changes only what it names. Writes take explicit ids, never
a search, report each item on its own, and take
dry_run. - Reads are bounded. Every read has a budget and says what it left out and how to continue.
- Act as you, and log nothing about your mail. Every call runs as the signed-in account, and the logs never carry content or addresses.
Non-goals:
- Push notifications. Gmail's
watchdelivers to a Cloud Pub/Sub topic, which a stdio process cannot own.list_changespolls instead. - Bulk operations over a search. No "archive everything from X" and no relabeling by query; a search is a read you have seen first.
- Settings that send mail elsewhere. Auto-forwarding, forwarding addresses, filters that forward, delegation and send-as identities are never written.
- Mailbox migration. Importing or inserting mail that was never sent is out.
- Rendering HTML. HTML becomes text, and nothing is fetched.
- A contacts directory. Addresses come from you or from the message being answered; turning a name into an address belongs to a People API server.
- Workspace administration. No service accounts and no domain-wide delegation.
- A hosted service. It speaks stdio only, so Claude on the web and on mobile cannot reach it.
- Asking you before a call. Your client approves each call; the server asks nothing.
What makes this one different
Every message was written by somebody other than you, and some of it is written to steer an AI assistant. So mail comes back inside blocks marked with a per-call boundary token; text a reader of the mail would not have seen — hidden styles, zero-width characters, text colored like its background — is removed and counted; nothing a message links to or embeds is fetched; and a link whose text names a different site from its target is flagged.
The writes that would make a persuaded assistant dangerous are not there. Automatic forwarding, filters that forward and delegation are not implemented; forwarding one message attaches it to a draft. Sending is not registered unless you turn it on, and then only a draft can be sent. Removal is trash; permanent deletion is not registered unless you turn it on, and is the only thing that asks Google for full mail access.
Reads are bounded. A thread comes back newest first within a character budget, with quoted replies and signatures collapsed to a line saying how much was hidden, and every omission says how to continue. Non-ASCII subjects, names and filenames decode in any charset.
The design and the decisions behind it are in
docs/architecture.md.
Install
Or take an archive from the latest release — Linux, macOS and Windows, on amd64 and arm64 — and verify it before you run it:
Every archive ships an SBOM. Builds are reproducible: rebuilding a tag gives the same bytes.
Claude Desktop
Every release also carries a .mcpb bundle. Open it and Claude Desktop
installs the server and asks for the settings a client's configuration
would carry: your OAuth client JSON, the profile, read-only, the
switches and the attachment folder. Sending (enable_send), permanent
deletion (enable_destructive) and settings changes (enable_settings)
stay off unless you turn them on, and read-only cannot be combined with
any of them. Signing new drafts (draft_signature) is off too, and
registers no tool. This server asks nobody before a call. Claude Desktop
approves each tool, with Allow once or Always allow, and a tool you
always allow then runs unasked, so leave a switch off unless you need
its tools.
The bundle covers macOS, Windows and Linux on both architectures. Its
SHA-256 is in the same signed checksums.txt.
The bundle does not log you in. Install the binary as well, run
google-mail-mcp login --client-secret <your client JSON> once, and the
bundle uses the same credentials.
Set up Google
docs/gcp-setup.md has the whole of it: a Cloud
project with the Gmail API enabled, a consent screen (with the scopes
for how you will run the server, on an External app), and a Desktop
app OAuth client. Then:
Every Gmail scope that reads mail is one Google calls restricted. For your
own use that costs nothing, but an External client in Testing gets refresh
tokens that expire after seven days;
docs/troubleshooting.md says what that
looks like.
Logging in over SSH
The callback goes to the remote host's loopback address while your
browser is local, so forward the port. Run
google-mail-mcp login --no-browser: it prints the authorization URL and
the exact ssh -L line for the port it picked. Run that line in a second
local terminal, then open the URL locally.
Connect a client
Claude Code:
Or, in a client config file:
Every setting is a GMAIL_* environment variable, listed in
docs/configuration.md. The ones worth knowing
first: GMAIL_READ_ONLY=true registers only the read tools and asks for
read-only access; GMAIL_LOCAL_DIR is the one directory attachments may
be saved to; GMAIL_PROFILE lets one machine hold several accounts.
Tools
Searches take Gmail's own search language in q, plus after and
before as real instants — Gmail reads a date written inside q as
midnight Pacific time. Every result states the quota it spent. Every
write takes dry_run, names what it touches by id, and says what it
changed, read from Gmail's answer. GMAIL_READ_ONLY=true leaves the
writes out. A tool marked "only with" a setting is not registered at all
unless that setting is on.
For clients that attach rather than call, gmail://threads/{id},
gmail://messages/{id} and gmail://labels carry the same text as
get_thread, get_message and list_labels.
Safety
-
Mail is data. It arrives marked, with what was hidden removed and counted, and no tool description tells a model to act on it.
-
Nothing reaches another person by default. Drafts wait in Gmail to be sent, and by default no tool changes a setting. Forwarding settings are shown, never set.
-
Settings are opt-in. With
GMAIL_ENABLE_SETTINGS=truethe server can set a signature and create filters. A filter cannot forward. A filter that trashes mail is its own tool,create_trash_filter, and it anddelete_filteralso needGMAIL_ENABLE_DESTRUCTIVE=trueandconfirm: true. The vacation reply answers other people, so it also needsGMAIL_ENABLE_SEND=true, it only ever answers contacts or the account's domain, and turning it on needsconfirm: true. -
Sending is opt-in and goes through a draft. With
GMAIL_ENABLE_SEND=true,send_draftsends a draft exactly as it is stored. Every recipient, the thread's own participants included, must be written out inconfirm_recipients, the call carries the draft's subject and first line, so your client's prompt shows what goes, and a send Gmail does not confirm is never repeated. -
Removal is trash. Gmail keeps trashed mail for 30 days, and
restorebrings it back. By default the only permanent removal isdelete_draft, which needs the message the draft holds andconfirm: true.delete_permanentlyanddelete_labelexist only withGMAIL_ENABLE_DESTRUCTIVE=true, which also asks for the one scope that can delete; each call needsconfirm: true. -
Your client approves each call. The server does not ask you itself. claude.ai and Codex prompt for the tools marked destructive: every tool that changes the mailbox but
create_draftandcreate_label, which only add. VS Code prompts for every tool that writes. In Claude Code,delete_permanentlyanddelete_labelask on every call whatever your rules say, since mail deleted for good skips the trash and a label comes off every message. For the rest, list the calls you want to approve one by one underpermissions.askin your settings, with the name you gave the server in place ofgoogle-mail. The example allows the server's tools and asks for every call that sends, changes a setting or deletes for good. An ask rule wins over an allow rule. The everyday writes to drafts, labels and the trash run unasked:A client that runs with nobody watching can make every write that is registered, so leave
GMAIL_ENABLE_SEND,GMAIL_ENABLE_DESTRUCTIVEandGMAIL_ENABLE_SETTINGSoff for one. -
Files go to one directory.
download_attachmentanddownload_attachmentswrite only intoGMAIL_LOCAL_DIR, under a name made safe, and never over an existing file. -
Logs never carry mail. No address, subject, body, label name or query; ids are cut to six characters. A test drives every tool with marker values and fails if one reaches a log, which is what makes a debug log safe to paste.
-
Everything above but the client's prompt is enforced in the server. Tool annotations are set, but they are hints a client may ignore.
docs/security.md has the whole of it.
Getting help
Run google-mail-mcp doctor first: it checks the client JSON, the token,
the granted scopes and whether the Gmail API is enabled, and names what
is missing. docs/troubleshooting.md covers
the common surprises. Then open an issue with doctor's output and the
version.
Do not paste a tool result: it is mail, and carries other people's
words and addresses.
Versioning
Semantic versioning. The tool names and their output fields are the
public contract; CHANGELOG.md marks anything you have
to act on as Breaking.
Development
make check runs everything CI runs. make live drives the built binary
against a real account, and make evals scores a model against the
tools; both are run by hand. CONTRIBUTING.md covers
the gates, the live run and the review flow.
Documentation
docs/architecture.md: the request flow, the package layout, and the design decisions a contributor should not undo.docs/configuration.md: every setting, where state is stored, andstatus --json.docs/gcp-setup.md: the Google Cloud project, consent screen and OAuth client, step by step.docs/troubleshooting.md: symptoms and their fixes, then rotating the token, revoking access and handling a suspected exposure.docs/security.md: the threat model.docs/release.md: how a release is cut and checked.
Contributing
See CONTRIBUTING.md.
Security
Report a vulnerability through a private advisory; see
SECURITY.md.
Code of conduct
License
来源:README.md,提交 f9c09fe
工具
0版本历史
19- v4.0.2最新Nov 4, 2026
- v4.0.1Nov 3, 2026
- v4.0.0Nov 1, 2026
- v3.3.0Oct 30, 2026
- v3.1.2Oct 25, 2026
- v3.1.0Oct 24, 2026
- v3.0.0Oct 23, 2026
- v2.3.0Oct 14, 2026
- v2.2.0Oct 9, 2026
- v2.1.0Oct 6, 2026
- v2.0.4Oct 1, 2026
- v2.0.3Oct 1, 2026
- v2.0.2Sep 30, 2026
- v2.0.1Sep 29, 2026
- v2.0.0Sep 29, 2026
- v1.2.0Sep 28, 2026
- v1.1.1Sep 28, 2026
- v1.1.0Sep 27, 2026
- v1.0.0Sep 27, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分