Gmail MCP Server
Provides tools for managing Gmail accounts, including sending, reading, replying, searching, labeling, moving, and deleting emails directly through the Gmail API.
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 MCP ServerList my unread emails in INBOX"
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 custom MCP server that gives Claude full Gmail control — send directly (no drafts), read, reply, search, label, and delete — over stdio for Claude Desktop and Cowork.
Folder Structure
gmail-mcp-server/
├── src/
│ ├── server.ts ← MCP entry point, registers all tools
│ ├── auth.ts ← OAuth2 flow + token refresh
│ ├── gmail-client.ts ← Gmail API wrapper
│ ├── templates.ts ← HTML email templates
│ ├── config.ts ← Env var loader
│ ├── logger.ts ← Structured stderr logger
│ └── tools/
│ ├── send-email.ts ← send_email
│ ├── send-bulk-email.ts ← send_bulk_email
│ ├── send-template-email.ts← send_template_email + list_templates
│ ├── list-emails.ts ← list_emails, get_email, reply_email
│ └── search-emails.ts ← search_emails, list_labels, add_label, move_email, delete_email
├── .env.example
├── claude_desktop_config.example.json
├── tsconfig.json
└── package.jsonRelated MCP server: gmail-mcp
Step 1 — Google Cloud Console Setup (One-time)
Create a new project (or use existing)
Enable the Gmail API:
APIs & Services → Library → search "Gmail API" → Enable
Create OAuth2 credentials:
APIs & Services → Credentials → Create Credentials → OAuth client ID
Application type: Desktop app
Name:
gmail-mcp-serverClick Create → Copy the Client ID and Client Secret
Configure OAuth consent screen:
OAuth consent screen → External → Add your Gmail as a test user
Add scopes:
gmail.send,gmail.readonly,gmail.modify
Step 2 — Project Setup
# 1. Install dependencies
npm install
# 2. Create your .env file
cp .env.example .env
# 3. Edit .env and fill in your credentials
# GOOGLE_CLIENT_ID=your_client_id
# GOOGLE_CLIENT_SECRET=your_client_secret
# SENDER_NAME=Your NameStep 3 — Authenticate (One-time)
npm run authThis will:
Print a Google auth URL
You open it in your browser, sign in, approve permissions
Paste the code back into the terminal
token.jsonis saved — never needs to be repeated
Step 4 — Build
npm run buildThis compiles TypeScript → dist/ folder.
Step 5 — Connect to Claude Desktop
Edit your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Add the gmail server block (replace paths with your actual absolute paths):
{
"mcpServers": {
"gmail": {
"command": "node",
"args": ["/Users/yourname/gmail-mcp-server/dist/server.js"],
"env": {
"GOOGLE_CLIENT_ID": "your_client_id",
"GOOGLE_CLIENT_SECRET": "your_client_secret",
"TOKEN_PATH": "/Users/yourname/gmail-mcp-server/token.json",
"SENDER_NAME": "Your Name",
"LOG_LEVEL": "info"
}
}
}
}Restart Claude Desktop. The gmail tools will appear in Claude's tool list.
Step 6 — Connect to Cowork
In Cowork, add a local MCP server with:
Command:
node /absolute/path/to/gmail-mcp-server/dist/server.jsEnvironment variables: same as above
Available Tools
Tool | What it does |
| Send directly to one or more recipients |
| Send same email to up to 50 recipients |
| Send HTML email using a template |
| See all templates and their variables |
| List inbox / any label with optional query |
| Read full email by message ID |
| Reply in-thread to an email |
| Full Gmail search query support |
| See all labels and their IDs |
| Add labels to an email |
| Move / archive / mark read |
| Move to Trash |
Example Prompts for Claude
Send an email to john@example.com with subject "Hello" and body "Let's connect!"
Search my emails for invoices from last month
Reply to message ID <id> saying "Thanks, I'll review this today"
Send the welcome template to sarah@example.com with name="Sarah" and company="Acme"
List my unread emails in INBOX
Move email <id> to archive (remove INBOX label)Adding New Templates
Edit src/templates.ts and add a new entry to the TEMPLATES object.
Then rebuild: npm run build
Development (no build needed)
npm run dev # runs via tsx directlyTroubleshooting
Problem | Fix |
| Check your |
| Run |
| Make sure Gmail API is enabled in Google Cloud Console |
Claude doesn't see tools | Restart Claude Desktop after editing config |
Server crashes silently | Check |
This server cannot be deployed
Maintenance
Related MCP Connectors
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
A MCP server for Gmail that lets you search, read, and draft emails and replies.
Connect any mailbox to Claude, ChatGPT & AI: read, send, reply, schedule & search emails.
Related MCP Servers
- AlicenseBqualityFmaintenanceMCP server that connects Claude with Gmail to read, send, delete, and manage messages and labels via the Google Gmail API.3MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that lets Claude read, search, send, label, and manage your Gmail through OAuth2.MIT
- AlicenseAqualityDmaintenanceA Gmail MCP server that enables Claude to send, search, and read emails using either Gmail API or SMTP/IMAP backend.322 PyPIMIT
- AlicenseNot gradedqualityDmaintenanceA secure MCP server that enables Claude to read, search, send, reply, forward, and manage Gmail messages and labels through natural language commands.62 npm1MIT