Mailtrap
STDIO通过Mailtrap发送邮件和管理模板的MCP服务器
通过Mailtrap发送邮件和管理模板的MCP服务器
An MCP server that provides tools for sending transactional emails and managing email templates via Mailtrap
Before using this MCP server, you need to:
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 functionalitySmithery is a registry installer and manager for MCP servers that works with all AI clients.
npx @smithery/cli install mailtrap
Smithery automatically handles client configuration and provides an interactive setup process. It's the easiest way to get started with MCP servers locally.
Use MCPB to install the Mailtrap server. You can find those files in Releases. 
Download .MCPB file and open it. If you have Claude Desktop - it will open it and suggest to configure.
Add the following configuration:
{ "mcpServers": { "mailtrap": { "command": "npx", "args": ["-y", "mcp-mailtrap"], "env": { "MAILTRAP_API_TOKEN": "your_mailtrap_api_token", "DEFAULT_FROM_EMAIL": "[email protected]", "MAILTRAP_ACCOUNT_ID": "your_account_id", "MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id" } } } }
If you are using asdf for managing Node.js you must use absolute path to executable (example for Mac)
{ "mcpServers": { "mailtrap": { "command": "/Users/<username>/.asdf/shims/npx", "args": ["-y", "mcp-mailtrap"], "env": { "PATH": "/Users/<username>/.asdf/shims:/usr/bin:/bin", "ASDF_DIR": "/opt/homebrew/opt/asdf/libexec", "ASDF_DATA_DIR": "/Users/<username>/.asdf", "ASDF_NODEJS_VERSION": "20.6.1", "MAILTRAP_API_TOKEN": "your_mailtrap_api_token", "DEFAULT_FROM_EMAIL": "[email protected]", "MAILTRAP_ACCOUNT_ID": "your_account_id", "MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id" } } } }
Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Mac: ~/.cursor/mcp.json
Windows: %USERPROFILE%\.cursor\mcp.json
Run in Command Palette: Preferences: Open User Settings (JSON)
Then, in the settings file, add the following configuration:
{ "mcp": { "servers": { "mailtrap": { "command": "npx", "args": ["-y", "mcp-mailtrap"], "env": { "MAILTRAP_API_TOKEN": "your_mailtrap_api_token", "DEFAULT_FROM_EMAIL": "[email protected]", "MAILTRAP_ACCOUNT_ID": "your_account_id", "MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id" } } } } }
[!TIP] Don't forget to restart your MCP server after changing the "env" section.
For easy installation in hosts that support MCP Bundles, you can distribute an .mcpb bundle file.
# Build TypeScript and pack the MCPB bundle npm run mcpb:pack # Inspect bundle metadata npm run mcpb:info # Sign the bundle for distribution (optional) npm run mcpb:sign
This creates mailtrap-mcp.mcpb using the repository manifest.json and built artifacts in dist/.
Once configured, you can ask agent to send emails and manage templates, for example:
Email Operations:
Template Operations:
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 analyticsSends 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[!NOTE] The
MAILTRAP_TEST_INBOX_IDenvironment 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.
Creates a new email template in your Mailtrap account.
Parameters:
name (required): Name of the templatesubject (required): Email subject linehtml (or text is required): HTML content of the templatetext (or html is required): Plain text version of the templatecategory (optional): Template category (defaults to "General")Lists all email templates in your Mailtrap account.
Parameters:
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[!NOTE] At least one updatable field (name, subject, html, text, or category) must be provided when calling update-template to perform an update.
Deletes an existing email template.
Parameters:
template_id (required): ID of the template to deletegit clone https://github.com/mailtrap/mailtrap-mcp.git cd mailtrap-mcp
npm install
[!TIP] See the location of the config file in the Setup section.
Add the following configuration:
{ "mcpServers": { "mailtrap": { "command": "node", "args": ["/path/to/mailtrap-mcp/dist/index.js"], "env": { "MAILTRAP_API_TOKEN": "your_mailtrap_api_token", "DEFAULT_FROM_EMAIL": "[email protected]", "MAILTRAP_ACCOUNT_ID": "your_account_id", "MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id" } } } }
If you are using asdf for managing Node.js you should use absolute path to executable:
(example for Mac)
{ "mcpServers": { "mailtrap": { "command": "/Users/<username>/.asdf/shims/node", "args": ["/path/to/mailtrap-mcp/dist/index.js"], "env": { "PATH": "/Users/<username>/.asdf/shims:/usr/bin:/bin", "ASDF_DIR": "/opt/homebrew/opt/asdf/libexec", "ASDF_DATA_DIR": "/Users/<username>/.asdf", "ASDF_NODEJS_VERSION": "20.6.1", "MAILTRAP_API_TOKEN": "your_mailtrap_api_token", "DEFAULT_FROM_EMAIL": "[email protected]", "MAILTRAP_ACCOUNT_ID": "your_account_id", "MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id" } } } }
[!TIP] See the location of the config file in the Setup section.
{ "mcp": { "servers": { "mailtrap": { "command": "node", "args": ["/path/to/mailtrap-mcp/dist/index.js"], "env": { "MAILTRAP_API_TOKEN": "your_mailtrap_api_token", "DEFAULT_FROM_EMAIL": "[email protected]", "MAILTRAP_ACCOUNT_ID": "your_account_id", "MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id" } } } } }
You can test the server using the MCP Inspector:
npm run dev
# Run the MCPB server directly node dist/mcpb-server.js # Or use the provided binary mailtrap-mcpb-server
[!TIP] For development with the MCP Inspector:
npm run dev:mcpb
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.
Structured JSON logs with levels: INFO, WARN, ERROR, DEBUG.
Enable debug logging by setting DEBUG=true.
# Example: enable debug logging DEBUG=true node dist/mcpb-server.js
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:
# Filter error logs node dist/mcpb-server.js 2>&1 | jq 'select(.level == "error")' # Filter debug logs node dist/mcpb-server.js 2>&1 | jq 'select(.level == "debug")'
Common issues:
MAILTRAP_API_TOKEN is setMAILTRAP_TEST_INBOX_ID is configuredBug 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.
The package is available as open source under the terms of the MIT License.
Everyone interacting in the Mailtrap project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.