gmail-mcp
Provides tools for interacting with Gmail, including searching threads with Gmail query syntax, reading full threads, listing labels, creating drafts and sending messages, replying in-thread, modifying labels, archiving, marking read, starring, and trashing threads.
Click on "Deploy 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-mcpsearch my unread emails from the last week"
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-mcp
A remote Gmail MCP server you host yourself and add to Claude as a custom connector. Once it's connected, the connector works everywhere you use Claude: claude.ai, desktop, mobile, and Claude Code.
Google sign-in when you connect. Pick a Gmail account when you add the connector. One deployment can serve several accounts; add one connector per inbox.
No database. Every token is encrypted with your
SECRETand contains everything the server needs to read it back.Allowlist. Only the Google accounts in
ALLOWED_EMAILScan connect.
Tools
Tool | |
| Gmail query syntax ( |
| Full thread as plain text |
| |
| Plain text; pass |
| Archive, mark read, star, label (names or IDs) |
| Recoverable for 30 days |
Scope is gmail.modify: read, send, label, trash. It can't permanently delete anything.
Related MCP server: Gmail MCP Server
Deploy
1. Railway
New project → Deploy from GitHub repo → your fork. Then Settings → Networking → Generate Domain. Note the domain, e.g. gmail-mcp-production.up.railway.app.
Any Node host works. Set BASE_URL if you're not on Railway.
2. Google OAuth client
Create a project and enable the Gmail API.
Google Auth Platform → Branding: fill in an app name and your email.
Audience: External. Then Publish app. If you leave it in Testing, Google expires refresh tokens after 7 days and you'll have to reconnect weekly. An unverified app in production works fine for personal use; you'll click through an "unverified app" warning once.
Clients → Create client → Web application. Add this authorized redirect URI:
https://<your-domain>/oauth/google/callback
3. Environment
Variable | |
| From step 2 |
|
|
|
|
| Optional on Railway |
4. Connect
Go to claude.ai → Settings → Connectors → Add custom connector, use https://<your-domain>/mcp, then sign in with Google.
How auth works
Claude ──/authorize──▶ server ──▶ Google sign-in ──▶ /oauth/google/callback
◀──code──────── server ◀───────────────────────┘
Claude ──/token──────▶ server (access token wraps the Google refresh token)
Claude ──/mcp────────▶ server ──▶ Gmail APIThe server acts as an OAuth 2.1 authorization server, with dynamic client registration and PKCE, through the MCP SDK's mcpAuthRouter. Google handles the actual sign-in. Client IDs, auth codes, and tokens are AES-256-GCM-encrypted payloads, so nothing is stored on the server.
Trade-offs of storing nothing:
No server-side revocation. To cut off access, remove the email from
ALLOWED_EMAILS(checked on every hourly token refresh), rotateSECRET, or revoke the app at myaccount.google.com/permissions.Auth codes aren't single-use within their 10-minute window. PKCE still ties each code to the client that requested it.
Develop
cp .env.example .env # add http://localhost:3000/oauth/google/callback to your Google client
pnpm install
pnpm dev
pnpm check # tsc + biomeLicense
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…
Connect any mailbox to Claude, ChatGPT & AI: read, send, reply, schedule & search emails.
Manage Gmail messages, threads, labels, drafts, and settings from your workflows. Send and organiz…
Your mailboxes in ChatGPT and Claude: Gmail, iCloud, Fastmail, any IMAP. Passwords stay yours.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables reading, sending, searching, and managing Gmail through Claude using the official Google Gmail API.144 npm3MIT
- AlicenseNot gradedqualityCmaintenanceEnables Claude to read, search, send, label, and trash emails in any Gmail account via Google's Gmail API, using OAuth2 authentication with automatic token refresh.67 npmMIT
- 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.2,341 npmMIT