Provides tools for sending transactional emails and managing email templates through Mailtrap's API, including sandbox testing capabilities for development environments
MCP Mailtrap Server
An MCP server that provides tools for sending transactional emails and managing email templates via Mailtrap
Prerequisites
Before using this MCP server, you need to:
Get your API token from Mailtrap API settings
Get your Account ID from Mailtrap account management
Required Environment Variables:
MAILTRAP_API_TOKEN
- Required for all functionalityDEFAULT_FROM_EMAIL
- Required for all email sending operationsMAILTRAP_ACCOUNT_ID
- Required for template management operationsMAILTRAP_TEST_INBOX_ID
- Only required for sandbox email functionality
Quick Install
MCP Bundle (MCPB)
For easy installation in hosts that support MCP Bundles, you can distribute an .mcpb
bundle file.
This creates mailtrap-mcp.mcpb
using the repository manifest.json
and built artifacts in dist/
.
Setup
Claude Desktop or Cursor
Add the following configuration:
If you are using asdf
for managing Node.js you must use absolute path to executable (example for Mac)
Claude Desktop config file location
Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Cursor config file location
Mac: ~/.cursor/mcp.json
Windows: %USERPROFILE%\.cursor\mcp.json
VS Code
Manually changing config
Run in Command Palette: Preferences: Open User Settings (JSON)
Then, in the settings file, add the following configuration:
Don't forget to restart your MCP server after changing the "env" section.
Usage
Once configured, you can ask agent to send emails and manage templates, for example:
Email Operations:
"Send an email to john.doe@example.com with the subject 'Meeting Tomorrow' and a friendly reminder about our upcoming meeting."
"Email sarah@example.com about the project update, and CC the team at team@example.com"
"Send a sandbox email to test@example.com with subject 'Test Template' to preview how our welcome email looks"
Template Operations:
"List all email templates in my Mailtrap account"
"Create a new email template called 'Welcome Email' with subject 'Welcome to our platform!'"
"Update the template with ID 12345 to change the subject to 'Updated Welcome Message'"
"Delete the template with ID 67890"
Available Tools
send-email
Sends a transactional email through Mailtrap.
Parameters:
to
(required): Email address(es) of the recipient(s) - can be a single email or array of emailssubject
(required): Email subject linefrom
(optional): Email address of the sender, if not provided "DEFAULT_FROM_EMAIL" will be usedtext
(optional): Email body text, required if "html" is emptyhtml
(optional): HTML version of the email body, required if "text" is emptycc
(optional): Array of CC recipient email addressesbcc
(optional): Array of BCC recipient email addressescategory
(required): Email category for tracking and analytics
send-sandbox-email
Sends an email to your Mailtrap test inbox for development and testing purposes. This is perfect for testing email templates without sending emails to real recipients.
Parameters:
to
(required): Email address(es) of the recipient(s) - can be a single email or array of emails (will be delivered to your test inbox)subject
(required): Email subject linefrom
(optional): Email address of the sender, if not provided "DEFAULT_FROM_EMAIL" will be usedtext
(optional): Email body text, required if "html" is emptyhtml
(optional): HTML version of the email body, required if "text" is emptycc
(optional): Array of CC recipient email addressesbcc
(optional): Array of BCC recipient email addressescategory
(optional): Email category for tracking
TheMAILTRAP_TEST_INBOX_ID
environment variable must be configured for sandbox emails to work. This variable is only required for sandbox functionality and is not needed for regular transactional emails or template management.
create-template
Creates a new email template in your Mailtrap account.
Parameters:
name
(required): Name of the templatesubject
(required): Email subject linehtml
(ortext
is required): HTML content of the templatetext
(orhtml
is required): Plain text version of the templatecategory
(optional): Template category (defaults to "General")
list-templates
Lists all email templates in your Mailtrap account.
Parameters:
No parameters required
update-template
Updates an existing email template.
Parameters:
template_id
(required): ID of the template to updatename
(optional): New name for the templatesubject
(optional): New email subject linehtml
(optional): New HTML content of the templatetext
(optional): New plain text version of the templatecategory
(optional): New category for the template
At least one updatable field (name, subject, html, text, or category) must be provided when calling update-template to perform an update.
delete-template
Deletes an existing email template.
Parameters:
template_id
(required): ID of the template to delete
Development
Clone the repository:
Install dependencies:
Configuration with Claude Desktop or Cursor
See the location of the config file in theSetup section.
Add the following configuration:
If you are using asdf
for managing Node.js you should use absolute path to executable:
(example for Mac)
VS Code
See the location of the config file in theSetup section.
Testing
You can test the server using the MCP Inspector:
Running the MCPB Server
For development with the MCP Inspector:
Error Handling
This server uses structured error handling aligned with MCP conventions:
VALIDATION_ERROR
: Input validation failuresCONFIGURATION_ERROR
: Missing or invalid configurationEXECUTION_ERROR
: Runtime execution errorsTIMEOUT
: Operation timeout (30 seconds default)
Errors include actionable messages and are logged in structured form.
Security
Input validated via Zod schemas
Environment variables handled securely
Timeout protection on operations (30 seconds)
Sensitive details sanitized in error output
Logging
Structured JSON logs with levels: INFO, WARN, ERROR, DEBUG.
Enable debug logging by setting DEBUG=true
.
Important: The server writes logs to stderr so stdout remains reserved for JSON-RPC frames. This prevents hosts from encountering JSON parsing errors due to interleaved logs.
Log analysis example using jq
:
Troubleshooting
Common issues:
Missing API Token: ensure
MAILTRAP_API_TOKEN
is setSandbox not working: verify
MAILTRAP_TEST_INBOX_ID
is configuredTimeout errors: check network connectivity and Mailtrap API status
Validation errors: ensure all required fields are provided
Contributing
Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The package is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Mailtrap project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables sending transactional emails and managing email templates through Mailtrap's API. Supports both production email delivery and sandbox testing with comprehensive template management capabilities.