mailrelay-mcp-server

An unofficial Model Context Protocol (MCP) server for the Mailrelay.com email marketing API. It lets AI assistants like Claude manage groups, subscribers, tags, senders, custom fields, and campaigns in your own Mailrelay account.

Not affiliated with Mailrelay. This is an independent, community-built integration against Mailrelay's public REST API. You need your own Mailrelay account and API key to use it.

Features

Requirements

Installation

Option A: npx (no install)

Run it directly without installing, pointing your MCP client at:

npx mailrelay-mcp-server

Option B: from source

git clone https://github.com/YOUR_GITHUB_USERNAME/mailrelay-mcp-server.git
cd mailrelay-mcp-server
npm install

Configuration

The server reads two environment variables:

Variable Description
MAILRELAY_BASE_URL Your account's base URL, e.g. https://youraccount.ipzmarketing.com
MAILRELAY_API_KEY Your Mailrelay API key

If running from source, copy .env.example to .env and fill in your values:

cp .env.example .env

Usage with Claude Code

Register the server with the Claude Code CLI:

claude mcp add mailrelay -e MAILRELAY_BASE_URL=https://youraccount.ipzmarketing.com -e MAILRELAY_API_KEY=your-api-key -- npx mailrelay-mcp-server

Or add it manually to your MCP configuration (.mcp.json, or claude_desktop_config.json for Claude Desktop):

{
  "mcpServers": {
    "mailrelay": {
      "command": "npx",
      "args": ["mailrelay-mcp-server"],
      "env": {
        "MAILRELAY_BASE_URL": "https://youraccount.ipzmarketing.com",
        "MAILRELAY_API_KEY": "your-api-key"
      }
    }
  }
}

If you installed from source, replace the command/args with "node" / ["/absolute/path/to/mailrelay-mcp-server/src/index.js"].

Available tools

Health

Groups

Subscribers

Campaigns

Campaign folders

A/B tests

Imports

Tags

Senders

Custom fields

Not yet covered: media files, SMS, WhatsApp, ecommerce. Contributions welcome.

Manual testing

npm start

The server speaks MCP over stdio — it isn't meant to be run standalone in an interactive terminal, but launched by an MCP client (Claude Code, Claude Desktop, etc.).

Running it remotely (HTTP mode)

Besides stdio, the server can run as an HTTP service so that MCP clients connect to a URL instead of spawning a local process. Authentication works two ways against the same MCP_AUTH_TOKEN:

For a permanent deployment on your own domain, see DEPLOY.md (Hetzner VPS + Caddy). The rest of this section covers a quick temporary tunnel instead.

Temporary tunnel (e.g. to let someone else try it)

For a one-off test where someone else should add this server as a custom connector without installing anything locally, run it over HTTP and expose it through a tunnel:

  1. Add to .env (see .env.example):

    PORT=3939
    MCP_AUTH_TOKEN=<a long random secret, e.g. `openssl rand -hex 32`>
    PUBLIC_URL=<the tunnel URL, filled in after step 3>
    
  2. Start the HTTP server:

    npm run start:http
    

    It binds to 127.0.0.1 only — it must be reached through a tunnel, not directly.

  3. In another terminal, start a Cloudflare quick tunnel (no account needed):

    cloudflared tunnel --url http://127.0.0.1:3939
    

    It prints a random https://<name>.trycloudflare.com URL.

  4. Give the other person the full endpoint URL (https://<name>.trycloudflare.com/mcp) and the MCP_AUTH_TOKEN value, through a secure channel — not in the same message/channel as anything public.

    Either of these works:

    • A "Connectors" UI that runs OAuth (e.g. Claude Desktop → Settings → Connectors → Add custom connector): paste the URL, click Connect, and enter the token on the consent screen that appears. Note these UIs cannot send a custom Authorization header on Free/Pro plans (that's Team/Enterprise-only) — which is exactly why the OAuth path exists.

    • A client that sets headers directly in its config, skipping the handshake entirely:

    • Claude Desktop — add to claude_desktop_config.json:

      {
        "mcpServers": {
          "mailrelay": {
            "url": "https://<name>.trycloudflare.com/mcp",
            "headers": { "Authorization": "Bearer <the MCP_AUTH_TOKEN value>" }
          }
        }
      }
      

      Then restart Claude Desktop.

    • Claude Code CLI:

      claude mcp add --transport http mailrelay https://<name>.trycloudflare.com/mcp \
        --header "Authorization: Bearer <the MCP_AUTH_TOKEN value>"
      
  5. Stop both processes (Ctrl+C) when you're done testing. The trycloudflare.com URL is randomly generated and stops working the moment cloudflared exits, and the token should be rotated (edit MCP_AUTH_TOKEN in .env) if this ever runs unattended for long.

This exposes a server that can send real campaigns (mailrelay_send_campaign is irreversible) — never skip the auth token, and don't leave the tunnel running longer than needed for the test.

Contributing

Issues and pull requests are welcome. Please don't commit real API keys or account URLs — use .env (gitignored) for local testing.

License

MIT