gmail-cleanup-mcp
Gmail Cleanup MCP Server
一个专注于 Gmail 收件箱清理的 Model Context Protocol 服务器 — 将邮件移到回收站、管理过滤器、提取退订链接。旨在补充 Anthropic 内置的 Gmail 连接器,后者负责读取、搜索、草稿和发送。
这是 dcerniglia/gmail-cleanup-mcp 的修补分支(MIT 许可)。该分支修复了一个 bug:
search_and_trash和batch_trash_emails过去会静默丢弃失败而不重试 — 同时发出 50 个并发删除请求可能会触发 Gmail 的速率限制,并在不显示任何错误的情况下丢弃约一半批次。现在这两个工具都会以更小的批次处理、退避、自动重试,并针对每条失败消息报告实际错误。
工具
工具 | 描述 |
| 将单个邮件移到回收站(30 天安全网) |
| 按邮件 ID 将最多 500 封邮件移到回收站,每批处理 50 封 |
| 按 Gmail 查询条件查找邮件并将其移到回收站 — 支持 试运行 预览 |
| 创建过滤器以自动归档、自动打标签、自动删除或转发 |
| 列出所有现有 Gmail 过滤器及其条件和操作 |
| 按 ID 移除 Gmail 过滤器 |
| 从邮件中提取 |
Related MCP server: Gmail AutoAuth MCP Server
前置要求
Node.js 18+
一个启用了 Gmail API 的 Google Cloud 项目
OAuth 2.0 凭据(桌面应用类型)
设置
1. Google Cloud OAuth
已经有来自其他 Gmail MCP 服务器的
~/.gmail-mcp/gcp-oauth.keys.json? 跳到第 2 步 — 此服务器使用相同的凭据位置。
创建项目(或复用现有项目)并启用 Gmail API
转到 凭据 → 创建凭据 → OAuth 客户端 ID
选择 桌面应用,下载 JSON
将其保存为
~/.gmail-mcp/gcp-oauth.keys.json(或将gcp-oauth.keys.json放在项目目录中 — 首次运行时会自动复制)
2. 安装与构建
git clone https://github.com/davidcerniglia/gmail-cleanup-mcp.git
cd gmail-cleanup-mcp
npm install
npm run build3. 身份验证
npm run auth这会在浏览器中打开 Google OAuth 授权页面。凭据将保存到 ~/.gmail-mcp/credentials.json,权限为 0600(仅所有者)。
4. 添加到 Claude Desktop
添加到 ~/Library/Application Support/Claude/claude_desktop_config.json(macOS):
{
"mcpServers": {
"gmail-cleanup": {
"command": "node",
"args": ["/absolute/path/to/gmail-cleanup-mcp/dist/index.js"]
}
}
}对于 Claude Code,则添加到 .claude/settings.json:
{
"mcpServers": {
"gmail-cleanup": {
"command": "node",
"args": ["/absolute/path/to/gmail-cleanup-mcp/dist/index.js"]
}
}
}使用示例
提示 | 实际行为 |
"将所有来自 newsletter@spam.com 且超过 6 个月的邮件移到回收站" | 使用 Gmail 查询语法的 |
"做一次试运行 — 显示 LinkedIn 中会被移到回收站的邮件" |
|
"创建一个过滤器,自动归档来自 nextdoor.com 的邮件" |
|
"检查那封营销邮件是否有退订链接" |
|
与 Claude 内置 Gmail 的配合方式
内置 Gmail 连接器 | 本服务器 | |
搜索与读取 | 是 | — |
草稿与发送 | 是 | — |
将邮件移到回收站 | — | 是 |
批量清理 | — | 是(每次最多 500 封) |
过滤器管理 | — | 是 |
退订信息提取 | — | 是 |
安全性
最小权限范围:
gmail.modify+gmail.settings.basic— 执行回收站和过滤器操作所需的最小权限移到回收站,而非永久删除:所有删除操作都使用 Gmail 的回收站(30 天恢复期),绝不会永久删除
试运行模式:
search_and_trash可以在执行前预览匹配结果严格的文件权限:凭据以
0600权限存储(仅所有者可读写)不处理附件:零路径遍历风险
不访问任何文件系统,仅
~/.gmail-mcp/中的凭据存储除外
环境变量
变量 | 默认值 | 描述 |
|
| OAuth 客户端密钥的路径 |
|
| 已存储凭据的路径 |
许可证
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseCqualityDmaintenanceEnables comprehensive Gmail management through the Gmail API, including sending/receiving emails, organizing labels and threads, managing drafts, and configuring account settings with secure OAuth2 authentication.641,3981MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage Gmail through natural language interactions, supporting email operations (send, read, search, draft), comprehensive attachment handling (send, receive, download), label management, filters, and batch operations with automatic OAuth2 authentication.192MIT
- AlicenseNot gradedqualityFmaintenanceProvides comprehensive Gmail integration with 25+ tools for intelligent email management, including AI-powered categorization, advanced search and filtering, automated archiving and cleanup, analytics, and secure OAuth2 authentication.1922MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage Gmail through natural language, supporting operations like sending, searching, and reading emails. It includes comprehensive label management, batch processing, and a streamlined OAuth2 auto-authentication flow.MIT
Related MCP Connectors
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…
Manage Gmail messages, threads, labels, drafts, and settings from your workflows. Send and organiz…
AI email automation, follow-ups, training, previews, and mailbox troubleshooting.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/adityai4/gmail-cleanup-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server