gmail-mcp
Provides tools for reading and writing a Gmail mailbox, including searching messages, managing drafts and labels, archiving, trashing, and sending email.
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-mcpcreate a draft reply to the email from Sarah about the project deadline"
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 second account MCP server
Read and write one Gmail mailbox from Claude.ai and Claude Code. Claude.ai's own Gmail connector handles a single account, so this exists for the second one: run an instance per mailbox and each connector reaches exactly the address it was given.
One mailbox per instance
Which account an instance serves comes from GMAIL_CREDENTIALS_DIR, and nothing else is reachable from that process. That separation is the point rather than a limitation: a draft cannot land in the wrong mailbox when the server only ever holds one set of credentials.
Related MCP server: Gmail MCP Local Server
Tools
Reading
Tool | What you get |
| Which mailbox this instance serves, and its counts |
| Search with Gmail's own query syntax |
| One message, with its body |
| A whole conversation, oldest first |
| Filenames, types and sizes on a message |
| Every label with its id |
| Drafts waiting in the mailbox |
Writing
Tool | What it does |
| Write a draft, optionally threaded as a reply |
| Replace a draft's contents |
| Discard a draft |
| Add or remove labels on a message |
| Take a message out of the inbox |
| Mark read or unread |
| Move to trash and back |
| Manage labels |
| Send an existing draft |
| Compose and send in one step |
The two send tools are marked destructive and say so in their descriptions: they reach other people and cannot be undone. The safe shape is gmail_create_draft, read it, then gmail_send_draft once a person has approved the text.
Searching
gmail_search takes the same operators as the Gmail search box:
is:unread from:client.com
subject:invoice has:attachment newer_than:7d
label:important -in:trashIt returns headers and a snippet per message rather than bodies, so a wide search stays small. Follow up with gmail_get_message or gmail_get_thread.
How it fits together
Claude.ai / Claude Code
| HTTPS
Cloudflare Tunnel, or any proxy that gives you HTTPS
|
nginx 127.0.0.1:8461
|
auth-server.js :8462 handles the login and the tokens
|
gmail-mcp :8460 the server itself, local only
|
gmail.googleapis.comThe MCP has no login of its own and refuses to listen on anything but the local machine, so everything reaching it has already passed the login.
Setup
You need a Google Cloud OAuth client with the Gmail API enabled, and a refresh token for the mailbox. The credentials directory holds two files:
credentials.json {"refresh_token": "..."}
gcp-oauth.keys.json the downloaded OAuth clientgmail.modify is the scope to grant. It covers reading, labelling, drafting and sending; drop to gmail.readonly plus gmail.compose if you would rather the credentials themselves could not send.
git clone https://github.com/rollecode/gmail-second-account-mcp.git
cd gmail-second-account-mcp
uv venv && uv pip install -e .
npm install --omit=dev
CONFIG_DIR=~/.config/gmail-mcp node set-password.js 'your-password-here'
openssl rand -hex 32 > ~/.config/gmail-mcp/token
chmod 600 ~/.config/gmail-mcp/tokenFill in YOUR_USER, the hostname and the credentials directory in systemd/*.service and nginx/gmail-mcp.conf, then:
sudo cp systemd/*.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now gmail-mcp gmail-mcp-auth
sudo cp nginx/gmail-mcp.conf /etc/nginx/sites-enabled/gmail-mcp
sudo nginx -t && sudo systemctl reload nginxPoint a tunnel or an HTTPS proxy at 127.0.0.1:8461. OAuth needs HTTPS.
Check from outside: discovery returns metadata, and /mcp without a token must return 401.
curl https://your-host/.well-known/oauth-authorization-server
curl -o /dev/null -w '%{http_code}\n' -X POST https://your-host/mcpConnecting
Claude.ai: Settings, Connectors, Add custom connector, https://your-host/mcp, client ID and secret blank.
Claude Code:
claude mcp add --transport http gmail https://your-host/mcp \
--header "Authorization: Bearer $(cat ~/.config/gmail-mcp/token)" --scope userLocally over stdio, with no server at all:
GMAIL_CREDENTIALS_DIR=/path/to/creds claude mcp add gmail -- /path/to/.venv/bin/gmail-mcpSettings
Variable | What it is for |
| Directory holding |
| Name for the mailbox, shown in the server's instructions |
| Public address, used to advertise the icon |
| Public origin of the login server |
| Login server port, 8462 by default |
| MCP server URL, |
| Where the password, token and OAuth database live |
Access tokens are refreshed in memory as they expire; only the refresh token is read from disk.
Credits
The login layer comes from rollecode/obsidian-remote-mcp.
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 Servers
- AlicenseNot gradedqualityFmaintenanceEnables reading, sending, searching, and managing Gmail through Claude using the official Google Gmail API.1653MIT
- FlicenseNot gradedqualityDmaintenanceProvides Claude with Gmail capabilities including sending emails, managing drafts, and searching messages.
- AlicenseNot gradedqualityDmaintenanceEnables Claude to read, search, send, and manage Gmail messages and threads through natural language.205MIT
- AlicenseNot gradedqualityDmaintenanceEnables Gmail integration with Claude Code for reading, sending, searching emails, and managing labels through natural language.205MIT
Related MCP Connectors
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…
Manage Gmail messages, threads, labels, drafts, and settings from your workflows. Send and organiz…
Read, search, send, organize, draft and schedule email across your inboxes from any MCP client.
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/rollecode/gmail-second-account-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server