gmail-mcp-imap
Provides email management for Gmail via IMAP/SMTP, including fetching emails by category, searching, reading, sending, replying, starring, deleting, labeling, and handling attachments.
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-imap Show me my primary 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-imap
A Gmail MCP (Model Context Protocol) server that provides email management capabilities through IMAP/SMTP. Works with Claude Desktop, Claude Code, and any MCP-compatible client.
Features
Gmail Categories: Fetch emails by Gmail's smart categories (Primary, Social, Promotions, Updates, Forums)
Full Email Management: Read, send, reply, star, delete, and label emails
Attachment Handling: List, download, and save attachments to disk
No Google API Required: Uses IMAP/SMTP directly with App Password authentication
Date Filtering: Filter emails by date range
Related MCP server: mail-mcp-oauth
Installation
npm install gmail-mcp-imapOr run directly with npx:
npx gmail-mcp-imapPrerequisites
A Gmail account
App Password (not your regular password):
Go to Google Account Security
Enable 2-Step Verification if not already enabled
Go to App Passwords (search for "App Passwords" in account settings)
Generate a new app password for "Mail"
Copy the 16-character password
Configuration
Environment Variables
Set these environment variables before running:
export GMAIL_EMAIL="your-email@gmail.com"
export GMAIL_APP_PASSWORD="your-16-char-app-password"Claude Desktop Configuration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": ["gmail-mcp-imap"],
"env": {
"GMAIL_EMAIL": "your-email@gmail.com",
"GMAIL_APP_PASSWORD": "your-app-password"
}
}
}
}Claude Code Configuration
Add to your .mcp.json:
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": ["gmail-mcp-imap"],
"env": {
"GMAIL_EMAIL": "your-email@gmail.com",
"GMAIL_APP_PASSWORD": "your-app-password"
}
}
}
}Available Tools
Category Tools
Tool | Description |
| Important conversations from real people |
| Social network notifications |
| Marketing emails, deals, offers |
| Receipts, bills, statements |
| Mailing lists, discussion groups |
Search & Read Tools
Tool | Description |
| Search emails by keywords |
| Get full email content by UID (pass |
| Get emails from a specific label/folder, with |
| List all Gmail labels/folders |
Action Tools
Tool | Description |
| Send a new email |
| Reply to an existing email |
| Mark email as read |
| Mark email as unread |
| Star or unstar an email |
| Move email to trash |
| Apply a label to an email |
Attachment Tools
Tool | Description |
| List attachments in an email |
| Download attachment as Base64 |
| Save attachment to disk |
Usage Examples
Once configured, you can ask Claude:
"Show me my primary emails from the last week"
"Search for emails from Amazon"
"Read the email with UID 12345"
"Send an email to john@example.com about the meeting"
"Download the PDF attachment from email 12345"
"Star the important emails about invoices"
Why IMAP/SMTP?
This MCP server uses IMAP/SMTP instead of the Google API because:
Simpler Setup: No OAuth consent screen or API credentials needed
App Passwords: More secure than storing your main password
No Rate Limits: Google API has strict quotas; IMAP doesn't
Works Offline: No dependency on Google's API servers
Privacy: Your emails aren't processed through additional Google services
Development
# Clone the repository
git clone https://github.com/suhail-ak-2/gmail-mcp-imap.git
cd gmail-mcp
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build for production
npm run build
# Run production build
npm startLicense
MIT
Author
Suhail (@ansuhail.ak@gmail.com)
Available Tools
19 toolsapply_labelB
Apply a label to an email
Inputs: uid (required), label (required), mailbox.
delete_emailA
Move an email to trash
Inputs: uid (required), mailbox.
download_attachmentA
Download an email attachment and return it as Base64 encoded data. Use this to save attachments locally.
Inputs: uid (required), filename (required), mailbox.
get_email_contentA
Get full content of a specific email by its UID
Inputs: uid (required), mailbox.
get_emails_by_labelA
Get emails from a specific label or folder (e.g., Github, Naukri jobs, Notes, [Gmail]/Sent Mail, [Gmail]/All Mail). Supports after/before date filters for paging. Results include a mailbox field - pass it as mailbox to get_email_content and other UID-based tools.
Inputs: label (required), after, limit, before.
get_forums_emailsA
Get emails from Forums category - mailing lists, discussion groups, online forums
Inputs: after, limit, before.
get_primary_emailsA
Get emails from Primary category - important conversations from real people
Inputs: after, limit, before.
get_promotions_emailsA
Get emails from Promotions category - marketing emails, deals, offers, newsletters
Inputs: after, limit, before.
get_social_emailsA
Get emails from Social category - notifications from social networks like Facebook, Twitter, LinkedIn
Inputs: after, limit, before.
get_updates_emailsA
Get emails from Updates category - transactional emails like receipts, bills, statements, order confirmations
Inputs: after, limit, before.
list_attachmentsA
List all attachments in an email (without downloading content)
Inputs: uid (required), mailbox.
list_labelsA
List all Gmail labels and folders
Inputs: no named parameters.
mark_as_readB
Mark an email as read
Inputs: uid (required), mailbox.
mark_as_unreadB
Mark an email as unread
Inputs: uid (required), mailbox.
reply_to_emailC
Reply to an existing email
Inputs: uid (required), body (required), html, mailbox.
save_attachmentC
Download an email attachment and save it to a specified file path
Inputs: uid (required), filename (required), savePath (required), mailbox.
search_emailsA
Search emails using keywords - searches in subject and sender
Inputs: query (required), limit.
send_emailB
Send a new email with optional attachments
Inputs: to (required), body (required), subject (required), cc, +3 more.
star_emailB
Star or unstar an email
Inputs: uid (required), mailbox, starred.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 19 tools
Most tools target a distinct resource and action, but the five get_*_emails category tools are very similar in shape and could be mistaken for one another without reading the category name closely. download_attachment and save_attachment also overlap as two ways to fetch the same attachment.
The dominant verb_noun pattern is clear and consistent, but there are minor deviations: get_emails_by_label uses a prepositional structure, get_email_content is singular while other retrievers are plural, and mark_as_read/mark_as_unread differ slightly from the simpler verb_noun style used elsewhere.
19 tools is on the heavy side for an MCP server and includes reducible duplication: five category getters could be one parameterized tool, and download_attachment/save_attachment serve nearly the same need with different output handling. The remaining tools are relevant, but the set feels padded.
The core Gmail lifecycle is covered: retrieve, search, read, send, reply, flag, star, delete, label, and attachments. Missing operations like remove_label, create_label, or draft management are notable but not critical gaps for a full Gmail surface.
Maintenance
Related MCP Connectors
Connect any IMAP/SMTP mailbox to Claude & ChatGPT: search, read, sort, draft. Sends only with OK.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Your mailboxes in ChatGPT and Claude: Gmail, iCloud, Fastmail, any IMAP. Passwords stay yours.
Connect any mailbox to Claude, ChatGPT & AI: read, send, reply, schedule & search emails.
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables Claude to interact with email accounts via IMAP and SMTP, providing tools for searching, reading, sending, and managing emails across multiple providers.401,009 npm135MIT
- AlicenseNot gradedqualityBmaintenanceEnables Claude to read, search, send, and manage email across multiple IMAP/SMTP accounts through OAuth 2.1-secured MCP tools.MIT
- AlicenseAqualityCmaintenanceEnables Claude to read, manage, and send email from any IMAP mailbox over plain IMAP and SMTP, including hosting-company and self-hosted mail servers. It provides tools for searching, reading, moving, deleting, and composing messages while built-in safety rules prevent unintended changes.12MIT
- AlicenseNot gradedqualityBmaintenanceEnables Claude and other MCP clients to search, read, and, when permitted, send email from regular IMAP/SMTP mailboxes, with read-first behavior and send previews requiring confirmation. It defaults to Titan Mail but supports any provider that accepts password or app-password IMAP/SMTP.MIT