multi-gmail-mcp
Provides tools for searching threads, fetching thread content, creating drafts, listing drafts, managing labels (create, update, delete), and applying/removing labels on messages and threads across multiple Gmail accounts.
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., "@multi-gmail-mcplist drafts 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.
multi-gmail-mcp
A Model Context Protocol (MCP) server that gives an LLM read/label/draft access to multiple Gmail accounts from a single server.
The tool interface deliberately mirrors the standard Gmail MCP connector — same tool names, parameters, and semantics — with one addition: every tool accepts an optional account parameter selecting which mailbox to operate on (by alias or email). A list_accounts tool is added so the model can discover what's configured.
This server creates drafts only — it never sends email.
Tools
Tool | Purpose |
| Search threads with full Gmail query syntax; returns per-message metadata (no bodies). |
| Fetch a thread; |
| Build an RFC 2822 draft (text/html/attachments/replies). Never sends. |
| List drafts with subject/to/snippet. |
| List user-defined labels (id, name, colors). |
| Create a label (supports |
| Rename / recolor a label. |
| Delete a user label (refuses system labels). |
| Add/remove labels on a message. |
| Add/remove labels on a whole thread. |
| List configured accounts with email, default flag, and auth status. |
Every tool above (including list_accounts) accepts an optional account parameter.
The account parameter
A value can be an alias (
"work","personal") or the account's email address. Matching is case-insensitive.If omitted, the configured default account is used.
If there is no default and more than one account, the call fails with an error listing the available accounts.
An unknown account fails with an error listing valid accounts.
Related MCP server: Gmail Plugin MCP Server
Prerequisites
Node.js 18+
A Google Cloud project with the Gmail API enabled and an OAuth Desktop-app credential (see below).
1. Google Cloud setup (one-time)
Create / pick a project at https://console.cloud.google.com/.
Enable the Gmail API: APIs & Services → Library → "Gmail API" → Enable.
Configure the OAuth consent screen: APIs & Services → OAuth consent screen.
User type External (or Internal if you're in a Google Workspace org).
Fill in app name + support email.
Scopes: you can leave the scope list empty here; the server requests
https://www.googleapis.com/auth/gmail.modifyandhttps://www.googleapis.com/auth/gmail.labelsat auth time.Test users: while the app is in Testing, add every Gmail address you intend to connect as a test user. (Test-mode refresh tokens expire after 7 days — publish the app to Production to get long-lived tokens.)
Create credentials: APIs & Services → Credentials → Create Credentials → OAuth client ID.
Application type: Desktop app.
Download the JSON (it looks like
{ "installed": { "client_id": ..., "client_secret": ... } }).
Desktop-app clients are allowed to use a
http://localhost:<port>loopback redirect with a dynamic port, which is exactly what theauthflow uses — no redirect URIs to register.
2. Install
From npm (when published):
npm install -g multi-gmail-mcp # or just use `npx multi-gmail-mcp ...`From source:
git clone <this-repo> && cd multi-gmail-mcp
npm install # also builds via the `prepare` script
npm run build # (if needed) compile TypeScript to dist/3. Provide your OAuth client credentials
The server resolves your OAuth app credentials from the first of these that is present:
# Option A — environment variables
export GOOGLE_CLIENT_ID="xxxxxxxx.apps.googleusercontent.com"
export GOOGLE_CLIENT_SECRET="xxxxxxxx"
# Option B — point at the downloaded credentials.json
export GOOGLE_OAUTH_CREDENTIALS="/absolute/path/to/credentials.json"
# Option C — no env var needed: just drop the downloaded credentials.json into
# ~/.multi-gmail-mcp/credentials.json (or the current directory)
cp ~/Downloads/client_secret_*.json ~/.multi-gmail-mcp/credentials.jsonResolution order is A → B → C. The credentials.json is the file you downloaded
from Google Cloud Console; both the Desktop-app shape ({ "installed": {...} })
and the web shape ({ "web": {...} }) are accepted.
These are only the app credentials. Per-account refresh tokens are obtained in the next step.
4. Add Gmail accounts
Run the interactive auth flow once per account. It opens a browser, runs Google consent against a localhost loopback redirect, and stores the refresh token.
# alias the account however you like
npx multi-gmail-mcp auth work --default
npx multi-gmail-mcp auth personal--defaultmarks the account as the default used whenaccountis omitted. (The first account added becomes the default automatically.)Re-running
auth <alias>re-authorizes (e.g. after a revoked token) and keeps the same alias.
Token storage
Tokens are written to ~/.multi-gmail-mcp/accounts.json with permissions 0600:
{
"accounts": {
"work": { "email": "me@company.com", "refresh_token": "1//...", "default": true },
"personal": { "email": "me@gmail.com", "refresh_token": "1//..." }
}
}Access tokens are refreshed automatically and cached in memory per account. If a
refresh token is revoked or expires, tool calls for that account return an
actionable error telling you to re-run auth <alias>. (You can override the
config directory with MULTI_GMAIL_MCP_HOME.)
Verify everything is connected:
# from an MCP client, call list_accounts — or check status quickly:
npx multi-gmail-mcp # starts the server; use your MCP client to call list_accounts5. Configure your MCP client
Claude Desktop / Claude Code (mcpServers JSON)
Add to your MCP client config (e.g. claude_desktop_config.json, or a project .mcp.json):
{
"mcpServers": {
"multi-gmail": {
"command": "npx",
"args": ["-y", "multi-gmail-mcp"],
"env": {
"GOOGLE_CLIENT_ID": "xxxxxxxx.apps.googleusercontent.com",
"GOOGLE_CLIENT_SECRET": "xxxxxxxx"
}
}
}
}Running from a local checkout instead:
{
"mcpServers": {
"multi-gmail": {
"command": "node",
"args": ["/absolute/path/to/multi-gmail-mcp/dist/index.js"],
"env": { "GOOGLE_OAUTH_CREDENTIALS": "/absolute/path/to/credentials.json" }
}
}
}Claude Code CLI
claude mcp add multi-gmail \
--env GOOGLE_CLIENT_ID=xxxx.apps.googleusercontent.com \
--env GOOGLE_CLIENT_SECRET=xxxx \
-- npx -y multi-gmail-mcpThe
authstep must be run separately in a terminal (it opens a browser); the MCP host only runs the server.
Example invocations
Once connected, natural-language requests map to tool calls like:
Search the work inbox:
search_threadswith{ "query": "in:inbox is:unread newer_than:7d", "account": "work" }Read a thread from personal:
get_threadwith{ "threadId": "18c...", "messageFormat": "FULL_CONTENT", "account": "personal" }Draft a reply from personal:
create_draftwith{ "to": ["friend@example.com"], "body": "Sounds good!", "replyToMessageId": "18c...", "account": "personal" }Label a thread in work:
label_threadwith{ "threadId": "18c...", "labelIds": ["Label_42"], "account": "work" }List accounts:
list_accountswith{}.
Omitting account uses the default account.
Gmail query syntax (search_threads)
Supports the full Gmail operator set, e.g. from:, to:, cc:, subject:,
label:<id>, in:(inbox|sent|trash|spam|anywhere), is:(unread|starred|important),
has:attachment, filename:, after:/before:YYYY/MM/DD, newer_than:7d,
older_than:1y, larger:/smaller:, grouping with ()/{}, OR, and - to
exclude. Use label IDs (from list_labels), not display names, with label:.
Drafts are excluded by default; set includeTrash: true to also search Trash/Spam.
Development
npm run build # compile TypeScript -> dist/
npm test # vitest: alias resolution, MIME building, query passthrough
node scripts/smoke.mjs # connect over stdio; verify 13 tools + optional `account`Source layout:
File | Responsibility |
| MCP server, tool registry, CLI dispatcher ( |
| Config + token store, OAuth client construction, alias resolution. |
| Gmail REST wrappers, query building, body decoding, retry/error mapping. |
|
|
| RFC 2822 MIME construction for drafts. |
Behavior notes & limits
Drafts only. There is no send capability by design.
Bodies over ~50KB are truncated (flagged); raw attachment bytes are never returned by
get_thread— only metadata +attachmentId.Attachments in
create_draftmust total ≤ 25MB; link large files from Drive instead.Rate limits / 5xx are retried up to 3 times with exponential backoff; persistent failures return a clear error.
Auth errors (
401/invalid_grant) tell you exactly which account to re-auth.System labels can be used directly by ID (
INBOX,TRASH,SPAM,STARRED,UNREAD,IMPORTANT,DRAFT,SENT); they cannot be deleted or modified.
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.
Latest Blog Posts
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/joewhaley/multi-gmail-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server