Gmail MCP Server
Provides tools for sending emails, reading and managing inbox, labels, archiving, deleting, and downloading attachments via 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 Server Send an email to the team about tomorrow's meeting"
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
Overview
Gmail MCP Server bridges AI assistants and Gmail. Instead of switching tabs or writing scripts, you ask your AI client to send an email, list unread messages, archive inbox clutter, or fill a reusable template — and the server handles the rest over stdio.
Capability | How it works |
Send mail | Gmail SMTP via Nodemailer + App Password |
Read & manage | Gmail API v1 via OAuth2 refresh token |
Templates | Mustache variables in local |
Transport | MCP over stdio (no HTTP server required) |
Related MCP server: Gmail AutoAuth MCP Server
Features
Send custom emails — plain text or HTML
Introduction emails — one-shot professional outreach
Template engine — Mustache-powered reusable email bodies
Inbox tools — list labels, list unread (with Gmail search queries), fetch by ID
Mailbox actions — archive (remove from Inbox) or move to trash
Config check — verify SMTP credentials before sending
Secure by design — secrets stay in
.env; never committed to git
Architecture
+------------------+ stdio / JSON-RPC +---------------------+
| MCP Client | <------------------------------> | Gmail MCP Server |
| Claude Desktop | | index.js |
| Cursor, etc. | +----------+----------+
+------------------+ |
+----------------------------+----------------------------+
| | |
v v v
+---------------+ +---------------+ +---------------+
| Nodemailer | | Gmail API | | Templates |
| SMTP send | | OAuth2 read | | Mustache |
+---------------+ +---------------+ +---------------+Tech Stack
Layer | Technology |
Runtime | Node.js (ES Modules) |
Protocol | Model Context Protocol over stdio |
MCP SDK |
|
Sending |
|
Reading / managing |
|
Auth | Gmail App Password (send) · OAuth2 refresh token (read/manage) |
Config |
|
Templating |
|
Project Structure
gmail-mcp-server/
├── index.js # MCP server entry — tool registration & handlers
├── lib/
│ └── gmail.js # OAuth2 client + Gmail API helpers
├── templates/
│ ├── introduction.txt # Intro email template
│ └── follow_up.txt # Follow-up email template
├── .env.example # Environment variable template
├── package.json
└── README.mdAvailable Tools
Tool | Description | Auth |
| Send a custom email (text or HTML) | App Password |
| Send a professional introduction | App Password |
| Send from a Mustache template | App Password |
| Validate SMTP credentials | App Password |
| List templates in | None |
| List Gmail labels | OAuth2 |
| List unread mail (optional query) | OAuth2 |
| Fetch a full message by ID | OAuth2 |
| Remove a message from Inbox | OAuth2 |
| Move a message to Trash | OAuth2 |
| List attachments on a message | OAuth2 |
| Download an attachment to disk | OAuth2 |
Getting Started
Prerequisites
Node.js 18 or later
A Gmail account
An MCP client (e.g. Claude Desktop)
1. Clone & install
git clone https://github.com/Abhitkumar89/Gmail_MCP_Tool.git
cd Gmail_MCP_Tool
npm install2. Configure environment
cp .env.example .envEdit .env with your values:
# Required for sending
GMAIL_USER=your_email@gmail.com
GMAIL_APP_PASSWORD=your_16_char_app_password
# Required for reading / archiving / deleting
GMAIL_CLIENT_ID=your_client_id
GMAIL_CLIENT_SECRET=your_client_secret
GMAIL_REDIRECT_URI=https://developers.google.com/oauthplayground
GMAIL_REFRESH_TOKEN=your_refresh_tokenEnable 2-Step Verification
Open App passwords → create one for Mail
Paste the 16-character password into
GMAIL_APP_PASSWORD
Create a project in Google Cloud Console
Enable the Gmail API
Create OAuth 2.0 Client credentials
Use OAuth 2.0 Playground (or your own flow) to obtain a refresh token
Recommended scope:
https://www.googleapis.com/auth/gmail.modifyFill in
GMAIL_CLIENT_ID,GMAIL_CLIENT_SECRET,GMAIL_REDIRECT_URI, andGMAIL_REFRESH_TOKEN
Note: Sending uses App Password (SMTP). Inbox tools require OAuth2. For the full toolset, configure both.
3. Run the server
npm startYou should see:
Gmail MCP Server running on stdioThe process waits on stdin — that is expected for MCP servers.
MCP Client Configuration
Add the server to your Claude Desktop config (or any MCP-compatible client).
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"gmail": {
"command": "node",
"args": ["/absolute/path/to/gmail-mcp-server/index.js"],
"cwd": "/absolute/path/to/gmail-mcp-server"
}
}
}Set
cwdto the project root so.envandtemplates/resolve correctly. Restart the client after saving.
Usage Examples
Once connected, try prompts like:
Send an introduction email to someone@example.com
Check if my Gmail configuration is working
Send an email to someone@example.com with subject "Hello" and body "Test message"
List unread emails
List unread emails with query "from:recruiter"
Get email with id 18c5b9b1a2e3a4b5
Archive email with id 18c5b9b1a2e3a4b5
Delete email with id 18c5b9b1a2e3a4b5
List email templates
Send a template email to user@example.com using template introduction
with variables {"name":"Alex","recipientName":"Jordan","customMessage":"Great meeting you."}Email Templates
Templates live in templates/ as .txt files. An optional first line sets the subject:
Subject: Introduction - {{name}}
Dear {{recipientName}},
I hope this message finds you well. I'm {{name}}, reaching out to introduce myself...
{{customMessage}}
Best regards,
{{name}}Pass variables through the send_template_email tool; Mustache replaces {{placeholders}}.
Security
Never commit
.env— it is listed in.gitignoreUse App Passwords and OAuth refresh tokens only on trusted machines
Prefer least-privilege Gmail scopes where possible
delete_emailmoves messages to Trash (recoverable), not permanent delete
Scripts
Command | Description |
| Start the MCP server |
| Start with Node |
License
MIT — feel free to use and adapt for your own MCP projects.
Available Tools
12 toolsarchive_emailA
Archive (remove from INBOX) an email by ID (requires OAuth2 config)
Inputs: id (required).
check_gmail_configB
Check if Gmail configuration is properly set up
Inputs: no named parameters.
delete_emailB
Move an email to trash by ID (requires OAuth2 config)
Inputs: id (required).
download_attachmentC
Download an email attachment to disk (requires OAuth2 config)
Inputs: messageId (required), attachmentId (required), filename, savePath.
get_emailB
Retrieve a full email by ID (requires OAuth2 config)
Inputs: id (required).
list_attachmentsB
List attachments on an email by ID (requires OAuth2 config)
Inputs: id (required).
list_email_templatesB
List available email templates
Inputs: no named parameters.
list_labelsA
List Gmail labels (requires OAuth2 config)
Inputs: no named parameters.
list_unread_emailsB
List recent unread emails (requires OAuth2 config)
Inputs: query, maxResults.
send_emailC
Send an email using Gmail
Inputs: to (required), body (required), subject (required), html, +1 more.
send_introduction_emailC
Send a professional introduction email
Inputs: to (required), name, customMessage.
send_template_emailC
Send an email using a stored template with variables
Inputs: to (required), template (required), variables, fallbackSubject.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Send_email, send_template_email, and send_introduction_email all perform the same core action of sending mail, with the introduction variant being just a specialization of send_email, so an agent could easily misselect. The read/label/attachment tools are reasonably distinct, but the send cluster blurs boundaries.
Every tool follows a snake_case verb_noun pattern (list_email_templates, get_email, archive_email, download_attachment), including the send_* family. Minor noun-order variation in send_template_email doesn't break the convention.
12 tools is well within the ideal 3-15 range and each maps to a plausible Gmail operation. The set is scoped tightly to sending, reading, labels, and attachments.
Core send/list/get/archive/delete flows exist, but there is no general email search or list-all (only unread), no reply/forward/draft tools, and list_labels has no companion to add/remove or modify labels. These gaps will cause agent dead ends for common inbox workflows.
Maintenance
Related MCP Connectors
Email inboxes for AI agents: read, search, send, reply, calendar invites. Hosted MCP with OAuth.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Email inboxes for AI agents: send, receive, reply, search, and manage threaded email over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables AI assistants to manage Gmail through natural language interactions with features like sending emails, searching, and label management.MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server enabling AI assistants to manage Gmail through natural language, including sending, reading, searching, labeling, and handling attachments with auto authentication.1MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server for Gmail that allows AI assistants to read, search, compose drafts, send emails, and manage labels with attachment support.MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Gmail through a standardized MCP server interface, allowing for natural language email management and automation.-