gmail-multi-mcp-server
Provides tools for managing one or more Gmail mailboxes, including searching threads, reading messages, sending replies, managing drafts and labels, and applying actions like trash and spam.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gmail-multi-mcp-serverCheck my work inbox for anything from the lender, and draft the reply from my personal account."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
gmail-multi-mcp-server
An MCP server that connects Claude to several Gmail accounts at once, exposing the same tool
surface as the built-in Gmail connector. Every tool takes an extra account argument naming which
mailbox to act on — that is the only structural difference from the single-mailbox connector.
"Check my work inbox for anything from the lender, and draft the reply from my personal account."Why this exists
The built-in Gmail connector authorizes one mailbox. If you run separate accounts — work, personal, a company alias — you have to keep switching. This server holds credentials for as many Gmail accounts as you authorize and routes each call to the one you name.
Related MCP server: multiGmailMCP
Requirements
Node.js 20 or newer
A Google Cloud project with the Gmail API enabled and an OAuth client of type Desktop app
1. Get a Google OAuth client
Open the Google Cloud Console and select or create a project.
APIs & Services → Library → enable Gmail API.
APIs & Services → OAuth consent screen → configure it. While the app is in Testing, add every Gmail address you plan to connect under Test users.
APIs & Services → Credentials → Create credentials → OAuth client ID → application type Desktop app. Download the JSON.
Desktop-app clients allow loopback redirects on any port, which is what the add-account flow uses.
2. Install and build
git clone <this repo>
cd Gmail-MCP
npm install
npm run build3. Point the server at your OAuth client
Pick one:
# Option A — save the downloaded JSON where the server looks by default
mkdir -p ~/.gmail-mcp && cp ~/Downloads/client_secret_*.json ~/.gmail-mcp/credentials.json
# Option B — point at it explicitly
export GMAIL_MCP_CREDENTIALS=/path/to/client_secret.json
# Option C — pass the values directly
export GMAIL_MCP_CLIENT_ID=...apps.googleusercontent.com
export GMAIL_MCP_CLIENT_SECRET=...4. Authorize each mailbox
Run once per Gmail account:
node dist/index.js add-account --alias work
node dist/index.js add-account --alias personal
node dist/index.js list-accountsEach run prints a Google consent URL, waits on a local loopback port for the redirect, and stores the
resulting refresh token. On a headless machine, add --manual and paste the redirected URL back in.
Accounts added while the server is running are picked up automatically — no restart needed.
5. Connect it to Claude
Claude Code
claude mcp add gmail-multi -- node /absolute/path/to/Gmail-MCP/dist/index.jsClaude Desktop — add to claude_desktop_config.json:
{
"mcpServers": {
"gmail-multi": {
"command": "node",
"args": ["/absolute/path/to/Gmail-MCP/dist/index.js"],
"env": {
"GMAIL_MCP_CREDENTIALS": "/absolute/path/to/client_secret.json"
}
}
}
}Selecting an account
Every tool except list_accounts accepts account. It matches, in order:
the full email address —
mikael@example.comthe alias set at
add-accounttime —workthe local part before
@—mikaelany unambiguous prefix
account is optional when only one mailbox is configured, or when GMAIL_MCP_DEFAULT_ACCOUNT is set.
Otherwise it is required, and the error lists what is available.
IDs are per-mailbox. A message, thread, draft, or label ID from one account is meaningless in
another. A "not found" error usually means the wrong account was passed.
Tools
35 tools — the connector's surface plus two for multi-account.
Area | Tools |
Accounts |
|
Threads |
|
Messages |
|
Sending |
|
Drafts |
|
Labels |
|
Tool names deliberately match the Gmail connector's, so prompts and habits carry over. MCP clients namespace tools by server, so both can be enabled at the same time without collision.
Differences from the built-in connector
Everything below is additive — nothing the connector does behaves differently here.
accounton every tool, pluslist_accountsandget_profile.response_format(markdown|json) on every tool. Markdown is the default and stays compact; the full structured payload is returned asstructuredContenteither way.delete_draftandget_message_attachment, which the connector references but does not expose.replytakesquoteOriginal(defaultfalse) to append the original as a quoted block.forwardtakesincludeAttachments(defaulttrue); set it tofalseto skip large files.get_message_attachmenttakessavePathto write a file to disk instead of inlining base64.Responses are capped at 25,000 characters, shrinking paginated lists first and saying exactly what was dropped and how to get the rest.
Behavior worth knowing
search_threadsreturns a preview of each thread's oldest messages (~5), like the connector. Callget_threadbefore answering anything about recent or unread mail.Drafts are excluded from
search_threadsunless the query mentions drafts. Uselist_drafts.Labels are addressed by ID, not display name. Call
list_labelsfirst.DRAFTandSENTare read-only; addingTRASH/SPAMis routed to theapply_sensitive_*tools so destructive actions are always explicitly named.update_draftmerges fields, but attachments are replaced, not merged — the response reports how many were dropped.replysetsIn-Reply-ToandReferencesso clients thread correctly, and never addresses the reply back to the authorized mailbox itself.
Security
Refresh tokens live in
~/.gmail-mcp/accounts.json, written atomically with0600inside a0700directory. Anyone with read access to that file has full access to the mailboxes.The OAuth flow validates the
stateparameter and listens only on127.0.0.1.remove-accountdeletes the local token. To fully revoke, also remove the app at myaccount.google.com/permissions.The granted scopes allow reading, sending, and deleting mail.
send_message,reply, andforwarddeliver immediately — the tool descriptions instruct the model to prefercreate_draftwhen the user has not clearly asked for mail to go out.
Development
npm run build # compile TypeScript to dist/
npm test # build, then unit tests + stdio smoke test
npm run test:unit # MIME, reply addressing, parsing, truncation — no network
npm run test:smoke # boots the server, checks all 35 tools register
npm run inspect # open the MCP Inspector against the serversrc/
index.ts CLI entry point and server bootstrap
constants.ts scopes, limits, paths
types.ts normalized message/thread/draft shapes
auth/ token store, OAuth flow, account registry
schemas/common.ts shared Zod fields (account, formats, pagination, colors)
services/ Gmail parsing, MIME building, formatting, errors
tools/ tool registration by domainTroubleshooting
Symptom | Fix |
"No Gmail accounts are authorized yet" | Run |
"Google did not return a refresh token" | Revoke the app at myaccount.google.com/permissions, then re-run |
"Account 'x' is ambiguous" | Use the full email address |
403 on every call | The Gmail API is not enabled on the Cloud project, or the address is not a listed test user |
Not-found errors on valid IDs | The ID belongs to another mailbox — check |
License
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 Connectors
Connect any mailbox to Claude, ChatGPT & AI: read, send, reply, schedule & search emails.
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…
Give AI agents secure access to your email via private aliases with dedicated mailbox storage.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Related MCP Servers
- AlicenseBqualityBmaintenanceEnables AI assistants to manage multiple Gmail accounts simultaneously with built-in OAuth authentication, supporting email reading, sending, drafts, labels, and account management.60482MIT
- FlicenseAqualityBmaintenanceConnects AI assistants to multiple Gmail accounts simultaneously, enabling search, read, draft, send, and reply operations with per-account permission controls.54
- AlicenseNot gradedqualityCmaintenanceEnables searching and summarizing emails across multiple Gmail accounts simultaneously through Claude.1MIT
- AlicenseBqualityCmaintenanceEnables multi-account Gmail and Google Calendar access through MCP, allowing operations across multiple Google accounts with a single tool call.11MIT
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/Seventhdd/Gmail-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server