A Model Context Protocol (MCP) server for sending and receiving emails, supporting IMAP/SMTP, with display name, reply, and robust error handling.
Project description
MCP Email Client
A Model Context Protocol (MCP) server for sending and receiving emails, supporting IMAP/SMTP, with display name, reply, and robust error handling.
Features
- Send emails (with display name support)
- List inbox emails (brief info)
- Read email details by UID
- Reply to emails (auto set headers, display name)
- 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"
}
}
}
}
- 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 |
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.
- Args:
to: Recipient email addresssubject: Email subjectcontent: Email body (plain text)
- Returns:
{ "success": bool, "message": str }
list_emails
List inbox emails (brief info).
- Args:
limit: Maximum number of emails to return (default 10)
- Returns:
{ "emails": [ { "uid", "subject", "snippet", "date", "seen" } ] }
read_email
Read full details of an email by UID.
- Args:
uid: UID of the email
- Returns:
{ "uid", "message_id", "from", "to", "subject", "date", "seen", "in_reply_to", "references", "snippet" }
reply_email
Reply to an email (auto set headers, display name, auto-detect html).
- Args:
uid: UID of the original email to reply tosubject: Email subjectcontent: Email body (plain text or HTML)
- Returns:
{ "success": bool, "message": str }
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
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_emails.
- 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.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_email_client-0.1.3.tar.gz.
File metadata
- Download URL: mcp_email_client-0.1.3.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d461ed1d8f229dc78f1308d201f0c23e627dbc3b559ac42e55162af8efb9c432
|
|
| MD5 |
183e143b71c1c564feb6748a4874b18e
|
|
| BLAKE2b-256 |
8ede0fb991156b5ee7954784773daf229914acb5cfcb71c8bf668e82075af965
|
File details
Details for the file mcp_email_client-0.1.3-py3-none-any.whl.
File metadata
- Download URL: mcp_email_client-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4985d7c3d1a6f4df9c7f8643c6991e6871678835221ae94dc6adaf97a4b8c9e6
|
|
| MD5 |
5a07f3f3441ea1f88d61811a9fe32e50
|
|
| BLAKE2b-256 |
76bc273e861b8438d118f2e0bca485d93113693f0ba885fa056c478d1e156191
|