Gmail MCP
Provides tools to search, read messages and threads, send messages, create drafts, list labels, and modify labels across one or more Gmail inboxes via the Gmail API.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Gmail MCP — multi-inbox connector for Claude
A small, self-hosted remote MCP server that lets Claude work with any Gmail inbox you choose, including extra inboxes beyond the one Claude's built-in Gmail connector is signed into.
Free to use, modify and share under the MIT license.
Tools it gives Claude: gmail_search_messages, gmail_get_message,
gmail_get_thread, gmail_send_message, gmail_create_draft,
gmail_list_labels, gmail_modify_labels.
Why use it
Connect a second, third or tenth inbox (work, side business, shared support inbox).
One deployment serves several inboxes, each with its own connector URL.
Runs as Vercel serverless functions: no server to keep alive, free tier is enough.
You host it, so your mail and tokens never pass through anyone else's service.
What you need
A Google account with access to Google Cloud Console (free)
A Vercel account (free) and a GitHub account
Node.js 18+ on your computer (only for the one-time token step)
A Claude plan that supports custom connectors
Setup takes about 20 minutes.
Related MCP server: Surfski
1. Create a Google OAuth client
In Google Cloud Console, create a new project.
APIs & Services → Library → enable the Gmail API.
Google Auth Platform → Get started (OAuth consent screen):
Audience: External. Fill in an app name and your contact email.
Audience → Test users → Add users: add every Gmail address you plan to connect. (While the app is in "Testing", only these users can sign in.)
Data Access → Add or remove scopes: add
gmail.readonly,gmail.send,gmail.compose,gmail.modify,gmail.labels.
Clients → Create client → type Web application.
Authorized redirect URI:
http://localhost:53682/oauth2callbackCopy the Client ID and Client secret.
Testing-mode tokens expire after 7 days. For a long-lived setup, either publish the app (Audience → Publish app; Google may ask for verification because Gmail scopes are sensitive), or plan to re-run step 2 weekly.
2. Get a refresh token for your inbox
git clone https://github.com/<you>/gmail-mcp-multi-inbox.git
cd gmail-mcp-multi-inbox
npm install
cp .env.example .envPut your GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET in .env, then:
npm run get-tokenOpen the printed URL, sign in with the inbox you want Claude to use, and approve.
The terminal prints GMAIL_REFRESH_TOKEN=.... Put it in .env, and also set:
GMAIL_ACCOUNT_EMAIL=you@example.com
MCP_SHARED_SECRET=<output of: openssl rand -hex 32>MCP_SHARED_SECRET is the password for your connector. Keep it long and random.
3. Deploy to Vercel
Push your copy to your own private GitHub repo (or use Vercel's CLI).
Vercel → Add New → Project → import that repo. Leave Framework Preset as Other (the included
vercel.jsonsets this) and leave build settings empty → Deploy.Settings → Environment Variables: add
GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET,GMAIL_REFRESH_TOKEN,GMAIL_ACCOUNT_EMAIL,MCP_SHARED_SECRET.Deployments → Redeploy (env vars apply only to new deploys).
Open
https://<your-project>.vercel.app/api/health. You should see{"ok":true,"inboxes":1}.
4. Add it to Claude
Claude → Settings → Connectors → Add custom connector.
URL:
https://<your-project>.vercel.app/api/mcp/<MCP_SHARED_SECRET>Leave authentication empty. The secret in the URL is the authentication.
Save. The seven Gmail tools should appear.
Treat that URL like a password: anyone who has it can read and send mail as that inbox.
Adding more inboxes (no terminal needed)
Google Cloud → Clients → your client → add redirect URI
https://<your-project>.vercel.app/api/oauth-callback→ Save.Open
https://<your-project>.vercel.app/api/connectand sign in with the new inbox. The page shows two variables, for exampleGMAIL_REFRESH_TOKEN_SUPPORTandGMAIL_ACCOUNT_EMAIL_SUPPORT.Add both in Vercel → Environment Variables → redeploy.
Add another custom connector in Claude using your URL plus
--<key>:https://<your-project>.vercel.app/api/mcp/<MCP_SHARED_SECRET>--support
For safety, /api/connect only accepts addresses on the same domain as
GMAIL_ACCOUNT_EMAIL. If your first inbox is @gmail.com, any other @gmail.com
address is accepted. To allow mixed domains (say a personal Gmail plus a work
address), add the env var ALLOW_ANY_GMAIL=true.
Every inbox you add must also be listed as a test user in Google Cloud (Audience → Test users) while your OAuth app is in Testing mode.
Each inbox shows up in Claude as its own connector with the same seven tools, and the tool descriptions name the inbox, so Claude knows which one it's using.
Local testing
npm startRuns on http://localhost:3000/mcp and expects the header
Authorization: Bearer <MCP_SHARED_SECRET>. Uses the same tool code as the Vercel functions.
How it works
File | Purpose |
| The MCP tools and Gmail API calls |
| Maps |
| The connector endpoint (secret checked in the path) |
| Browser sign-in for extra inboxes |
| Liveness check (shows inbox count only) |
| Optional local test server ( |
| One-time local token script |
The secret sits in the URL path rather than a header because Claude treats a 401
from a custom connector as "needs OAuth" and tries to register an OAuth client.
A wrong secret returns 404 instead, so no OAuth handshake is attempted.
Each request builds a fresh, stateless MCP session, which suits serverless functions.
Security notes
Never commit
.env. It is already in.gitignore.Each refresh token grants full Gmail access for that inbox. Revoke access any time at myaccount.google.com/permissions.
Want read-only? Remove the
send,composeandmodifyscopes inauth/get-refresh-token.jsandlib/oauth-web.js, and delete the matching tools inlib/gmail-mcp.js.Rotate
MCP_SHARED_SECRETif the connector URL is ever exposed.
Troubleshooting
No refresh token returned: the account already granted access. Remove the app at myaccount.google.com/permissions and run the sign-in again.
invalid_granterrors after a week: your OAuth app is in Testing mode. See the note in step 1./api/healthreturns 404 after deploy: Vercel detected the project as an Express or Node server. In Project → Settings → Build and Deployment, set Framework Preset to Other, then redeploy. Don't add aserver.js,index.jsorapp.jsat the repo root.Connector shows no tools: check
/api/health, confirm every env var is set, and redeploy.
Contributing
Issues and pull requests are welcome, whether that's new tools (attachments, filters, batch actions), other hosts, or docs fixes.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Multiple Google accounts (Gmail, Calendar, Drive, Contacts, Tasks) in one Claude connector.
Multiple Google accounts (Gmail, Calendar, Drive, Contacts, Tasks) in one Claude connector.
Connect any IMAP/SMTP mailbox to Claude & ChatGPT: search, read, sort, draft. Sends only with OK.
Connect any mailbox to Claude, ChatGPT & AI: read, send, reply, schedule & search emails.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables Claude to query and read across multiple Gmail accounts simultaneously through one connector, searching with Gmail syntax, fetching full threads, and creating drafts without ever sending. It also supports scheduled routines that scan all accounts for deadlines and notify the owner via WhatsApp webhooks.MIT
- AlicenseNot gradedqualityBmaintenanceEnables Claude to search, read, and draft email across multiple linked Gmail and Google Workspace mailboxes per user, with per-user isolation and Google sign-in. Self-hosted, drafts-only today, so users send from Gmail themselves.MIT
- AlicenseNot gradedqualityNot gradedmaintenanceConnects Gmail to Claude and other MCP clients so users can search and read mail, send and reply-all with quoted history, forward messages, handle attachments and inline images, and manage drafts, labels, and threads across multiple Google accounts simultaneously from a self-hosted remote server.MIT
- AlicenseNot gradedqualityBmaintenanceEnables Claude to read, search, send, draft, and organize email across multiple independently authenticated Gmail accounts through one local MCP connection. It supports account aliases, per-account default From addresses, dry-run sends, and draft-only replies for safer multi-account email management.MIT