Mailtrap Email API logo

Mailtrap Email API

Organization
railsware

Official mailtrap.io MCP server

Publisherrailsware
Repositorymailtrap-mcp
LanguageTypeScript
Forks
13
Stars
59
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Mailtrap Email API exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    59 stars and 13 forks from the linked repository.

TypeScript test NPM

MCP Mailtrap Server

An MCP server that provides tools for sending and testing in sandbox via Mailtrap.

Prerequisites

Before using this MCP server, you need to:

  1. Create a Mailtrap account
  2. Verify your domain
  3. Get your API token from Mailtrap API settings
  4. Get your Account ID from Mailtrap account management

Required Environment Variables:

  • MAILTRAP_API_TOKEN - Required for all functionality
  • MAILTRAP_ACCOUNT_ID - Required for templates, stats, email logs, sandbox list/show, and sending domains. Optional only for send-email and send-sandbox-email.

Optional (can be passed as tool parameters instead):

  • DEFAULT_FROM_EMAIL - Default sender email when from is not provided to send-email or send-sandbox-email. Enables switching sender per call via the from parameter.
  • MAILTRAP_TEST_INBOX_ID - Default test inbox ID for sandbox tools when test_inbox_id is not provided. Enables switching between inboxes per call via the test_inbox_id parameter.

Quick Install

Install in Cursor

Install with Node in VS Code

Smithery CLI

Smithery 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.

Setup

Claude Desktop

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.

Claude Desktop or Cursor

Add the following configuration:

json
{
  "mcpServers": {
    "mailtrap": {
      "command": "npx",
      "args": ["-y", "mcp-mailtrap"],
      "env": {
        "MAILTRAP_API_TOKEN": "your_mailtrap_api_token",
        "DEFAULT_FROM_EMAIL": "your_sender@example.com",
        "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)

json
{
  "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",
        "MAILTRAP_ACCOUNT_ID": "your_account_id",
        "MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id"
      }
    }
  }
}

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:

json
{
  "mcp": {
    "servers": {
      "mailtrap": {
        "command": "npx",
        "args": ["-y", "mcp-mailtrap"],
        "env": {
          "MAILTRAP_API_TOKEN": "your_mailtrap_api_token",
          "DEFAULT_FROM_EMAIL": "your_sender@example.com",
          "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.

MCP Bundle (MCPB)

For easy installation in hosts that support MCP Bundles, you can distribute an .mcpb bundle file.

bash
# 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/.

Usage

Once configured, you can ask agent to send emails and manage templates, for example:

Email Sending 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 the welcome template (uuid b81aabcd-1a1e-41cf-91b6-eca0254b3d96) to new@example.com with variables { name: 'Alex' }"
  • "Send a sandbox email to test@example.com with subject 'Test Template' to preview how our welcome email looks"

Email Logs (debug delivery):

  • "List my recent sent email logs"
  • "Show email logs for emails sent to user@example.com"
  • "Get the email log message for ID abc-123-uuid to check delivery status"

Sending Statistics:

  • "Get sending stats for January 2025"
  • "Show delivery rates broken down by domain for last month"
  • "What are my email stats by category from 2025-01-01 to 2025-01-31?"

Sandbox Operations:

  • "Get all messages from my sandbox inbox"
  • "Show me the first page of sandbox messages"
  • "Search for messages containing 'test' in my sandbox inbox"
  • "Show me the details of sandbox message with ID 5159037506"

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"

Sending Domains:

  • "List my sending domains"
  • "Get sending domain with ID 3938"
  • "Create a sending domain for example.com"
  • "Delete sending domain 3938"
  • "Get sending domain 3938 with DNS setup instructions"

Available Tools

send-email

Sends a transactional email through Mailtrap. Supports two mutually exclusive modes — inline content (subject + text/html) or template-based (template_uuid).

Parameters:

  • from (optional): Sender as an email string or { email, name? }. If not provided, DEFAULT_FROM_EMAIL is used.
  • to (optional): Recipient(s) — a single email/{ email, name? } or an array. Optional if cc or bcc is provided; at least one of to / cc / bcc must contain a recipient.
  • cc (optional): Array of CC recipients (email strings or { email, name? } each).
  • bcc (optional): Array of BCC recipients (email strings or { email, name? } each).
  • subject (conditional): Email subject line. Required for inline sends; must be omitted when template_uuid is set.
  • text (conditional): Email body text. Required (alongside or instead of html) for inline sends; must be omitted when template_uuid is set.
  • html (conditional): HTML version of the email body. Required (alongside or instead of text) for inline sends; must be omitted when template_uuid is set.
  • category (optional): Email category for tracking and analytics. Must be omitted when template_uuid is set.
  • template_uuid (optional): Use a Mailtrap email template instead of inline content. When set, subject / text / html / category must be omitted (per Mailtrap API).
  • template_variables (optional): Object of variables substituted into the template referenced by template_uuid. Only allowed together with template_uuid.

list-email-logs

Lists sent email logs (delivery history) with optional pagination and filters. Use to debug delivery issues from the IDE.

Parameters:

  • search_after (optional): Pagination cursor from the previous response's next_page_cursor
  • sent_after (optional): ISO 8601 date/time; only logs sent after this time
  • sent_before (optional): ISO 8601 date/time; only logs sent before this time
  • from_email (optional): Filter by sender email; use with from_operator (default: ci_equal)
  • to_email (optional): Filter by recipient email; use with to_operator (default: ci_equal)
  • status (optional): Filter by delivery status: delivered, not_delivered, enqueued, opted_out; use with status_operator (default: equal)
  • subject (optional): Filter by email subject; use with subject_operator (default: ci_contain). Use subject_operator: empty/not_empty to filter by presence of subject.
  • sending_domain_id (optional): Filter by sending domain ID (number); use with sending_domain_id_operator (default: equal)
  • sending_stream (optional): Filter by stream: transactional or bulk; use with sending_stream_operator (default: equal)
  • events (optional): Filter by event type(s): delivery, open, click, bounce, spam, unsubscribe, soft_bounce, reject, suspension; use with events_operator (include_event / not_include_event)
  • clicks_count / opens_count (optional): Filter by click/open count; use with *_operator: equal, greater_than, less_than
  • client_ip / sending_ip (optional): Filter by IP; use with *_operator: equal, not_equal, contain, not_contain
  • email_service_provider_response (optional): Filter by provider response text; use with *_operator (ci_contain, etc.)
  • email_service_provider (optional): Filter by provider (exact); use with *_operator: equal, not_equal
  • recipient_mx (optional): Filter by recipient MX; use with recipient_mx_operator (ci_contain, etc.)
  • category (optional): Filter by email category; use with category_operator: equal, not_equal

All parameters are optional.

get-email-log-message

Gets a single email log message by ID (UUID): a readable summary (from, to, subject, sent time, status, category, stream, engagement, delivery context), then detailed event history. Optionally, with include_content: true, you can also load and show the message body (HTML and plain text) when Mailtrap exposes a raw message URL.

Parameters:

  • message_id (required): UUID of the email log message (from send response or list-email-logs). Use list-email-logs to find message IDs.
  • include_content (optional): When true, fetches the raw EML (if raw_message_url is available) and appends parsed HTML and plain-text body sections, similar to show-sandbox-email-message.

get-sending-stats

Get email sending statistics (delivery, bounce, open, click, spam rates) for a date range. Optionally break down by domain, category, email service provider, or date. Check delivery rates without leaving the editor.

Parameters:

  • start_date (required): Start date for the stats range (YYYY-MM-DD)
  • end_date (required): End date for the stats range (YYYY-MM-DD)
  • breakdown (optional): How to break down the stats: aggregated (default), by_domain, by_category, by_email_service_provider, or by_date
  • sending_domain_ids (optional): Limit results to these sending domain IDs (array of integers)
  • sending_streams (optional): Limit to transactional and/or bulk (array of strings)
  • categories (optional): Limit to these email categories (array of strings)
  • email_service_providers (optional): Limit to these providers, e.g. Google, Yahoo, Outlook (array of strings)

create-template

Creates a new email template in your Mailtrap account.

Parameters:

  • name (required): Name of the template
  • subject (required): Email subject line
  • html (or text is required): HTML content of the template
  • text (or html is required): Plain text version of the template
  • category (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 update
  • name (optional): New name for the template
  • subject (optional): New email subject line
  • html (optional): New HTML content of the template
  • text (optional): New plain text version of the template
  • category (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.

delete-template

Deletes an existing email template.

Parameters:

  • template_id (required): ID of the template to delete

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. Supports the same two modes as send-emailinline content or template-based (template_uuid).

Parameters:

  • test_inbox_id (optional): Mailtrap test inbox ID. Required unless MAILTRAP_TEST_INBOX_ID is set; pass per call to target a specific inbox.
  • from (optional): Sender as an email string or { email, name? }. If not provided, DEFAULT_FROM_EMAIL is used.
  • to (optional): Recipients as a comma-separated string, or an array of email strings / { email, name? } objects. Optional if cc or bcc is provided; at least one of to / cc / bcc must contain a recipient.
  • cc (optional): Array of CC recipients (email strings or { email, name? } each).
  • bcc (optional): Array of BCC recipients (email strings or { email, name? } each).
  • subject (conditional): Email subject line. Required for inline sends; must be omitted when template_uuid is set.
  • text (conditional): Email body text. Required (alongside or instead of html) for inline sends; must be omitted when template_uuid is set.
  • html (conditional): HTML version of the email body. Required (alongside or instead of text) for inline sends; must be omitted when template_uuid is set.
  • category (optional): Email category for tracking. Must be omitted when template_uuid is set.
  • template_uuid (optional): Use a Mailtrap email template instead of inline content. When set, subject / text / html / category must be omitted.
  • template_variables (optional): Object of variables substituted into the template referenced by template_uuid. Only allowed together with template_uuid.

[!NOTE] For sandbox tools, provide test_inbox_id in the tool call or set the MAILTRAP_TEST_INBOX_ID environment variable. You can switch between inboxes per call by passing test_inbox_id.

get-sandbox-messages

Retrieves a list of messages from your Mailtrap test inbox. Useful for checking what emails have been received in your sandbox during testing.

Parameters:

  • page (optional): Page number for pagination (minimum: 1)
  • last_id (optional): Pagination using last message ID. Returns messages after the specified message ID (minimum: 1)
  • search (optional): Search query to filter messages

[!NOTE] All parameters are optional. If none are provided, the first page of messages from the inbox will be returned. Use page for traditional pagination, last_id for cursor-based pagination, or search to filter messages by content.

show-sandbox-email-message

Shows detailed information and content of a specific email message from your Mailtrap test inbox, including HTML and text body content.

Parameters:

  • message_id (required): ID of the sandbox email message to retrieve

[!NOTE] Use get-sandbox-messages first to get the list of messages and their IDs, then use this tool to view the full content of a specific message.

list-sending-domains

List sending domains and their DNS verification status.

Parameters:

  • No parameters required

get-sending-domain

Get a sending domain by ID and its verification status (including DNS records). Optionally include DNS setup instructions by setting include_setup_instructions to true.

Parameters:

  • sending_domain_id (required): Sending domain ID
  • include_setup_instructions (optional): If true, append DNS setup instructions to the response. Default: false

create-sending-domain

Create a new sending domain. After creation, add DNS records to verify the domain (use get-sending-domain with include_setup_instructions: true to see the records).

Parameters:

  • domain_name (required): Domain name (e.g. example.com)

delete-sending-domain

Delete a sending domain.

Parameters:

  • sending_domain_id (required): Sending domain ID to delete

Development

  1. Clone the repository:
bash
git clone https://github.com/mailtrap/mailtrap-mcp.git
cd mailtrap-mcp
  1. Install dependencies:
bash
npm install

Configuration with Claude Desktop or Cursor

[!TIP] See the location of the config file in the Setup section.

Add the following configuration:

json
{
  "mcpServers": {
    "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",
        "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)

json
{
  "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": "your_sender@example.com",
        "MAILTRAP_ACCOUNT_ID": "your_account_id",
        "MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id"
      }
    }
  }
}

VS Code

[!TIP] See the location of the config file in the Setup section.

json
{
  "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",
          "MAILTRAP_ACCOUNT_ID": "your_account_id",
          "MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id"
        }
      }
    }
  }
}

Testing

You can test the server using the MCP Inspector:

bash
npm run dev

Running the MCPB Server

bash
# 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:

bash
npm run dev:mcpb

Error Handling

This server uses structured error handling aligned with MCP conventions:

  • VALIDATION_ERROR: Input validation failures
  • CONFIGURATION_ERROR: Missing or invalid configuration
  • EXECUTION_ERROR: Runtime execution errors
  • TIMEOUT: 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.

bash
# 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:

bash
# 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")'

Troubleshooting

Common issues:

  1. Missing API Token: ensure MAILTRAP_API_TOKEN is set
  2. Sandbox not working: provide test_inbox_id in the tool call or set MAILTRAP_TEST_INBOX_ID env
  3. Timeout errors: check network connectivity and Mailtrap API status
  4. 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.

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "mailtrap": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mailtrap"
      ],
      "env": {
        "MAILTRAP_API_TOKEN": "your_mailtrap_api_token",
        "DEFAULT_FROM_EMAIL": "your_sender@example.com"
      }
    }
  }
}

Use Mailtrap Email API MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Mailtrap Email API is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Mailtrap Email API as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Mailtrap Email API MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "mailtrap-email-api": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mailtrap"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Mailtrap Email API MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Mailtrap Email API MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Mailtrap Email API to help me with this task?
Mailtrap Email API
Sure. I read it.
Here is what I found using Mailtrap Email API.

Frequently asked questions

What is the Mailtrap Email API MCP server used for?

Mailtrap Email API is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Mailtrap Email API MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Mailtrap Email API with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Mailtrap Email API MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Mailtrap Email API connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Mailtrap Email API MCP to TypingMind?

Mailtrap Email API runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Mailtrap Email API MCP provide in TypingMind?

Mailtrap Email API exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Mailtrap Email API MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Mailtrap Email API requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇