Enables programmatic email sending capabilities via SendGrid, supporting basic text or HTML emails, dynamic templates, and file attachments.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Email Server with SendGridSend a thank you email to mark@example.com for his help with the code review"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
βοΈ MCP Email Server with SendGrid
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.
π Features
π§ Basic Email Sending - Send text or HTML emails
π¨ Template Support - Use SendGrid dynamic templates
π File Attachments - Attach files to emails
π₯ CC/BCC Support - Send copies to multiple recipients
π³ Docker Ready - Containerized deployment
π Secure - Environment-based configuration
π Prerequisites
Python 3.10 or higher
SendGrid account and API key (Sign up here)
Verified sender email address in SendGrid
Docker (optional, for containerized deployment)
π οΈ Installation
Option 1: Local Python Setup
Clone or navigate to the repository:
cd d:\repos\mcp_mailCreate and activate virtual environment:
python -m venv venv .\venv\Scripts\activate # WindowsInstall dependencies:
pip install -e .Configure environment variables:
copy .env.example .envEdit
.envand add your credentials:SENDGRID_API_KEY=your_actual_sendgrid_api_key DEFAULT_FROM_EMAIL=your-verified-email@example.com DEFAULT_FROM_NAME=Your Name
Option 2: Docker Deployment
Configure environment:
copy .env.example .env # Edit .env with your credentialsBuild and run with Docker Compose:
docker-compose up -dOr build manually:
docker build -t mcp-email-server . docker run --env-file .env mcp-email-server
π§ Configuration
SendGrid Setup
Create a SendGrid account at sendgrid.com
Generate an API key:
Go to Settings β API Keys
Click "Create API Key"
Select "Full Access" or "Restricted Access" with Mail Send permissions
Copy the API key (you'll only see it once!)
Verify sender email:
Go to Settings β Sender Authentication
Verify the email address you'll use as the sender
This is required by SendGrid to prevent spam
Environment Variables
Variable | Required | Description |
| Yes | Your SendGrid API key |
| Yes | Default sender email (must be verified in SendGrid) |
| No | Default sender name displayed to recipients |
π Usage
Running the Server
Local:
Docker:
The server communicates via stdio (standard input/output) using the MCP protocol.
Available MCP Tools
1. send_email
Send 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:
2. send_email_with_template
Send 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 subject
Example:
3. send_email_with_attachments
Send 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 flag
Example:
π Integration Examples
Claude Desktop
Add to your Claude Desktop config file (claude_desktop_config.json):
Or using Docker:
Langflow Integration
Install an MCP client component in Langflow (if available) or use a custom Python component
Configure the MCP server connection with the email server's stdio transport
Call the email tools from your Langflow flows
See examples/langflow_integration.md for detailed instructions.
Python Client Example
π§ͺ Testing
Run the test script to verify functionality:
This will test the email sending functions with mocked SendGrid responses.
π Troubleshooting
"SendGrid client not initialized"
Ensure
SENDGRID_API_KEYis set in your.envfileVerify the API key is valid and has Mail Send permissions
"403 Forbidden" error
Your sender email address must be verified in SendGrid
Go to SendGrid Settings β Sender Authentication
"No from_email provided"
Set
DEFAULT_FROM_EMAILin your.envfile, orProvide
from_emailparameter in each request
Attachments not working
Ensure the file paths are absolute and accessible
Check file permissions
Verify files exist at the specified paths
π Resources
π License
MIT License - feel free to use this in your projects!
π€ Contributing
Contributions welcome! Feel free to submit issues or pull requests.