advanced-gmail-mcp
A Gmail MCP server for Claude Code that enables full email management across multiple Gmail accounts, including tools for listing, searching, reading, sending, and organizing emails with OAuth2 authentication.
README
Gmail MCP Server

A Gmail MCP server for Claude Code that provides full email management across multiple Gmail accounts.
Features
- 12 tools: list, search, read, thread, labels, send, draft, reply, archive, label, trash, batch modify
- Multi-account support with simple aliases
- OAuth2 authentication with interactive CLI flow
- Token auto-refresh — re-authenticates transparently
- Rate limit retry with exponential backoff
- Claude Code commands included (
/emailand/checkemail) for structured inbox triage
Quick Start
1. Clone & Install
git clone https://github.com/coreyepstein/advanced-gmail-mcp.git
cd advanced-gmail-mcp
npm install
2. Google Cloud Setup
- Go to Google Cloud Console
- Create a new project (or select an existing one)
- Enable the Gmail API:
- APIs & Services → Enable APIs → search "Gmail API" → Enable
- Configure the OAuth consent screen:
- APIs & Services → OAuth consent screen
- User type: External (or Internal if using Google Workspace)
- Add your email address(es) as test users
- Add scopes:
gmail.readonly,gmail.modify,gmail.send,gmail.compose
- Create OAuth credentials:
- APIs & Services → Credentials → Create Credentials → OAuth client ID
- Application type: Desktop app
- Download the JSON file
- Save the downloaded file as
credentials.jsonin the project root
3. Configure Accounts
cp accounts.example.json accounts.json
Edit accounts.json with your Gmail accounts:
{
"accounts": [
{ "email": "you@gmail.com", "alias": "personal" },
{ "email": "you@company.com", "alias": "work" }
],
"default": "personal"
}
You can add as many accounts as you want. Each needs a unique alias.
4. Authenticate
# Authenticate all accounts (opens browser for each)
npm run auth
# Or authenticate a single account
npm run auth -- work
# Check auth status
npm run auth:check
The auth flow opens a browser window for each account. Tokens are saved to ./tokens/.
5. Add to Claude Code
Add to your MCP config (project .mcp.json or ~/.claude.json):
{
"mcpServers": {
"gmail": {
"type": "stdio",
"command": "npx",
"args": ["tsx", "/absolute/path/to/gmail-mcp/src/server.ts"]
}
}
}
Important: Use the absolute path to
src/server.ts.
6. (Optional) Add Commands
Copy the included Claude Code commands for structured email workflows:
# From your project root (where .claude/ lives)
mkdir -p .claude/commands
cp /path/to/gmail-mcp/.claude/commands/email.md .claude/commands/
cp /path/to/gmail-mcp/.claude/commands/checkemail.md .claude/commands/
Then use /email or /checkemail in Claude Code.
Tools
| Tool | Description |
|---|---|
list_emails |
List inbox or label emails |
search_emails |
Search with Gmail query syntax |
read_email |
Read full email by ID |
get_thread |
Get full thread with all messages |
get_labels |
List all labels |
send_email |
Send a new email |
draft_email |
Create a draft |
reply_email |
Reply with proper threading |
archive_email |
Archive (remove INBOX label) |
label_email |
Add/remove labels |
trash_email |
Move to trash |
batch_modify |
Batch archive/trash/label |
All tools accept an optional account parameter (alias or email). Defaults to the account set in accounts.json.
Commands
/email [action] [account]
Full email management command with actions:
- triage — Summarize inbox, batch archive/trash
- cleanup — 4-phase daily email workflow
- search {query} — Cross-account search
- send / draft / reply — Compose with confirmation
/checkemail [account]
Quick 3-phase inbox sweep:
- Fetch & classify all inbox emails (auto-archive junk)
- Batch archive on approval
- Walk through remaining emails one at a time
Troubleshooting
| Error | Fix |
|---|---|
accounts.json not found |
Copy accounts.example.json to accounts.json |
credentials.json not found |
Download OAuth credentials from GCP Console |
No token for... |
Run npm run auth -- <alias> |
Token refresh failed |
Re-authenticate: npm run auth -- <alias> |
403 Forbidden |
Add your email as test user in GCP OAuth consent screen |
403 insufficient scopes |
Re-authenticate to get updated scopes |
License
MIT
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。