Skip to main content

MCP server for KeenMail API integration

Project description

KeenMail MCP Server

A Model Context Protocol (MCP) server for integrating with the KeenMail API. This server allows AI assistants to send template-based emails through KeenMail's service.

Features

  • MCP Compatible: Works with Claude Desktop and other MCP clients
  • UVX Ready: Installable and runnable via uvx for easy distribution
  • Environment Configuration: Secure API key management through environment variables
  • STDIO Transport: Full compatibility with MCP protocol standards
  • Template Email Sending: Send emails using KeenMail templates with dynamic data

Installation

Using UVX (Recommended)

uvx keenmail-mcp-server

Using Docker (Recommended for Production)

# Quick start with Docker Compose
git clone <repository-url>
cd keenmail-mcp-server
cp .env.docker .env
# Edit .env with your API credentials
docker-compose up -d

Using pip

pip install keenmail-mcp-server

From source

git clone <repository-url>
cd keenmail-mcp-server
uv sync --dev
uv run python -m keenmail_mcp

Configuration

Set the following environment variables before running:

export KEENMAIL_API_KEY="your_api_key_here"
export KEENMAIL_SECRET="your_secret_key_here"
export KEENMAIL_BASE_URL="https://app.keenmail.com/api/v1"  # Optional, defaults to this
export KEENMAIL_PROVIDER_ID="amazonaws"  # Optional, default email provider
export KEENMAIL_FROM_EMAIL="mcp@optimoz.com"  # Optional, default sender email

Environment File (.env)

You can also create a .env file in your working directory:

KEENMAIL_API_KEY=your_api_key_here
KEENMAIL_SECRET=your_secret_key_here
KEENMAIL_BASE_URL=https://app.keenmail.com/api/v1
KEENMAIL_PROVIDER_ID=amazonaws
KEENMAIL_FROM_EMAIL=mcp@optimoz.com

Usage

With Docker (Recommended)

# Development mode
./scripts/docker-run.sh --dev --logs

# Production mode
./scripts/docker-run.sh --prod

# Build and run
./scripts/docker-run.sh --build --logs

With Docker Compose

# Development
cp .env.docker .env
# Edit .env with your credentials
docker-compose up -d

# Production
docker-compose -f docker-compose.prod.yml up -d

# View logs
docker-compose logs -f keenmail-mcp-server

With UVX

# Set environment variables
export KEENMAIL_API_KEY="your_key"
export KEENMAIL_SECRET="your_secret"

# Run the server
uvx keenmail-mcp-server

With Claude Desktop

Add to your Claude Desktop configuration file:

{
  "mcpServers": {
    "keenmail": {
      "command": "uvx",
      "args": ["keenmail-mcp-server"],
      "env": {
        "KEENMAIL_API_KEY": "your_api_key",
        "KEENMAIL_SECRET": "your_secret"
      }
    }
  }
}

Programmatically

from keenmail_mcp import create_server

server = create_server()
server.run(transport="stdio")

Available Tools

The MCP server exposes the following tools:

sendTemplateEmail

Send an email using a KeenMail template.

Parameters:

  • templateId (string): The ID of the email template
  • providerId (string): The email provider configuration ID
  • recipients (array): List of recipient objects with email details and template data

Example:

{
  "templateId": "welcome_email",
  "providerId": "ses_smtp_test",
  "recipients": [
    {
      "from": "sender@example.com",
      "to": "recipient@example.com",
      "data": {
        "userName": "John Doe",
        "companyName": "Example Corp"
      }
    }
  ]
}

Development

Requirements

  • Python 3.10+
  • uv (recommended) or pip

Setup

# Clone the repository
git clone <repository-url>
cd keenmail-mcp-server

# Install dependencies with uv
uv sync --dev

# Or with pip
pip install -e ".[dev]"

Running Tests

uv run pytest

Linting and Formatting

# Run ruff linter
uv run ruff check .

# Format code
uv run ruff format .

# Type checking
uv run mypy src/

Building

Python Package

uv build

Docker Image

# Quick build
./scripts/docker-build.sh

# Build with specific tag
./scripts/docker-build.sh --tag v0.1.0

# Multi-platform build and push
./scripts/docker-build.sh --platform linux/amd64,linux/arm64 --push --tag v0.1.0

Publishing

This package uses automated publishing through GitHub Actions:

  1. Create a version tag:

    # Update version in pyproject.toml first, then:
    uv version patch  # or minor, major
    git add .
    git commit -m "Bump version to $(uv version --dry-run patch)"
    git tag "v$(grep version pyproject.toml | cut -d'"' -f2)"
    git push origin main --tags
    
  2. Automatic publishing: The GitHub Action will automatically build and publish to PyPI when a version tag is pushed.

Manual Publishing

Python Package

# Build the package
uv build

# Publish to PyPI
uv publish

Docker Image

# Build and push to GitHub Container Registry
./scripts/docker-build.sh --push --tag v0.1.0

# Or manually with Docker
docker build -t ghcr.io/yourusername/keenmail-mcp-server:v0.1.0 .
docker push ghcr.io/yourusername/keenmail-mcp-server:v0.1.0

Docker Deployment

Quick Start

  1. Clone the repository:

    git clone <repository-url>
    cd keenmail-mcp-server
    
  2. Set up environment:

    cp .env.docker .env
    # Edit .env with your KeenMail API credentials
    
  3. Run with Docker Compose:

    # Development
    docker-compose up -d
    
    # Production
    docker-compose -f docker-compose.prod.yml up -d
    

Production Deployment

The production Docker setup includes:

  • Security hardening with non-root user and read-only filesystem
  • Resource limits and health checks
  • Log rotation and structured logging
  • Restart policies for high availability
  • Network isolation with custom bridge network
# Production deployment
cp .env.docker .env
# Configure production credentials
docker-compose -f docker-compose.prod.yml up -d

# Monitor
docker-compose -f docker-compose.prod.yml ps
docker-compose -f docker-compose.prod.yml logs -f

Container Registry

Images are automatically published to GitHub Container Registry:

  • ghcr.io/yourusername/keenmail-mcp-server:latest - Latest development build
  • ghcr.io/yourusername/keenmail-mcp-server:v0.1.0 - Specific version tags

License

MIT License - see LICENSE file for details.

Support

For issues and questions:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keenmail_mcp_server-0.1.2.tar.gz (93.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keenmail_mcp_server-0.1.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file keenmail_mcp_server-0.1.2.tar.gz.

File metadata

  • Download URL: keenmail_mcp_server-0.1.2.tar.gz
  • Upload date:
  • Size: 93.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.12

File hashes

Hashes for keenmail_mcp_server-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9ef38963f8e8195539ffea6c8c29384513599bf65bb821f01ac4727154a3c238
MD5 cf6b486b79c494bf3fd091663a196c11
BLAKE2b-256 db310b5219848003e13b851b752a453789637a694890e99b3cd48d089d53f4c5

See more details on using hashes here.

File details

Details for the file keenmail_mcp_server-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for keenmail_mcp_server-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3c2d88f69c4ecf70cd0d18a2bc4b95c78012bc64a87978a1d33b6e4901a9107b
MD5 4361ad0a02eed5e1d9db750807f1083a
BLAKE2b-256 3bb0bcc1bd2821dad6712254a9efada886bd315a351d31c4076078c03a18a13e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page