MCP Mail Server is a Model Context Protocol server that enables AI assistants like Claude and Cursor to perform IMAP/SMTP email operations. It allows you to search, read, and manage emails, as well as send emails with content and attachments through natural language commands.
You can install the MCP Mail Server globally using npm:
npm install -g mcp-mail-server
Add to your claude_desktop_config.json
:
{
"mcpServers": {
"mcp-mail-server": {
"command": "npx",
"args": ["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": "[email protected]",
"EMAIL_PASS": "your-password"
}
}
}
}
Add to your Cursor MCP settings:
{
"mcpServers": {
"mcp-mail-server": {
"command": "npx",
"args": ["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": "[email protected]",
"EMAIL_PASS": "your-password"
}
}
}
}
For global installation:
{
"mcpServers": {
"mcp-mail-server": {
"command": "mcp-mail-server"
}
}
}
All of the following variables are required:
Variable | Description | Example |
---|---|---|
IMAP_HOST |
IMAP server address | imap.gmail.com |
IMAP_PORT |
IMAP port number | 993 |
IMAP_SECURE |
Enable TLS | true |
SMTP_HOST |
SMTP server address | smtp.gmail.com |
SMTP_PORT |
SMTP port number | 465 |
SMTP_SECURE |
Enable SSL | true |
EMAIL_USER |
Email username | [email protected] |
EMAIL_PASS |
Email password/app password | your-app-password |
IMAP_HOST=imap.gmail.com
IMAP_PORT=993
IMAP_SECURE=true
SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
SMTP_SECURE=true
[email protected]
EMAIL_PASS=your-app-password
Note: Use App Passwords instead of your regular password when using Gmail.
IMAP_HOST=outlook.office365.com
IMAP_PORT=993
IMAP_SECURE=true
SMTP_HOST=smtp.office365.com
SMTP_PORT=587
SMTP_SECURE=true
[email protected]
EMAIL_PASS=your-password
Tool | Description |
---|---|
connect_all |
Connect to both IMAP and SMTP servers |
get_connection_status |
Check connection status and server info |
disconnect_all |
Disconnect from all servers |
open_mailbox |
Open specific mailbox/folder |
list_mailboxes |
List available mail folders |
search_messages |
Search emails with IMAP criteria |
search_by_sender |
Find emails from specific sender |
search_by_subject |
Search by subject keywords |
search_by_body |
Search message content |
search_since_date |
Find emails since date |
search_unreplied_from_sender |
Find unreplied emails from specific sender |
search_larger_than |
Find emails by size |
get_message |
Retrieve email by UID |
get_messages |
Retrieve multiple emails |
delete_message |
Delete email by UID |
get_unseen_messages |
Get all unread emails |
get_recent_messages |
Get recent emails |
send_email |
Send email via SMTP |
reply_to_email |
Reply to specific email |
mailboxName
(string, default: "INBOX"), readOnly
(boolean)criteria
(array, IMAP search criteria)sender
(string, email address)subject
(string, keywords)text
(string, search text)date
(string, date format)sender
(string, email address), startDate
(string, optional), endDate
(string, optional)size
(number, bytes)uid
(number), markSeen
(boolean, optional)uids
(array), markSeen
(boolean, optional)uid
(number)to
(string), subject
(string), text
(string, optional), html
(string, optional), cc
(string, optional), bcc
(string, optional)originalUid
(number), text
(string), html
(string, optional), replyToAll
(boolean, optional), includeOriginal
(boolean, optional)Use natural language commands with your AI assistant:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mcp-mail-server" '{"command":"npx","args":["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":"[email protected]","EMAIL_PASS":"your-password"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mcp-mail-server": {
"command": "npx",
"args": [
"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": "[email protected]",
"EMAIL_PASS": "your-password"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mcp-mail-server": {
"command": "npx",
"args": [
"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": "[email protected]",
"EMAIL_PASS": "your-password"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect