Secure Python MCP email server with TLS for reading, deleting, and sending emails via POP3 and SMTP
The MCP (Model Context Protocol) Email Server is an advanced Python application designed to facilitate interaction between AI applications and email accounts. Leveraging POP3 for secure mailbox access and SMTP for sending emails, this server enables detailed operations such as polling emails, fetching full emails, deleting emails, and sending both plain text and HTML emails over secured connections. By integrating with the Model Context Protocol, it provides a standardized interface that can be used by various AI applications like Claude Desktop, Continue, Cursor, and more.
The Email Server includes several key capabilities:
pollEmails
function allows the AI application to query emails in the inbox, providing a list of email IDs along with key headers (Subject, From, Date, Message-ID).getEmailsById
method, specific emails can be retrieved by ID, including detailed body content parsed from HTML and plain text.deleteEmailsById
. This function is critical for managing email storage but should be used judiciously to avoid disrupting workflow processes.sendTextEmail
) and HTML formatted (sendHtmlEmail
) messages can be dispatched, giving AI applications flexibility in communication.These features are backed by the Model Context Protocol, ensuring seamless integration with various AI tools through a standardized API.
The architecture of the Email Server is structured around the Model Context Protocol (MCP), which defines a set of methods and protocols for interaction. The server exposes these methods via an MCP client, enabling them to be called by AI applications such as Claude Desktop.
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
graph TD
SubGraph[Email Server]
E[POP3] --> F[Inbox Access/Update]
G[SMTP] --> H[Email Sending/Receiving]
F --> G
H --> I[Email Storage/Delivery]
style SubGraph fill:#a0cbe8
To deploy the Email Server, follow these steps:
uv
is available for use.uv venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows
uv pip install -e .
.env
file): Create a .env
file with your email credentials and server details.Once configured, restart Claude Desktop to ensure automatic connection to the MCP Server.
An AI application could use the Email Server to implement an automated notification system. By polling for new emails and sending relevant notifications based on certain keywords or conditions, the server can trigger actions downstream, enhancing user experience and automation.
For a customer support application, the Email Server can be used to manage incoming support queries. Emails could be tagged automatically using pollEmails
, prioritized for immediate attention, and forwarded to relevant agents with necessary context attached.
The Email Server is compatible with several MCU clients:
Use the provided JSON snippet to configure your MCP client:
{
"mcpServers": {
"email-mcp-server": {
"command": "uv",
"args": [
"--directory",
"/path/to/email-mcp-server",
"run",
"main.py"
],
"env": {
# Override .env file settings if needed
#"EMAIL_USER": "...",
#"EMAIL_PASS": "...",
#"POP3_SERVER": "...",
#"SMTP_SERVER": "...",
#"SMTP_PORT": "...",
#"SMTP_USE_SSL": "true/false"
}
}
}
}
MCP Email Server ensures seamless and efficient data exchange with AI applications. The following table illustrates compatibility across key MCP clients:
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ |
Continue | ✅ | ✅ | ✅ |
Cursor | ❌ | ✅ | ❌ |
This matrix helps developers integrate the Email Server into their AI workflows effectively.
{
"mcpServers": {
"email-mcp-server": {
"command": "uv",
"args": ["run", "main.py"],
"env": {
"EMAIL_USER": "[email protected]",
"EMAIL_PASS": "securepassword!",
"POP3_SERVER": "pop.example.com",
"SMTP_SERVER": "smtp.example.com",
"SMTP_PORT": 465,
"SMTP_USE_SSL": "true"
}
}
}
}
Q: How do I ensure secure email communication?
Q: Can the Email Server handle large volumes of emails efficiently?
Q: Is it compatible with all AI applications using MCP?
Q: How do I troubleshoot connection issues?
Q: Can custom prompts be integrated into this system?
Contributions to improve and extend the functionality of the Email Server are welcome. For developers looking to enhance or modify this server:
uv
and dependencies installed.Explore more about the Model Context Protocol (MCP) and its applications at Official MCP Documentation. Join our community forums to engage with fellow developers and stay updated on MCP advancements.
This comprehensive documentation positions the MCP Email Server as a robust tool for AI application integration, providing clear guidelines for implementation and support.
AI Vision MCP Server offers AI-powered visual analysis, screenshots, and report generation for MCP-compatible AI assistants
Analyze search intent with MCP API for SEO insights and keyword categorization
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Expose Chicago Public Schools data with a local MCP server accessing SQLite and LanceDB databases
Connects n8n workflows to MCP servers for AI tool integration and data access