Gmail MCP Server
Provides tools to read and write Gmail messages, manage labels, search emails, create drafts, and send emails.
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 MCP Serversearch for unread emails from 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 Server
A self-hostable Model Context Protocol server that exposes Gmail read and write tools. Connect it to Claude Code or Claude.ai to let Claude manage your email.
Prerequisites
Node.js 20+
A Google Cloud project with Gmail API enabled
OAuth 2.0 credentials (Desktop app type)
Related MCP server: gmail-mcp-server
Setup
1. Create Google Cloud Credentials
Go to the Google Cloud Console
Create a new project (or select an existing one)
Enable the Gmail API:
Navigate to APIs & Services > Library
Search for "Gmail API" and click Enable
Create OAuth credentials:
Navigate to APIs & Services > Credentials
Click Create Credentials > OAuth client ID
Select Desktop app as the application type
Name it (e.g., "Gmail MCP Server")
Click Create
Copy the Client ID and Client Secret
2. Configure Environment
cd gmail-mcp
cp .env.example .envEdit .env and fill in your credentials:
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret3. Install Dependencies
npm install4. Authenticate with Gmail
npm run authThis opens your browser for Google's OAuth consent screen. After granting access, the refresh token is automatically saved to .env.
Note: If you've previously authorized and need to re-authenticate, revoke access at Google Account Permissions first, then run
npm run authagain.
5. Start the Server
For Claude Code (stdio transport):
npm startFor Claude.ai (HTTP/SSE transport):
npm run start:httpConnecting to Claude Code
Add to your Claude Code MCP config (~/.claude.json or project .mcp.json):
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": ["tsx", "/absolute/path/to/gmail-mcp/src/index.ts"],
"env": {
"GOOGLE_CLIENT_ID": "your-client-id",
"GOOGLE_CLIENT_SECRET": "your-client-secret",
"GOOGLE_REFRESH_TOKEN": "your-refresh-token"
}
}
}
}Or if you prefer it to read from .env automatically, use a wrapper:
{
"mcpServers": {
"gmail": {
"command": "npm",
"args": ["start", "--prefix", "/absolute/path/to/gmail-mcp"]
}
}
}Connecting to Claude.ai
Start the HTTP server:
npm run start:httpThe server listens on
http://127.0.0.1:3000by default (changePORTin.env)If you need remote access, use a tunnel (e.g.,
ngrok http 3000or Cloudflare Tunnel)In Claude.ai, add the SSE endpoint URL as a custom MCP server:
http://localhost:3000/sse
Available Tools
Read Tools
Tool | Description |
| Search Gmail using Gmail search syntax. Params: |
| Read a full message with decoded body. Params: |
| Read all messages in a thread. Params: |
| List all Gmail labels (system + user) with IDs |
| Get email address and message/thread counts |
Write Tools (all marked MUTATING)
Tool | Description |
| Add/remove labels on a message. Params: |
| Add/remove labels on a thread. Params: |
| Archive a message (removes INBOX label). Params: |
| Archive a thread. Params: |
| Move to Trash (auto-deleted after 30 days). Params: |
| Create a new label. Params: |
| Send an email (or reply). Params: |
| Create a draft (or reply draft). Params: |
Gmail Search Syntax Examples
from:alice@example.com # Messages from a specific sender
to:bob@example.com # Messages to a specific recipient
subject:meeting # Subject contains "meeting"
has:attachment # Messages with attachments
is:unread # Unread messages
is:starred # Starred messages
label:INBOX # Messages in Inbox
label:Subscriptions # Messages with a user label
after:2025/01/01 # Messages after a date
before:2025/06/01 # Messages before a date
newer_than:7d # Messages from the last 7 days
from:alice subject:project # Combine multiple criteriaYour Labels
System labels: INBOX, SENT, DRAFT, TRASH, SPAM, STARRED, IMPORTANT, CATEGORY_PERSONAL, CATEGORY_SOCIAL, CATEGORY_PROMOTIONS, CATEGORY_UPDATES, CATEGORY_FORUMS
User labels: Subscriptions, My Finance, Receipts, My Travel, Taxes, DFL, Integral Function, PV 2025, Scotland, mini-split, eclips
Tip: Use
list_labelsto get the exact label IDs needed forlabel_messageandlabel_threadoperations.
Security Notes
The refresh token in
.envgrants access to your Gmail. Never commit.envto version control.The HTTP server binds to
127.0.0.1only (localhost). Use a tunnel for remote access.The
gmail.modifyscope is used — this allows reading, labeling, archiving, trashing, and sending, but does not allow permanent message deletion.
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
- 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/brentdemark/gmail-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server