Mailtrap MCP Server
In this article:
- Adding Mailtrap MCP to Cursor
- Adding Mailtrap MCP to Claude
- Adding Mailtrap MCP to VS Code
- Use cases and examples
- send-email and parameters
- Running the server locally
Mailtrap MCP Server lets you automate email workflows from your AI IDE (e.g., VS Code) or send real emails with simple prompts from AI assistants (e.g., Claude or Cursor).
For a more detailed overview of MCP, check out the YouTube video we’ve prepared for you. Or, for more technical details, visit the official GitHub repository. ⬅️
Note: Mailtrap MCP server is implemented as a Node.js command line utility, so please install the latest Node.js version before getting started.
Adding Mailtrap MCP to Cursor
To add Mailtrap MCP to Cursor, follow these steps:
- Open your Cursor editor and navigate to Settings → Cursor Settings.
- Go to the MCP tab and click on Add new global MCP server.
The Add new global MCP server should open a new mcp.json config file, where we’ll store the Mailtrap MCP configuration.
Tip: You can also open the mcp.json file in the following locations:
- MacOS:
~/.cursor/mcp.json
- Windows:
%USERPROFILE%\.cursor\mcp.json
Once you open the mcp.json file, copy/paste the following configuration inside it:
{ "mcpServers": { "mailtrap": { "command": "npx", "args": ["-y", "mcp-mailtrap"], "env": { "MAILTRAP_API_TOKEN": "your_mailtrap_api_token", "DEFAULT_FROM_EMAIL": "your_sender@example.com" } } } }
Note: In case you’re using asdf to manage Node.js, you must use an absolute path to the executable. Here’s an 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": "your_sender@example.com" } } } }
Lastly, open your Mailtrap account and navigate to Sending Domains → Integration → API.
Once in the Integration/API page, update the following values in your mcp.json file with Mailtrap credentials:
MAILTRAP_API_TOKEN
– Used to authenticate API requests, which you can copy/paste from the credentials tab.DEFAULT_FROM_EMAIL
– Make sure the email’s domain matches your own domain from the Sending Domains tab in Mailtrap.
For example, here’s what your mcp.json file should ultimately look like:
And that’s it, hit save, reload, and you can start sending emails via Cursor with simple prompts.
Adding Mailtrap MCP to Claude
To add Mailtrap MCP server to Claude, follow these steps:
- In Claude settings, go to the Developer tab, click on Edit Config, and open the claude_desktop_config.json file.
Tip: You can also open the claude_desktop_config.json file in the following locations:
- MacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
Then, in the claude_desktop_config,json copy/paste the following script:
{ "mcpServers": { "mailtrap": { "command": "npx", "args": ["-y", "mcp-mailtrap"], "env": { "MAILTRAP_API_TOKEN": "your_mailtrap_api_token", "DEFAULT_FROM_EMAIL": "your_sender@example.com" } } } }
Lastly, open your Mailtrap account and navigate to Sending Domains → Integration → API.
Once in the Integration/API page, update the following values in your mcp.json file with Mailtrap credentials:
MAILTRAP_API_TOKEN
– Used to authenticate API requests, which you can copy/paste from the credentials tab.DEFAULT_FROM_EMAIL
– Make sure the email’s domain matches your own domain from the Sending Domains tab in Mailtrap.
Adding Mailtrap MCP to VS Code
To add Mailtrap MCP to Visual Studio Code, follow these steps:
- Open your VS Code editor, navigate to Settings, and find the Mcp tab via the search bar.
- Tick the Chat> Mcp: Enabled option and click on Edit in settings.json
- This should open the settings.json config file.
Pro tip: You can also open the settings.json file by typing the following in the Command Pallette: Preferences: Open User Settings (JSON).
- In the settings.json file, copy/paste the following code snippet:
{ "mcp": { "servers": { "mailtrap": { "command": "npx", "args": ["-y", "mcp-mailtrap"], "env": { "MAILTRAP_API_TOKEN": "your_mailtrap_api_token", "DEFAULT_FROM_EMAIL": "your_sender@example.com" } } } } }
Important: Make sure to restart your MCP server after changing the “env” section.
Now, all there’s left to do is replace the following values in the settings.json file:
MAILTRAP_API_TOKEN
– Used to authenticate API requests, which you can copy/paste from the credentials tab.DEFAULT_FROM_EMAIL
– Make sure the email’s domain matches your own domain from the Sending Domains tab in Mailtrap.
You can find these credentials in your Mailtrap account by navigating to Sending Domains → Integration → API.
Note: Although you shouldn’t face any issues, I still recommend reloading VS Code to make sure everything is being set up correctly.
Use cases and examples
Once configured, you can prompt the AI/agent to send emails, such as:
- Plain-text emails – "Send an email to john.doe@example.com with the subject 'Meeting Tomorrow' and a friendly reminder about our upcoming meeting."
- HTML emails – "Send an HTML email to john.doe@example that wishes them a happy work anniversary and make sure the message is nicely formatted”
- Multiple recipients– "Email sarah@example.com about the project update, and CC the team at team@example.com"
- Summarize and send info – "Summarize this PDF for me and send the summary to john.doe@example.com and jane.doe@example.com"
Pro tip: You can also combine Mailtrap MCP with other MCP servers for an even more advanced functionality. For example, you can send a report email to your team via Mailtrap MCP, and use the Slack MCP to post a message in the team’s channel to ensure everyone gets the word. You can also post a test email to your team’s channel for them to approve it via a simple prompt. The possibilities are really endless.
send-email
and parameters
To send emails through Mailtrap, you’ll use send-email
.
And here are some of the parameters you can add:
Parameter | Required/Optional | Description |
to |
Required | Email address of the recipient |
subject |
Required | Email subject line |
from |
Optional | Sender’s email address. If it’s not provided, it defaults to DEFAULT_FROM_EMAIL |
text |
Optional | Plain text email body. Required if text is not provided. |
html |
Optional | HTML version of the email body. Required if text is empty. |
cc |
Optional | Array of CC recipient email addresses |
bcc |
Optional | Array of BCC recipient email addresses |
category |
Optional | Email category for tracking |
Running the server locally
You can also run the server locally during development. To do this, you need to:
- Clone the repository by running:
git clone https://github.com/railsware/mailtrap-mcp.git cd mailtrap-mcp
- Install dependencies with npm:
npm install
- Add one of the following configurations to your main .json file:
Claude Desktop or Cursor:
{ "mcp": { "servers": { "mailtrap": { "command": "node", "args": ["/path/to/mailtrap-mcp/dist/index.js"], "env": { "MAILTRAP_API_TOKEN": "your_mailtrap_api_token", "DEFAULT_FROM_EMAIL": "your_sender@example.com" } } } } }
VS Code:
{ "mcp": { "servers": { "mailtrap": { "command": "node", "args": ["/path/to/mailtrap-mcp/dist/index.js"], "env": { "MAILTRAP_API_TOKEN": "your_mailtrap_api_token", "DEFAULT_FROM_EMAIL": "your_sender@example.com" } } } } }
Also, make sure to replace the placeholders with your actual Mailtrap credentials.
- Run the server with npm command
Lastly, you can try testing the server using MCP inspector and npm:
npm run dev
Note: You can also test and debug MCP the server using MCP inspector.