gmail-mcp
MCP server for Gmail with full read/write coverage: search, send, reply, drafts, labels, filters, vacation responder, auto-forwarding, signature, and attachment handling (download and PDF export). Uses the Gmail API with the gmail.modify scope to prevent permanent deletion, and requires explicit confirmation for sensitive actions.
README
gmail-mcp
MCP server for Gmail with full read/write coverage: search, send, reply, drafts, labels, filters, vacation responder, auto-forwarding, signature, and attachment handling (download + render to PDF).
Built because the commonly available Gmail MCP integrations are read/label-only (no sending, no attachment export, no settings management). This one closes that gap using the standard Gmail API with your own OAuth client.
Why it's safe by design
The OAuth scope used is gmail.modify, not the full https://mail.google.com/
scope. This means the Gmail API itself rejects permanent delete
(messages.delete, batchDelete, threads.delete) — the only "removal" tool
is trash/untrash, which is reversible.
Tools (34)
Read / search
| Tool | What it does |
|---|---|
get_profile |
Account email and message/thread totals |
list_messages |
Search with Gmail query syntax (query, label_ids, pagination) |
get_message |
Parsed message: from/to/cc/subject/date/body/labels/attachments |
get_thread |
Full thread with all messages parsed |
list_attachments |
Real attachment metadata for a message (with attachment_id) |
download_attachment |
Download an attachment to disk |
export_message_to_pdf |
Render a message (HTML + inline images resolved) to PDF via WeasyPrint |
export_thread_to_pdf |
Same, for a full thread (one message per page) |
Send / reply (require confirmed=True)
| Tool | What it does |
|---|---|
send_message |
Send a new email (text/HTML, attachments) |
reply_message |
Reply within a thread, auto-generating In-Reply-To/References |
Drafts
| Tool | What it does |
|---|---|
list_drafts / get_draft |
List and read drafts |
create_draft / update_draft / delete_draft |
Manage drafts |
send_draft |
Send an existing draft (confirmed=True) |
Labels
| Tool | What it does |
|---|---|
list_labels / create_label / update_label |
Label management |
delete_label |
Delete a label (confirmed=True) |
modify_message_labels / modify_thread_labels |
Add/remove labels on a message or full thread |
Organization (trash only, reversible)
| Tool | What it does |
|---|---|
trash_message / untrash_message |
Move to trash / restore |
batch_modify_messages |
Change labels on several messages at once |
Settings
| Tool | What it does |
|---|---|
get_vacation / update_vacation |
Vacation auto-responder |
get_auto_forwarding / update_auto_forwarding |
Auto-forwarding (confirmed=True when enabling — this is a data-exfiltration vector, double check the destination address) |
list_filters / create_filter / delete_filter |
Filters (delete_filter requires confirmed=True) |
list_send_as / update_signature |
Send-as aliases and HTML signature (confirmed=True) |
Confirmation pattern
Tools that send mail, delete something, or change externally-visible settings
take confirmed: bool = False. Called without it, they return
{"requires_confirmation": true, ...} with a preview of what would happen —
the calling agent must show that preview to the user and only repeat the call
with confirmed=True after explicit approval. confirmed=True is a technical
flag, not a substitute for actually asking.
Setup
- Create a Google Cloud project (or reuse one) and enable the Gmail API.
- Create an OAuth 2.0 Client ID of type "Desktop app" and download it as
client_secret.json. - On the OAuth consent screen, add these scopes:
gmail.modify,gmail.settings.basic,gmail.settings.sharing. - If the app is in "Testing" mode, add your own Google account as a test user.
- Install dependencies:
python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt # weasyprint also needs a system package for PDF rendering: # macOS: brew install pango # Debian/Ubuntu: apt install libpango-1.0-0 libpangocairo-1.0-0 - Run the OAuth flow once per account:
This opens a browser — log in and grant access. Run it again with a differentCLIENT_SECRET_PATH=~/.config/gmail-mcp/client_secret.json \ TOKEN_OUT=~/.config/gmail-mcp/token.json \ python3 setup_auth.pyTOKEN_OUTfor each additional Gmail account you want to expose as a separate MCP server instance.
MCP client configuration
{
"mcpServers": {
"gmail": {
"command": "/path/to/.venv/bin/python3",
"args": ["/path/to/gmail-mcp/server.py"],
"env": {
"GMAIL_TOKEN_PATH": "~/.config/gmail-mcp/token.json"
}
}
}
}
To expose a second account, add another entry (e.g. gmail-work) pointing at
the same server.py with a different GMAIL_TOKEN_PATH.
| Env var | Default | Purpose |
|---|---|---|
GMAIL_TOKEN_PATH |
~/.config/gmail-mcp/token.json |
Path to the OAuth token for this account |
Notes on usage (for the calling agent)
- API quota: 6,000 units/user/minute.
messages.getcosts 20 units,messages.listcosts 5. Filter with Gmail'squerysyntax instead of fetching everything and filtering client-side. - Use
get_threadinstead of Nget_messagecalls when you need a whole conversation. attachment_idis not stable across calls — always use the one from the same response you're about to calldownload_attachmentwith.- Prefer
body_htmloverbody_textfor anything with lists, bold text or links — Gmail does not reflow plain text, so\nbecomes a hard line break. - No automatic retry on 429 — back off manually if you hit a rate limit.
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。