mcp-email-client
An MCP server for sending and receiving emails via IMAP/SMTP, with support for attachments, replies, and display names.
README
MCP Email Client
A Model Context Protocol (MCP) server for sending and receiving emails, supporting IMAP/SMTP, with display name, reply, robust error handling, and full attachment support.
Features
- Send emails (with display name and attachment support)
- List inbox/sent emails (brief info, attachment count)
- Read email details by UID (auto-save and list attachments)
- Reply to emails (auto set headers, display name, attachments)
- Environment variable based configuration
- Robust error handling and IMAP/SMTP compatibility
Example JSON config for MCP/Claude/Inspector
This format is suitable for use with Claude Desktop, MCP Inspector, or any MCP client that supports multi-server JSON configuration:
{
"mcpServers": {
"mcp-email-client": {
"command": "uvx",
"args": [
"mcp-email-client"
],
"env": {
"MAIL_USER_NAME": "your@email.com",
"MAIL_PASS_WORD": "yourpassword",
"MAIL_SMTP_ADDR": "smtp.example.com:465",
"MAIL_IMAP_ADDR": "imap.example.com:993",
"MAIL_FROM_NAME": "Your Name",
"MAIL_FROM_ADDR": "your@email.com",
"MAIL_SAVE_PATH": "/absolute/path/to/attachments"
}
}
}
}
- You can add multiple servers under
mcpServers. - This config can be loaded directly by Claude Desktop, MCP Inspector, or compatible tools.
Environment Variables
| Name | Description | Example |
|---|---|---|
| MAIL_USER_NAME | Email account (login username) | user@example.com |
| MAIL_PASS_WORD | Email account password/app token | yourpassword |
| MAIL_SMTP_ADDR | SMTP host:port | smtp.example.com:465 |
| MAIL_IMAP_ADDR | IMAP host:port | imap.example.com:993 |
| MAIL_FROM_ADDR | (Optional) From email address | user@example.com |
| MAIL_FROM_NAME | (Optional) From display name | Alice |
| MAIL_SAVE_PATH | (Optional) Path to save attachments | /absolute/path/to/dir |
Installation
uv pip install fastmcp
# or
pip install fastmcp
Usage
- Set environment variables (see above)
- Run the server:
python server.py
API Endpoints (Tools)
send_email
Send an email, with optional attachments.
- Args:
to: Recipient email addresssubject: Email subjectcontent: Email body (plain text)attachments: List of absolute file paths to attach (optional)
- Returns:
{ "success": bool, "message": str }
reply_email
Reply to an email, with optional attachments.
- Args:
uid: UID of the original email to reply tosubject: Email subjectcontent: Email body (plain text or HTML)attachments: List of absolute file paths to attach (optional)
- Returns:
{ "success": bool, "message": str }
list_inbox / list_sent
List inbox or sent emails (brief info, attachment count).
- Args:
limit: Maximum number of emails to return (default 10)start: Start index (0-based, from the latest email)
- Returns:
{ "emails": [ { "uid", "subject", "snippet", "date", "seen", "attachment" } ] }attachment: Number of attachments in the email
read_email
Read full details of an email by UID, auto-save and list attachments.
- Args:
uid: UID of the email
- Returns:
{ "uid", "message_id", "from", "to", "subject", "date", "seen", "in_reply_to", "references", "snippet", "attachments" }attachments: List of all attachment filenames (auto-saved to MAIL_SAVE_PATH/uid/ if MAIL_SAVE_PATH is set)
Example .env
MAIL_USER_NAME=your@email.com
MAIL_PASS_WORD=yourpassword
MAIL_SMTP_ADDR=smtp.example.com:465
MAIL_IMAP_ADDR=imap.example.com:993
MAIL_FROM_NAME=Your Name
MAIL_FROM_ADDR=your@email.com
MAIL_SAVE_PATH=/absolute/path/to/attachments
FAQ
- Q: Why do I get 'Email content is empty'?
- A: The UID may not exist, or the email was deleted/moved. Make sure to use a valid UID from list_inbox/list_sent.
- Q: How to set display name?
- A: Set MAIL_FROM_NAME in your environment variables.
- Q: How to send HTML email?
- A: Just include HTML tags in content, the server will auto-detect and set the correct MIME type.
- Q: How to send attachments?
- A: Pass a list of absolute file paths to the
attachmentsparameter in send_email or reply_email.
- A: Pass a list of absolute file paths to the
- Q: How to auto-save received attachments?
- A: Set MAIL_SAVE_PATH. All attachments will be saved to MAIL_SAVE_PATH/uid/ when reading emails.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。