
Gmail Tidy Mcp
io.github.imkath由 GitHub 帳號 imkath 發布v0.5.1更新於 Nov 7, 2026
Organize Gmail accounts: threads, attachments, labels, filters, drafts. Never sends or deletes.
概覽
本機 MCP 伺服器,讓助理搜尋、閱讀並整理多個 Gmail 帳戶——標籤、封存、篩選器和草稿,但絕不寄送或刪除郵件。
- 可以做什麼
- 連接並檢查多個 Gmail 帳戶,每個帳戶帶一個簡短標籤
- 跨帳戶搜尋和閱讀郵件,包括對話串、附件、寄件人統計和郵件清單
- 建立、重新命名和改色標籤,並依搜尋條件批次加上或移除標籤
- 列出、建立和刪除 Gmail 篩選器,並修改帳戶簽名檔
- 撰寫、列出和更新草稿,可作為對話串內的回复並附上本機檔案
- 檢視伺服器每次變更的本機稽核記錄
- 適用情境
- 適合讓助理協助整理爆滿的收件匣——封存電子報、套用標籤、設定篩選器,或準備由你自己寄出的草稿——同時不把寄送或刪除郵件的能力交給模型。
- 執行需求
- 需要 Node.js 22 或更新版本,以 stdio 方式在本機執行(npx gmail-tidy-mcp)。須自行建立 Google OAuth 桌面用戶端、啟用 Gmail API,並把用戶端 JSON 存到 ~/.config/gmail-tidy-mcp/oauth-client.json。登入透過瀏覽器完成,會要求 gmail.modify 與 gmail.settings.basic 權限。Linux 上需安裝 libsecret-tools 以使用金鑰環;也可透過 GMAIL_TIDY_KEY 自行提供金鑰。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Gmail Tidy Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
gmail-tidy-mcp
[npm] [test] [license] [MCP Registry]
An MCP server that lets your AI assistant read and organize several Gmail accounts at once: search, read, label, archive, set up filters and write drafts.
It cannot send or delete email. Not "it asks first": there is no tool for it, and a test fails the build if a send or delete call ever shows up in the code.
Why
Most Gmail MCP servers hand the model full control of your mailbox, including sending, and keep OAuth tokens in plain text on disk. That is a lot of trust to give a model that also reads emails written by strangers.
This one is built around a smaller promise: the assistant can help you get your inbox in order, but it can't send anything or delete anything.
What it can do
Each account gets a short label, so you can say things like "archive every newsletter older than a month in work".
What it will not do
- Send, reply, forward or delete email, or move it to Trash or Spam.
- Give the model a way to add those later: the tools are fixed in code and the model cannot call arbitrary Gmail endpoints.
Google has no scope that allows drafts but not sending, so the server asks for gmail.modify (which technically includes sending) plus gmail.settings.basic for filters. The guarantee comes from the code, and test/safety.test.js checks it on every run.
Security
- Tokens are encrypted with AES-256-GCM in
~/.config/gmail-tidy-mcp/tokens.enc(mode 600). The key lives in the macOS Keychain, the Linux Secret Service (secret-tool), or a DPAPI-protected file on Windows. You can also provide it yourself withGMAIL_TIDY_KEY(64 hex characters). - Sign-in uses PKCE and a random
state, with the redirect on127.0.0.1only. - The signed-in account is verified. After sign-in, the server asks Gmail which address it got. If it is not the one you asked for, or Google granted different scopes, the token is revoked and nothing is saved.
- Your own OAuth client. No shared client and no third-party server. Your mail goes from Google to your machine and nowhere else.
- Email content is fenced off as untrusted. Everything read from Gmail goes inside a block whose markers carry a random value per call, so an email can't close the block early. Control characters in headers are removed, and HTML is reduced to visible text (scripts, styles, and text hidden with
display:none,visibility:hidden,font-size:0oropacity:0are dropped). - Invisible text is removed. Unicode tag characters (used to smuggle instructions that a model reads but you can't see), zero-width characters and text-direction controls are stripped from headers, bodies and attachments. Tag characters are reported, since they have no legitimate use in mail.
- Security notes come from the server, not the sender.
get_emailandget_attachmentadd a short list of findings above the untrusted block: phrasing typical of prompt injection, failed SPF, DKIM or DMARC, a Reply-To that sends answers to a free webmail address when the sender didn't pass DMARC, a display name that pretends to be another address, and links that show one site but lead to another (Gmail and Outlook redirect wrappers are unwrapped first; tracking links in mailing lists are not flagged). They are tuned to stay quiet on normal mail, so a note means something. - Lookalike senders are flagged. A sender whose domain is one or two letters away from one of your connected accounts (or uses letters from other scripts that look Latin) gets a note; for Gmail and other webmail the mailbox name is compared instead. Mail between your own accounts is never flagged.
- Drafts only attach files from your user folders. Attachments must live under Downloads, Desktop or Documents (or the folders in
GMAIL_TIDY_ATTACH_DIRS), never in a hidden folder and never this server's own config. Links are resolved before the check, so a shortcut can't point at~/.ssh. That way a model steered by a malicious email can't slip a private key or token into a draft for you to send. - Every change is logged locally. Labels, archiving, filters, drafts, signature changes and saved files are appended to
~/.config/gmail-tidy-mcp/audit.log(mode 600), without message bodies, draft text or the signature itself.recent_changesshows them, so if something odd happened in a session you can see exactly what and undo it. - Dangerous attachments are not saved. Executables and scripts, disguised names (
factura.pdf.exe, right-to-left override tricks), files whose bytes don't match their extension, and archives that contain any of those are refused unless the call saysallow_risky: true. Password-protected archives, macro-enabled Office files and PDFs with JavaScript or auto-run actions are flagged. Saved files never overwrite anything, can't be written outside the downloads folder, and on macOS get the quarantine flag so Gatekeeper checks them before they open. - Drafts can't smuggle headers. Line breaks in To, Cc, Subject or the reply headers are rejected, so nobody can sneak in a hidden Bcc.
- Arguments are validated before anything reaches Gmail, and the tools that change things carry MCP annotations (
destructiveHint) so clients can ask you before running them. - Big scans respect Gmail's quota.
sender_stats,newslettersand searches fetch a few messages at a time and back off when Gmail asks, so a large mailbox slows the scan down instead of breaking it. - Two runtime dependencies (
@modelcontextprotocol/sdkandgoogleapis), pinned to exact versions, none with install scripts.
What could still go wrong
No server can make prompt injection impossible, and the security notes are heuristics: they catch common tricks, not every one, and a clean result proves nothing. If a malicious email convinces the model, it could still:
- relabel or archive mail (you can undo this),
- create a filter that hides new mail from the inbox (only with
skip_inbox: true, and your client can ask you first), - delete one of your filters (filters can't be recovered),
- write a misleading draft. It is never sent unless you send it,
- rename or recolor a label, change your signature, or rewrite one of your drafts (all reversible: the audit log keeps what changed),
- save an attachment flagged as dangerous, if it also sets
allow_risky: true; opening it is still up to you.
Two more things worth knowing:
- The token itself can send mail. The "never send" guarantee is in this code, not in the token. If someone steals the token and the key, they get what
gmail.modifyallows. Keep your machine and keyring locked. - On macOS, the Keychain item trusts
/usr/bin/security, which means any process running as you can read the key without a prompt. That still keeps the key off the disk, but it is not a barrier against malware running under your user.
Setup
Requires Node.js 22 or newer.
1. Create your Google OAuth client (once)
- In Google Cloud Console, create a project and enable the Gmail API.
- In Google Auth Platform, set up the app as External, add your email as the support and contact address, and publish it (Audience → Publish app). Unverified apps in production keep their refresh tokens. In testing mode they expire after 7 days.
- Under Clients, create a client of type Desktop app and download the JSON.
- Save it as
~/.config/gmail-tidy-mcp/oauth-client.jsonand make it private (chmod 600on macOS and Linux).
When you connect an account, Google warns that the app is unverified. That is expected: the app is yours. Continue through Advanced.
2. Register it with your MCP client
Claude Code:
Any other MCP client: run npx -y gmail-tidy-mcp over stdio.
Prefer to run it from source? Clone the repo, run npm ci --ignore-scripts, and point your client at node /path/to/gmail-tidy-mcp/bin/gmail-tidy-mcp.js.
On Linux, install libsecret-tools first so the key can go into your keyring.
3. Connect accounts
Ask your assistant to connect an account. It opens Google's sign-in page in your browser. Or do it from the terminal:
Removing an account deletes its token locally. To revoke access on Google's side too, go to myaccount.google.com/permissions.
Google Workspace accounts may need an admin to allow unverified apps.
Development
The tests cover the safety guarantee (no send or delete calls, no Trash or Spam, filter actions limited to labels), token encryption and key handling, the sign-in callback (state, errors, timeouts), the post-login checks, draft headers and body decoding. CI runs them on Linux, macOS and Windows, including the real DPAPI path on Windows.
Credits
This started from gx-55/multi-gmail-mcp (MIT) by Rogers Xie. Some of its building blocks remain: the label-or-address account lookup, the message search and header helpers, the reply threading and the token-error detection. The storage, sign-in flow, tool set and safety model were redesigned.
License
MIT. See LICENSE.
來源:README.md,提交 6df48c6
工具
0版本歷史
4- v0.5.1最新Nov 7, 2026
- v0.5.0Oct 21, 2026
- v0.3.0Oct 14, 2026
- v0.1.1Oct 12, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分