- Explore MCP Servers
- Email_MCP
Email Mcp
What is Email Mcp
Email_MCP is a Python-based server designed for sending and previewing emails using Gmail. It utilizes FastMCP to provide a simple API for sending emails and listing recent inbox messages, with a focus on security through environment-based configuration.
Use cases
Use cases for Email_MCP include sending promotional emails, notifying users of updates or changes, and providing a preview of recent communications for users to manage their inbox effectively.
How to use
To use Email_MCP, start the server by running ‘python Email_MCP_Server.py’. You can then send emails using the ‘send_email’ tool and list recent emails with the ‘list_recent_emails’ tool via the exposed API endpoints.
Key features
Key features of Email_MCP include the ability to send HTML emails via Gmail SMTP, list recent emails in the inbox, input validation for email addresses, support for environment variables to secure credentials, and integration with FastMCP for easy API access.
Where to use
Email_MCP can be used in various domains such as web applications, automated email notifications, and any system that requires email communication with users or clients.
Overview
What is Email Mcp
Email_MCP is a Python-based server designed for sending and previewing emails using Gmail. It utilizes FastMCP to provide a simple API for sending emails and listing recent inbox messages, with a focus on security through environment-based configuration.
Use cases
Use cases for Email_MCP include sending promotional emails, notifying users of updates or changes, and providing a preview of recent communications for users to manage their inbox effectively.
How to use
To use Email_MCP, start the server by running ‘python Email_MCP_Server.py’. You can then send emails using the ‘send_email’ tool and list recent emails with the ‘list_recent_emails’ tool via the exposed API endpoints.
Key features
Key features of Email_MCP include the ability to send HTML emails via Gmail SMTP, list recent emails in the inbox, input validation for email addresses, support for environment variables to secure credentials, and integration with FastMCP for easy API access.
Where to use
Email_MCP can be used in various domains such as web applications, automated email notifications, and any system that requires email communication with users or clients.
Content
Email MCP Server
A Python-based server for sending and previewing emails using Gmail, built with FastMCP. This project provides a simple API for sending emails and listing recent inbox messages, with environment-based configuration for security.
Features
- Send Emails: Easily send HTML emails via Gmail SMTP.
- List Recent Emails: Preview the latest emails in your Gmail inbox.
- Input Validation: Ensures all email addresses and fields are valid.
- Environment Variable Support: Keeps sensitive credentials out of your codebase.
- FastMCP Integration: Exposes tools as API endpoints for easy integration.
Requirements
- Python 3.8+
- Gmail account (with App Password if 2FA is enabled)
- FastMCP
- python-dotenv
Install dependencies:
pip install -r requirements.txt
Environment Variables
Create a .env
file in the project root with the following:
[email protected] EMAIL_PASSWORD=your_gmail_app_password
- EMAIL_ADDRESS: Your Gmail address.
- EMAIL_PASSWORD: App Password (required if 2FA is enabled).
Usage
Start the Server
python Email_MCP_Server.py
The server will expose tools via FastMCP.
Tools
1. send_email
Send an email using Gmail SMTP.
Parameters:
recipient_email
(str): Recipient’s email address.subject
(str): Email subject.body
(str): Email body (HTML supported).
Returns:
Success message or error details.
2. list_recent_emails
List the most recent emails in your inbox.
Parameters:
limit
(int, optional): Number of emails to preview (default: 5).
Returns:
A formatted string with subject and sender for each email.
Example
from mcp.client import MCPClient
client = MCPClient("http://localhost:8000")
print(client.send_email("[email protected]", "Test Subject", "<b>Hello!</b>"))
print(client.list_recent_emails(limit=3))
Security Notes
- Use an App Password for Gmail if 2FA is enabled.
- Never commit your
.env
file or credentials to version control. - For production, consider using OAuth2 for Gmail access.
Troubleshooting
- Authentication failed: Check your email and app password.
- Less secure app access: Ensure your Google account allows SMTP/IMAP access.
- Firewall issues: Make sure ports 465 (SMTP) and 993 (IMAP) are open.
License
MIT License
Author: Shashwat SIngh