An MCP (Model Context Protocol) server for 163 email that provides tools for reading, searching, analyzing, and sending emails via SMTP and IMAP.
163 Email MCP Server
An MCP (Model Context Protocol) server for 163 email that provides tools for reading, searching, analyzing, and sending emails via SMTP and IMAP.
Features
- List emails: List emails in a mailbox with optional search criteria
- Get email: Get full content of a specific email including body and attachments info
- Search emails: Search emails with various criteria (subject, sender, date, unread status, etc.)
- Email statistics: Get mailbox statistics (total count, unread count, etc.)
- Send email: Send text emails with attachments
- Mark as read/unread: Change email read status
Configuration
The server uses the following configuration (hardcoded in main.py):
EMAIL_ACCOUNT = "your 163 email"
SMTP_PASSWORD = "your smtp password"
SMTP_SERVER = "smtp.163.com"
SMTP_PORT = 465
IMAP_SERVER = "imap.163.com"
IMAP_PORT = 993
Installation
-
Install uv if not already installed.
-
Install dependencies:
uv sync
Usage
Running the server
uv run main.py
The server will start and communicate via stdin/stdout following the MCP protocol.
Tools Available
-
list_emails
- Parameters:
mailbox(default: "INBOX"),limit(default: 20),search_criteria(optional IMAP criteria) - Returns: List of email summaries
- Parameters:
-
get_email
- Parameters:
email_id,mailbox(default: "INBOX") - Returns: Full email content including body and attachments info
- Parameters:
-
search_emails
- Parameters:
mailbox,subject,sender,date_from,date_to,unread_only,has_attachments,limit - Returns: List of matching email summaries
- Parameters:
-
get_email_statistics
- Parameters:
mailbox(default: "INBOX"),days(default: 30) - Returns: Mailbox statistics
- Parameters:
-
send_email
- Parameters:
to,subject,body,cc,bcc,attachments(list of file paths) - Returns: Success status
- Parameters:
-
mark_as_read
- Parameters:
email_id,mailbox(default: "INBOX") - Returns: Success status
- Parameters:
-
mark_as_unread
- Parameters:
email_id,mailbox(default: "INBOX") - Returns: Success status
- Parameters:
Example Usage with Claude Desktop
Add the server to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"163-email": {
"command": "uv",
"args": [
"--directory",
"/path/to/nexus-email-mcp-server",
"run",
"main.py"
]
}
}
}
Windows Attachment Support
The server supports attaching common Windows file formats:
- Images: .jpg, .png, .gif, .bmp, etc.
- Documents: .doc, .docx, .pdf, .txt, .xlsx, .pptx, etc.
- Archives: .zip, .rar, .7z, etc.
- Videos: .mp4, .avi, .mov, etc.
- Any other file type is supported as binary attachment.
Security Notes
- Email credentials are hardcoded in the source code. For production use, consider using environment variables or a configuration file.
- The server requires SMTP and IMAP access to your 163 email account.
- Ensure you're using an app-specific password if 2FA is enabled on your account.
Troubleshooting
- Connection errors: Verify your SMTP/IMAP settings and password.
- Authentication failed: Ensure you're using the correct SMTP authorization password (not your account password).
- Attachment issues: Check file paths exist and are readable.
- IMAP search issues: Some IMAP servers may have specific search syntax requirements.