loading…
Search for a command to run...
loading…
An MCP server that enables AI applications to send text, HTML, and template-based emails using SendGrid. It supports file attachments, CC/BCC recipients, and ea
An MCP server that enables AI applications to send text, HTML, and template-based emails using SendGrid. It supports file attachments, CC/BCC recipients, and easy deployment via Python or Docker.
A Model Context Protocol (MCP) server that provides email sending capabilities through SendGrid. This server enables AI applications like Claude Desktop, Langflow, and other MCP clients to send emails programmatically.
Clone or navigate to the repository:
cd d:\repos\mcp_mail
Create and activate virtual environment:
python -m venv venv
.\venv\Scripts\activate # Windows
Install dependencies:
pip install -e .
Configure environment variables:
copy .env.example .env
Edit .env and add your credentials:
SENDGRID_API_KEY=your_actual_sendgrid_api_key
[email protected]
DEFAULT_FROM_NAME=Your Name
Configure environment:
copy .env.example .env
# Edit .env with your credentials
Build and run with Docker Compose:
docker-compose up -d
Or build manually:
docker build -t mcp-email-server .
docker run --env-file .env mcp-email-server
Create a SendGrid account at sendgrid.com
Generate an API key:
Verify sender email:
| Variable | Required | Description |
|---|---|---|
SENDGRID_API_KEY |
Yes | Your SendGrid API key |
DEFAULT_FROM_EMAIL |
Yes | Default sender email (must be verified in SendGrid) |
DEFAULT_FROM_NAME |
No | Default sender name displayed to recipients |
Local:
python server.py
Docker:
docker-compose up
The server communicates via stdio (standard input/output) using the MCP protocol.
send_emailSend a basic email with text or HTML content.
Parameters:
to_email (required): Recipient email addresssubject (required): Email subject linebody (required): Email content (text or HTML)from_email (optional): Sender email (uses DEFAULT_FROM_EMAIL if not provided)from_name (optional): Sender namecc_emails (optional): List of CC recipientsbcc_emails (optional): List of BCC recipientsis_html (optional): Set to true for HTML emails (default: false)Example:
{
"to_email": "[email protected]",
"subject": "Hello from MCP",
"body": "<h1>Welcome!</h1><p>This is a test email.</p>",
"is_html": true
}
send_email_with_templateSend an email using a SendGrid dynamic template.
Parameters:
to_email (required): Recipient email addresstemplate_id (required): SendGrid template IDdynamic_data (required): Dictionary of template variablesfrom_email (optional): Sender emailfrom_name (optional): Sender namesubject (optional): Override template subjectExample:
{
"to_email": "[email protected]",
"template_id": "d-1234567890abcdef",
"dynamic_data": {
"username": "John",
"action_url": "https://example.com/verify"
}
}
send_email_with_attachmentsSend an email with file attachments.
Parameters:
to_email (required): Recipient email addresssubject (required): Email subject linebody (required): Email contentattachment_paths (required): List of file paths to attachfrom_email (optional): Sender emailfrom_name (optional): Sender nameis_html (optional): HTML email flagExample:
{
"to_email": "[email protected]",
"subject": "Report Attached",
"body": "Please find the report attached.",
"attachment_paths": ["/path/to/report.pdf", "/path/to/data.csv"]
}
Add to your Claude Desktop config file (claude_desktop_config.json):
{
"mcpServers": {
"email": {
"command": "python",
"args": ["d:\\repos\\mcp_mail\\server.py"],
"env": {
"SENDGRID_API_KEY": "your_api_key",
"DEFAULT_FROM_EMAIL": "[email protected]",
"DEFAULT_FROM_NAME": "Your Name"
}
}
}
}
Or using Docker:
{
"mcpServers": {
"email": {
"command": "docker",
"args": ["run", "-i", "--rm", "--env-file", "d:\\repos\\mcp_mail\\.env", "mcp-email-server"]
}
}
}
See examples/langflow_integration.md for detailed instructions.
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
server_params = StdioServerParameters(
command="python",
args=["d:/repos/mcp_mail/server.py"],
env={
"SENDGRID_API_KEY": "your_key",
"DEFAULT_FROM_EMAIL": "[email protected]"
}
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
# Call the send_email tool
result = await session.call_tool("send_email", {
"to_email": "[email protected]",
"subject": "Test Email",
"body": "Hello from MCP!",
"is_html": False
})
print(result)
Run the test script to verify functionality:
python test_server.py
This will test the email sending functions with mocked SendGrid responses.
SENDGRID_API_KEY is set in your .env fileDEFAULT_FROM_EMAIL in your .env file, orfrom_email parameter in each requestMIT License - feel free to use this in your projects!
Contributions welcome! Feel free to submit issues or pull requests.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"mcp-email-server-with-sendgrid": {
"command": "npx",
"args": []
}
}
}