Enables email operations through POP3 and SMTP protocols, allowing users to connect to email servers (including Gmail), list messages, retrieve email content, delete messages, get message counts, and send emails with text/HTML formats, CC, and BCC support.
Runs as a Node.js application that provides email functionality through POP3 and SMTP protocols, leveraging Node.js runtime for secure email operations with environment-based configuration.
Available as an npm package that can be installed globally or run directly with npx, providing email client capabilities through a standardized package distribution system.
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., "@MCP Mail Servershow me all unread emails"
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.
MCP Mail Server
Language: English | 中文
A Model Context Protocol server for IMAP/SMTP email operations with Claude, Cursor, and other AI assistants.
Features
IMAP Operations: Search, read, and manage emails across mailboxes
SMTP Support: Send emails with HTML/text content and attachments
Attachment Management: View attachment metadata and save attachments to local files
Secure Configuration: Environment-based setup with TLS/SSL support
AI-Friendly: Natural language commands for email operations
Auto Connection Management: Automatic IMAP/SMTP connection handling
Multi-Mailbox Support: Access INBOX, Sent, and custom folders
Related MCP server: MCP Advanced Reasoning Server
Changelog
[1.2.1] - 2026-03-18
Fixed
Fixed search criteria (FROM/TO/SUBJECT/BODY/KEYWORD/SINCE) not using nested array format, causing errors on TO and other searches
Fixed
search()wrapping criteria in an extra array, breaking compound search conditionsFixed
deleteMessage()failing silently when the mailbox was opened in read-only modeFixed
getRecentMessages()misusing the IMAPRECENTflag; now fetches latest N messages by UIDFixed
getRecentMessages()/getUnseenMessages()relying on leftover mailbox state from previous operationsFixed
cleanReplySubject()only stripping oneRe:prefix layer, causing false negatives in unreplied detectionFixed email date stored as locale string causing inconsistent
new Date()parsing across platforms; changed to ISO 8601Fixed
ensureIMAPConnection()having no timeout while waiting for concurrent initializationFixed
saveSentMessage()always returningsentFolderSaved: trueeven when save failedFixed
handleGetMessages()/handleDeleteMessage()relying oncurrentBoxstate to locate messagesFixed
reply_to_emailwriting literal"undefined"into the body whentextis empty
Added
All search tools now support an
inboxOnlyparameter to restrict search to INBOX only
Improved
ensureSMTPConnection()now has concurrency guard with 30-second timeout, consistent with IMAPSent mailbox auto-detected via RFC 6154
\Sentspecial-use attribute with result caching, compatible with all mail providerssaveMessageToFolder()simplified; skips saving if no sent folder is foundSearch now uses
slice(-limit)to fetch the newest messages first, preventing empty results after date filteringHTML-escape applied to quoted content in reply emails to prevent XSS injection
For the full version history, see CHANGELOG.md.
Quick Start
Install:
npm install -g mcp-mail-serverConfigure environment variables (see Configuration)
Add to your MCP client configuration
Use natural language: "Show me unread emails from today"
Installation
Add to your claude_desktop_config.json:
{
"mcpServers": {
"mcp-mail-server": {
"command": "npx",
"args": ["-y", "mcp-mail-server"],
"env": {
"IMAP_HOST": "your-imap-server.com",
"IMAP_PORT": "993",
"IMAP_SECURE": "true",
"SMTP_HOST": "your-smtp-server.com",
"SMTP_PORT": "465",
"SMTP_SECURE": "true",
"EMAIL_USER": "your-email@domain.com",
"EMAIL_PASS": "your-password"
}
}
}
}Add to your Cursor MCP settings:
{
"mcpServers": {
"mcp-mail-server": {
"command": "npx",
"args": ["-y", "mcp-mail-server"],
"env": {
"IMAP_HOST": "your-imap-server.com",
"IMAP_PORT": "993",
"IMAP_SECURE": "true",
"SMTP_HOST": "your-smtp-server.com",
"SMTP_PORT": "465",
"SMTP_SECURE": "true",
"EMAIL_USER": "your-email@domain.com",
"EMAIL_PASS": "your-password"
}
}
}
}Add using the claude mcp add command:
claude mcp add mcp-mail-server \
-e IMAP_HOST=your-imap-server.com \
-e IMAP_PORT=993 \
-e IMAP_SECURE=true \
-e SMTP_HOST=your-smtp-server.com \
-e SMTP_PORT=465 \
-e SMTP_SECURE=true \
-e EMAIL_USER=your-email@domain.com \
-e EMAIL_PASS=your-password \
-- npx -y mcp-mail-serverOr manually add to .claude/settings.json:
{
"mcpServers": {
"mcp-mail-server": {
"command": "npx",
"args": ["-y", "mcp-mail-server"],
"env": {
"IMAP_HOST": "your-imap-server.com",
"IMAP_PORT": "993",
"IMAP_SECURE": "true",
"SMTP_HOST": "your-smtp-server.com",
"SMTP_PORT": "465",
"SMTP_SECURE": "true",
"EMAIL_USER": "your-email@domain.com",
"EMAIL_PASS": "your-password"
}
}
}
}Add to codex.json in your project root:
{
"mcpServers": {
"mcp-mail-server": {
"command": "npx",
"args": ["-y", "mcp-mail-server"],
"env": {
"IMAP_HOST": "your-imap-server.com",
"IMAP_PORT": "993",
"IMAP_SECURE": "true",
"SMTP_HOST": "your-smtp-server.com",
"SMTP_PORT": "465",
"SMTP_SECURE": "true",
"EMAIL_USER": "your-email@domain.com",
"EMAIL_PASS": "your-password"
}
}
}
}Other MCP clients can be configured similarly. The core configuration is:
{
"mcpServers": {
"mcp-mail-server": {
"command": "npx",
"args": ["-y", "mcp-mail-server"],
"env": {
"IMAP_HOST": "your-imap-server.com",
"IMAP_PORT": "993",
"IMAP_SECURE": "true",
"SMTP_HOST": "your-smtp-server.com",
"SMTP_PORT": "465",
"SMTP_SECURE": "true",
"EMAIL_USER": "your-email@domain.com",
"EMAIL_PASS": "your-password"
}
}
}
}Refer to your specific client's documentation for the appropriate configuration file location.
Available Tools
Tool | Description |
| Connect to both IMAP and SMTP servers |
| Check connection status and server info |
| Disconnect from all servers |
| Open specific mailbox/folder |
| List available mail folders |
| Get total message count in current mailbox |
| Get all unread emails |
| Get recent emails |
| Find emails from specific sender |
| Search by subject keywords |
| Find emails sent to specific recipient |
| Search message body content |
| Find emails since date |
| Find unread emails from specific sender |
| Find unreplied emails from specific sender |
| Search emails by keyword/flag |
| Search all messages with optional date range and limit |
| Retrieve email by UID |
| Retrieve multiple emails |
| Delete email by UID |
| Send email via SMTP (with optional attachments) |
| Reply to specific email |
| Get attachment metadata for an email |
| Download and save attachments to local files |
Connection Management
connect_all: No parameters required
get_connection_status: No parameters required
disconnect_all: No parameters required
Mailbox Operations
open_mailbox:
mailboxName(string, default: "INBOX"),readOnly(boolean)list_mailboxes: No parameters required
Search Operations
search_by_sender:
sender(string, email address),startDate(string, optional),endDate(string, optional)search_by_subject:
subject(string, keywords),startDate(string, optional),endDate(string, optional)search_by_recipient:
recipient(string, email address),startDate(string, optional),endDate(string, optional)search_by_body:
text(string, search text),startDate(string, optional),endDate(string, optional)search_since_date:
date(string, date format)search_unread_from_sender:
sender(string, email address),startDate(string, optional),endDate(string, optional)search_unreplied_from_sender:
sender(string, email address),startDate(string, optional),endDate(string, optional),limit(number, optional)search_with_keyword:
keyword(string, keyword),startDate(string, optional),endDate(string, optional)search_all_messages:
startDate(string, optional),endDate(string, optional),limit(number, optional, default: 50)
Message Operations
get_message_count: No parameters required
get_unseen_messages: No parameters required
get_recent_messages: No parameters required
get_message:
uid(number),markSeen(boolean, optional)get_messages:
uids(array),markSeen(boolean, optional)delete_message:
uid(number)
Email Sending
send_email:
to(string),subject(string),text(string, optional),html(string, optional),cc(string, optional),bcc(string, optional),attachments(string[], optional, absolute file paths)reply_to_email:
originalUid(number),text(string),html(string, optional),replyToAll(boolean, optional),includeOriginal(boolean, optional)
Attachment Operations
get_attachments:
uid(number) — Returns metadata: filename, contentType, size, indexsave_attachment:
uid(number),savePath(string, absolute path),attachmentIndex(number, optional, 0-based),returnBase64(boolean, optional, default: false)
Usage Examples
Use natural language commands with your AI assistant:
Basic Operations
"Connect to my email servers"
"Show me all unread emails"
"Search for emails from boss@company.com"
"Send an email to team@company.com about the meeting"
"Reply to email with UID 123"
Advanced Searches
"Find emails with 'urgent' in the subject from last week"
"Show me unreplied emails from boss@company.com"
"Search emails sent to team@company.com"
"Get all emails from the Sales folder"
"Show unread emails from boss@company.com"
"Show me all emails from the last 7 days"
"List all messages, limit to 20"
Email Management
"Delete the email with UID 123"
"Mark recent emails as read"
"List all my email folders"
Attachment Operations
"Show me the attachments of email UID 456"
"Save all attachments from email UID 456 to D:/Downloads"
"Download the first attachment from email UID 789"
"Send an email to team@company.com with attachment D:/report.pdf"
Configuration
Environment Variables
⚠️ All variables are required
Variable | Description | Example |
| IMAP server address |
|
| IMAP port number |
|
| Enable TLS |
|
| SMTP server address |
|
| SMTP port number |
|
| Enable SSL |
|
| Email username |
|
| Email password/app password |
|
Common Email Providers
IMAP_HOST=imap.gmail.com
IMAP_PORT=993
IMAP_SECURE=true
SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
SMTP_SECURE=true
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-passwordNote: Use App Passwords instead of your regular password.
IMAP_HOST=outlook.office365.com
IMAP_PORT=993
IMAP_SECURE=true
SMTP_HOST=smtp.office365.com
SMTP_PORT=587
SMTP_SECURE=true
EMAIL_USER=your-email@outlook.com
EMAIL_PASS=your-passwordSecurity Notes
Use App Passwords: Enable 2FA and use app-specific passwords when available
TLS/SSL Required: Always use secure connections (IMAP_SECURE=true, SMTP_SECURE=true)
Environment Variables: Never hardcode credentials in configuration files
Development
Clone the repository:
git clone https://github.com/yunfeizhu/mcp-mail-server.git cd mcp-mail-serverInstall dependencies:
npm installBuild the project:
npm run buildSet environment variables:
export IMAP_HOST=your-imap-server.com export IMAP_PORT=993 export IMAP_SECURE=true export SMTP_HOST=your-smtp-server.com export SMTP_PORT=465 export SMTP_SECURE=true export EMAIL_USER=your-email@domain.com export EMAIL_PASS=your-passwordRun the server:
npm start
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Package Information:
Package:
mcp-mail-serverNode.js: ≥18.0.0
Repository: GitHub
Issues: Report bugs
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.