mcp server smtp

Local 2025-08-31 23:29:02 0

Enables sending emails via SMTP with template management, supporting multiple SMTP configurations, template creation with variable substitution, and bulk email sending with rate limiting.


A Model Context Protocol (MCP) server that provides email sending capabilities for Claude and other MCP-compatible AI assistants.

Features

  • Multiple SMTP Configurations: Configure and manage multiple SMTP servers
  • Email Templates: Create, update, and use reusable email templates
  • Bulk Email Sending: Send emails to multiple recipients with batching and rate limiting
  • HTML Support: Full HTML support for rich email content
  • Logging: Comprehensive logging of all email activities
  • Template Variables: Dynamic content using template variables

Installation

# Clone the repository
git clone https://github.com/samihalawa/mcp-server-smtp.git
cd mcp-server-smtp

# Install dependencies
npm install

# Build the server
npm run build

Usage

Starting the Server

npm start

Configuration

Add the server to your MCP configuration:

{
  "servers": {
    "smtp-email-server": {
      "command": "/path/to/node",
      "args": ["/path/to/mcp-server-smtp/build/index.js"],
      "enabled": true,
      "port": 3007,
      "environment": {
        "NODE_PATH": "/path/to/node_modules",
        "PATH": "/usr/local/bin:/usr/bin:/bin"
      }
    }
  }
}

Available Tools

send-email

Send an email to one or more recipients.

Parameters: - to: Array of recipients with email and optional name - subject: Email subject - body: Email body (HTML supported) - from: (Optional) Sender email and name - cc: (Optional) CC recipients - bcc: (Optional) BCC recipients - templateId: (Optional) ID of a template to use - templateData: (Optional) Data to populate template variables - smtpConfigId: (Optional) ID of the SMTP configuration to use

send-bulk-emails

Send emails to multiple recipients in batches.

Parameters: - recipients: Array of recipients with email and optional name - subject: Email subject - body: Email body (HTML supported) - from: (Optional) Sender email and name - cc: (Optional) CC recipients - bcc: (Optional) BCC recipients - templateId: (Optional) ID of a template to use - templateData: (Optional) Data to populate template variables - batchSize: (Optional) Number of emails to send in each batch - delayBetweenBatches: (Optional) Delay in milliseconds between batches - smtpConfigId: (Optional) ID of the SMTP configuration to use

get-smtp-configs

Get all configured SMTP servers.

Parameters: None

add-smtp-config

Add a new SMTP server configuration.

Parameters: - name: Name for the configuration - host: SMTP server hostname - port: SMTP server port - secure: Whether to use SSL/TLS - auth: Authentication credentials (user and pass) - isDefault: (Optional) Whether this is the default configuration

update-smtp-config

Update an existing SMTP server configuration.

Parameters: - id: ID of the configuration to update - name: Name for the configuration - host: SMTP server hostname - port: SMTP server port - secure: Whether to use SSL/TLS - auth: Authentication credentials (user and pass) - isDefault: (Optional) Whether this is the default configuration

delete-smtp-config

Delete an SMTP server configuration.

Parameters: - id: ID of the configuration to delete

get-email-templates

Get all email templates.

Parameters: None

add-email-template

Add a new email template.

Parameters: - name: Template name - subject: Email subject template - body: Email body template (HTML supported) - isDefault: (Optional) Whether this is the default template

update-email-template

Update an existing email template.

Parameters: - id: ID of the template to update - name: Template name - subject: Email subject template - body: Email body template (HTML supported) - isDefault: (Optional) Whether this is the default template

delete-email-template

Delete an email template.

Parameters: - id: ID of the template to delete

get-email-logs

Get logs of sent emails.

Parameters: None

Example Usage

  1. Configure an SMTP server:

    add-smtp-config(
      name: "Gmail",
      host: "smtp.gmail.com",
      port: 587,
      secure: false,
      auth: {
        user: "[email protected]",
        pass: "your-app-password"
      },
      isDefault: true
    )

  2. Create an email template:

    add-email-template(
      name: "Welcome Email",
      subject: "Welcome to {{company}}!",
      body: "<h1>Hello {{name}},</h1><p>Welcome to {{company}}!</p>",
      isDefault: false
    )

  3. Send an email using a template:

    send-email(
      to: [{ email: "[email protected]", name: "John Doe" }],
      templateId: "welcome-email",
      templateData: {
        name: "John",
        company: "ACME Corp"
      }
    )

  4. Send bulk emails:

    send-bulk-emails(
      recipients: [
        { email: "[email protected]", name: "User 1" },
        { email: "[email protected]", name: "User 2" }
      ],
      subject: "Important Announcement",
      body: "<p>This is an important announcement.</p>",
      batchSize: 10,
      delayBetweenBatches: 1000
    )

Requirements

  • Node.js 14+
  • Nodemailer for email sending
  • Access to an SMTP server

License

MIT

[
  {
    "description": "Send an email to one or more recipients",
    "inputSchema": {
      "properties": {
        "bcc": {
          "description": "Array of BCC recipients",
          "items": {
            "properties": {
              "email": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "email"
            ],
            "type": "object"
          },
          "type": "array"
        },
        "body": {
          "description": "Email body (HTML supported)",
          "type": "string"
        },
        "cc": {
          "description": "Array of CC recipients",
          "items": {
            "properties": {
              "email": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "email"
            ],
            "type": "object"
          },
          "type": "array"
        },
        "from": {
          "description": "Sender information. If not provided, the default SMTP user will be used.",
          "properties": {
            "email": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "type": "object"
        },
        "smtpConfigId": {
          "description": "ID of the SMTP configuration to use. If not provided, the default configuration will be used.",
          "type": "string"
        },
        "subject": {
          "description": "Email subject",
          "type": "string"
        },
        "templateData": {
          "description": "Data to be used for template variable substitution",
          "type": "object"
        },
        "templateId": {
          "description": "ID of the email template to use. If not provided, the email will use the subject and body provided.",
          "type": "string"
        },
        "to": {
          "description": "Array of recipients",
          "items": {
            "properties": {
              "email": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "email"
            ],
            "type": "object"
          },
          "type": "array"
        }
      },
      "required": [
        "to",
        "subject",
        "body"
      ],
      "type": "object"
    },
    "name": "send-email"
  },
  {
    "description": "Send emails in bulk to multiple recipients with rate limiting",
    "inputSchema": {
      "properties": {
        "batchSize": {
          "description": "Number of emails to send in each batch (default: 10)",
          "type": "number"
        },
        "bcc": {
          "description": "Array of BCC recipients",
          "items": {
            "properties": {
              "email": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "email"
            ],
            "type": "object"
          },
          "type": "array"
        },
        "body": {
          "description": "Email body (HTML supported)",
          "type": "string"
        },
        "cc": {
          "description": "Array of CC recipients",
          "items": {
            "properties": {
              "email": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "email"
            ],
            "type": "object"
          },
          "type": "array"
        },
        "delayBetweenBatches": {
          "description": "Delay between batches in milliseconds (default: 1000)",
          "type": "number"
        },
        "from": {
          "description": "Sender information. If not provided, the default SMTP user will be used.",
          "properties": {
            "email": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "type": "object"
        },
        "recipients": {
          "description": "Array of recipients",
          "items": {
            "properties": {
              "email": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "email"
            ],
            "type": "object"
          },
          "type": "array"
        },
        "smtpConfigId": {
          "description": "ID of the SMTP configuration to use. If not provided, the default configuration will be used.",
          "type": "string"
        },
        "subject": {
          "description": "Email subject",
          "type": "string"
        },
        "templateData": {
          "description": "Data to be used for template variable substitution",
          "type": "object"
        },
        "templateId": {
          "description": "ID of the email template to use. If not provided, the email will use the subject and body provided.",
          "type": "string"
        }
      },
      "required": [
        "recipients",
        "subject",
        "body"
      ],
      "type": "object"
    },
    "name": "send-bulk-emails"
  },
  {
    "description": "Get all SMTP configurations",
    "inputSchema": {
      "properties": {},
      "required": [],
      "type": "object"
    },
    "name": "get-smtp-configs"
  },
  {
    "description": "Add a new SMTP configuration",
    "inputSchema": {
      "properties": {
        "host": {
          "description": "SMTP host",
          "type": "string"
        },
        "isDefault": {
          "description": "Whether this configuration should be the default",
          "type": "boolean"
        },
        "name": {
          "description": "Name of the SMTP configuration",
          "type": "string"
        },
        "pass": {
          "description": "SMTP password",
          "type": "string"
        },
        "port": {
          "description": "SMTP port",
          "type": "number"
        },
        "secure": {
          "description": "Whether to use secure connection (SSL/TLS)",
          "type": "boolean"
        },
        "user": {
          "description": "SMTP username",
          "type": "string"
        }
      },
      "required": [
        "name",
        "host",
        "port",
        "user",
        "pass"
      ],
      "type": "object"
    },
    "name": "add-smtp-config"
  },
  {
    "description": "Update an existing SMTP configuration",
    "inputSchema": {
      "properties": {
        "host": {
          "description": "SMTP host",
          "type": "string"
        },
        "id": {
          "description": "ID of the SMTP configuration to update",
          "type": "string"
        },
        "isDefault": {
          "description": "Whether this configuration should be the default",
          "type": "boolean"
        },
        "name": {
          "description": "Name of the SMTP configuration",
          "type": "string"
        },
        "pass": {
          "description": "SMTP password",
          "type": "string"
        },
        "port": {
          "description": "SMTP port",
          "type": "number"
        },
        "secure": {
          "description": "Whether to use secure connection (SSL/TLS)",
          "type": "boolean"
        },
        "user": {
          "description": "SMTP username",
          "type": "string"
        }
      },
      "required": [
        "id"
      ],
      "type": "object"
    },
    "name": "update-smtp-config"
  },
  {
    "description": "Delete an SMTP configuration",
    "inputSchema": {
      "properties": {
        "id": {
          "description": "ID of the SMTP configuration to delete",
          "type": "string"
        }
      },
      "required": [
        "id"
      ],
      "type": "object"
    },
    "name": "delete-smtp-config"
  },
  {
    "description": "Get all email templates",
    "inputSchema": {
      "properties": {},
      "required": [],
      "type": "object"
    },
    "name": "get-email-templates"
  },
  {
    "description": "Add a new email template",
    "inputSchema": {
      "properties": {
        "body": {
          "description": "Email body template",
          "type": "string"
        },
        "isDefault": {
          "description": "Whether this template should be the default",
          "type": "boolean"
        },
        "name": {
          "description": "Name of the template",
          "type": "string"
        },
        "subject": {
          "description": "Email subject template",
          "type": "string"
        }
      },
      "required": [
        "name",
        "subject",
        "body"
      ],
      "type": "object"
    },
    "name": "add-email-template"
  },
  {
    "description": "Update an existing email template",
    "inputSchema": {
      "properties": {
        "body": {
          "description": "Email body template",
          "type": "string"
        },
        "id": {
          "description": "ID of the template to update",
          "type": "string"
        },
        "isDefault": {
          "description": "Whether this template should be the default",
          "type": "boolean"
        },
        "name": {
          "description": "Name of the template",
          "type": "string"
        },
        "subject": {
          "description": "Email subject template",
          "type": "string"
        }
      },
      "required": [
        "id"
      ],
      "type": "object"
    },
    "name": "update-email-template"
  },
  {
    "description": "Delete an email template",
    "inputSchema": {
      "properties": {
        "id": {
          "description": "ID of the template to delete",
          "type": "string"
        }
      },
      "required": [
        "id"
      ],
      "type": "object"
    },
    "name": "delete-email-template"
  },
  {
    "description": "Get logs of all email sending activity",
    "inputSchema": {
      "properties": {
        "filterBySuccess": {
          "description": "Filter logs by success status (true = successful emails, false = failed emails)",
          "type": "boolean"
        },
        "limit": {
          "description": "Maximum number of log entries to return (most recent first)",
          "type": "number"
        }
      },
      "type": "object"
    },
    "name": "get-email-logs"
  }
]