gmail-mcp
gmail-mcp v1.0.0
用于 Gmail 的统一多账户 Google OAuth2 MCP 服务器。 跨多个 Google 账户无缝搜索、读取、撰写、发送、创建草稿和整理邮件。
功能(4 个统一工具)
gmail_search:使用官方 Gmail 搜索语法检索邮件(is:unread、from:boss@corp.com、subject:invoice、newer_than:2d、has:attachment)gmail_read:读取完整的邮件内容和元数据(主题、发件、正文文本、HTML、抄送、密送、标签、附件列表)gmail_send:发送邮件或创建草稿(支持 HTML、抄送、密送、线程回复和文件附件)gmail_manage:标签管理、归档、垃圾邮件处理、已读/未读切换、永久删除以及多账户清单
Related MCP server: Moist
多账户架构
单个 Google Cloud OAuth 客户端(credentials.json)即可认证多个 Gmail 账户。
令牌按账户存储在 ~/.secrets/gmail/tokens/<account_name>.json 中。
1. 设置 Google OAuth 凭据(一次性)
在 Google Cloud Console 中创建项目。
启用 Gmail API。
创建 OAuth 2.0 客户端 ID(桌面应用)。
下载客户端密钥 JSON 文件,并将其保存为
~/.secrets/gmail/credentials.json(或设置GMAIL_CREDENTIALS_JSON)。
2. 认证账户
为每个账户运行交互式授权 CLI:
gmail-auth default # Authenticates primary account
gmail-auth work # Authenticates secondary work account
gmail-auth client_x # Authenticates any additional account列出所有已认证的账户:
gmail-auth --list在 MCP 客户端中安装(Claude Desktop、OpenCode、Cursor、Windsurf)
选项 1:通过 uvx 即时安装(推荐)
{
"mcpServers": {
"gmail": {
"command": "uvx",
"args": ["--from", "git+https://github.com/Steph-ux/gmail-mcp.git", "gmail-mcp"]
}
}
}选项 2:通过 pip install 安装
pip install git+https://github.com/Steph-ux/gmail-mcp.git然后在你的 MCP 配置中:
{
"mcpServers": {
"gmail": {
"command": "gmail-mcp"
}
}
}选项 3:本地克隆(开发)
{
"mcpServers": {
"gmail": {
"command": "python",
"args": ["D:\\Steph\\script\\gmail-mcp\\server.py"]
}
}
}使用示例
1. 搜索邮件
# Search in default account:
gmail_search(query='is:unread from:github')
# Search in work account:
gmail_search(account='work', query='subject:invoice newer_than:7d')2. 读取邮件
gmail_read(account='work', message_id='18f2a9b4c10d')3. 发送邮件或创建草稿
# Send direct email:
gmail_send(
account='default',
to='colleague@example.com',
subject='Project Update',
body_text='Here is the latest status...',
body_html='<h1>Project Update</h1><p>Here is the latest status...</p>'
)
# Create a draft:
gmail_send(
account='work',
to='client@example.com',
subject='Proposal draft',
body_text='Please review the proposal.',
draft=True
)4. 整理与管理
# Archive email:
gmail_manage(account='work', action='archive', message_id='18f2a9b4c10d')
# Mark as unread:
gmail_manage(account='default', action='mark_unread', message_id='18f2a9b4c10d')
# Move to trash:
gmail_manage(account='default', action='trash', message_id='18f2a9b4c10d')
# List active accounts:
gmail_manage(action='list_accounts')测试
pytest tests许可证
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
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Gmail through the MCP protocol, supporting sending, reading, searching, replying, forwarding, managing drafts and labels, and saving attachments.123MIT
- AlicenseNot gradedqualityDmaintenanceEnables Gmail operations such as reading, sending, searching, and managing emails, threads, labels, and drafts via MCP tools.1MIT
- FlicenseNot gradedqualityCmaintenanceEnables searching, reading, and drafting emails across multiple Gmail accounts through a single MCP server.
- FlicenseNot gradedqualityCmaintenanceEnables reading, searching, sending, and drafting Gmail emails via MCP tools, with support for multiple accounts and background notifications.
Related MCP Connectors
Read, search, send, organize, draft and schedule email across your inboxes from any MCP client.
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…
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/Steph-ux/gmail-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server