Connect Claude to your Gmail accounts — read, send, search, and manage email across multiple inboxes without leaving Claude.
You need one Google Cloud project that covers all your accounts. You don't need a separate project per inbox.
support@yourdomain.com forwards to a Gmail account), add the backing Gmail address as a test user — Google won't recognise the alias as a sign-in username.
credentials.json. Keep it secret — it grants access to create OAuth tokens for your accounts.Clone the repo and install dependencies. No build step needed — the server runs TypeScript directly via tsx.
git clone https://github.com/coreyepstein/advanced-gmail-mcp
cd advanced-gmail-mcp
npm install
Copy your downloaded OAuth JSON into the repo root and rename it:
cp ~/Downloads/client_secret_*.json ./credentials.json
chmod 600 credentials.json
mkdir -p tokens
chmod 700 tokens
credentials.json and tokens/ are already in .gitignore. Never commit them. The chmod commands lock them so only your user can read them.
Copy the example config and edit it with your accounts:
cp accounts.example.json accounts.json
Edit accounts.json:
{
"accounts": [
{
"email": "you@gmail.com",
"alias": "personal",
"name": "Your Name"
},
{
"email": "support@yourdomain.com",
"alias": "support",
"name": "Support Team"
},
{
"email": "admin@yourcompany.com",
"alias": "work",
"name": "Work Admin"
}
],
"default": "personal"
}
| Field | Purpose |
|---|---|
| Sets the From: address on outbound mail — use the alias address here, not the backing Gmail | |
| alias | Short name used in Claude prompts: "send from my work account" |
| name | Display name in the From header — e.g. "Support Team <support@yourdomain.com>" |
| default | Which account is used when none is specified |
support@yourdomain.com is a "Send mail as" alias, keep it in the email field so outbound mail uses that address. Gmail will honour it as long as the alias is verified under Settings → Accounts and Import → Send mail as.
Run the auth flow once per account. Each opens a browser URL — sign in and approve, then the token is saved automatically.
# Authenticate one account at a time
npx tsx src/auth.ts personal
npx tsx src/auth.ts work
npx tsx src/auth.ts support
# Or authenticate all accounts in sequence
npx tsx src/auth.ts
# Check status of all accounts
npx tsx src/auth.ts --check
accounts.json is a "Send mail as" alias (not a real Google login), the auth screen will show "Couldn't find your Google Account." To fix:
email in accounts.json to the backing Gmail addressemail back to the alias addressalias, not the email — so it will still load correctly.
chmod 600 tokens/*.json
Edit your Claude Desktop config at:
~/Library/Application Support/Claude/claude_desktop_config.json
Add a single gmail entry under mcpServers — one server handles all accounts:
{
"mcpServers": {
"gmail": {
"command": "/opt/homebrew/bin/npx",
"args": [
"tsx",
"/absolute/path/to/advanced-gmail-mcp/src/server.ts"
]
}
}
}
server.ts — relative paths break when Claude is invoked from different directories. Run pwd inside the repo folder to get the full path.account: "alias" in each tool call — no separate server entry per inbox.
Restart Claude Desktop. The gmail tools will appear in Claude's tool list.
If you're sending from a custom domain alias (e.g. support@yourdomain.com), outbound mail may land in spam. Fix: add Google's sending servers to your domain's SPF record.
dig TXT yourdomain.com +short
Look for a line starting with v=spf1.
Add include:_spf.google.com before the final ~all or -all:
# Before
v=spf1 include:_spf.mx.cloudflare.net ~all
# After
v=spf1 include:_spf.mx.cloudflare.net include:_spf.google.com ~all
Update this in your DNS provider (Cloudflare, Route53, etc.). Propagates in minutes on Cloudflare.
loudalo@gmail.com) don't need this — Google already authorises its own servers for gmail.com.
With Claude Desktop restarted, try these prompts:
List the 5 most recent unread emails in my personal inbox.
Send a test email from my work account to yourself at your personal address.
Subject: MCP test. Body: It works.
Search my support inbox for emails from this week that mention "invoice".
name field, sent mail should show Your Name <you@domain.com> in the recipient's inbox — not a garbled alias.
cat ~/Library/Logs/Claude/mcp*.log | tail -50
Look for [gmail] Server started and connected successfully. If absent, check the path in your config and that npm install completed cleanly.
Once the MCP is running, you can build a Claude skill that turns a markdown email body into a branded HTML newsletter and sends it to a contact group — all from a single prompt.
get_contact_group to fetch all members of a named Google Contacts group{{BODY_HTML}} placeholder where the converted content goesget_contact_group.~/.claude/skills/your-newsletter/SKILL.md) — instructs Claude to: collect subject + markdown body, fetch the contact group, convert markdown to HTML, inject into your template, preview, confirm, then send.Tell Claude in your skill instructions to convert using these patterns:
- Blank line between paragraphs → <p style="margin:0 0 20px 0;">...</p>
- **bold** → <strong>
- *italic* → <em>
- - list item → <ul><li>
- ## heading → <p><strong>heading</strong></p>
- [text](url) → <a href="url">text</a>
- --- → <hr>
get_contact_group tool uses Google's People API. Make sure it's enabled in your Google Cloud project (Step 1) and that your OAuth token includes the contacts.readonly scope. If you added this scope after your initial auth, delete your token file and re-run the auth flow for that account.