MCP Email Server

MCP Email Server

An HTTP streaming MCP server for sending emails via Gmail using nodemailer, supporting HTML content and CC/BCC recipients.

Category
Visit Server

README

MCP Email Server (HTTP Streaming)

This is a test service. To ensure security, enable authentication.

An HTTP streaming MCP (Model Context Protocol) server for sending emails via Gmail. Deployable to Cloud Foundry or any Node.js hosting platform.

Features

  • HTTP streaming transport for remote MCP connections
  • MCP tool: send_email for sending emails
  • Support for To, CC, and BCC recipients
  • HTML body support
  • Cloud Foundry ready
  • Health check endpoint

Prerequisites

  • Node.js 22.x or higher
  • Gmail account with App Password enabled
  • Cloud Foundry CLI (for CF deployment)

Gmail Setup

To use this server, you need to generate a Gmail App Password:

  1. Go to your Google Account settings
  2. Navigate to Security → 2-Step Verification
  3. Scroll down to "App passwords"
  4. Generate a new app password for "Mail"
  5. Save the 16-character password

Installation

npm install

Local Development

  1. Set environment variables:
export GMAIL_USER=your-email@gmail.com
export GMAIL_PASSWORD=your-app-password
export PORT=3000
  1. Start the server:
npm start

The server will start on port 3000 (or PORT environment variable).

Endpoints:

  • Health check: http://localhost:3000/health
  • MCP endpoint: http://localhost:3000/mcp

Cloud Foundry Deployment

  1. Log in to Cloud Foundry:
cf login
  1. Set environment variables:
cf set-env mcp-email-server GMAIL_USER your-email@gmail.com
cf set-env mcp-email-server GMAIL_PASSWORD your-app-password
  1. Push the application:
cf push
  1. Get your app URL:
cf app mcp-email-server

Your MCP server will be available at: https://your-app.cfapps.io/mcp

MCP Client Configuration

Claude Desktop

Add to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "email": {
      "transport": "http",
      "url": "https://your-app.cfapps.io/mcp"
    }
  }
}

Claude Code CLI

Add to your MCP settings file (~/.claude/mcp_settings.json):

{
  "mcpServers": {
    "email": {
      "transport": "http",
      "url": "https://your-app.cfapps.io/mcp"
    }
  }
}

Custom MCP Client

Send POST requests to the MCP endpoint:

const response = await fetch('https://your-app.cfapps.io/mcp', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'tools/list',
    params: {}
  })
});

MCP Tool Usage

send_email

Send an email via Gmail with HTML support.

Required Parameters:

  • to (string): Recipient email address (comma-separated for multiple)
  • subject (string): Email subject line
  • body (string): Email body (HTML supported)

Optional Parameters:

  • cc (string): CC recipients (comma-separated)
  • bcc (string): BCC recipients (comma-separated)

Example Usage in Claude:

Send an email to john@example.com with subject "Meeting Tomorrow" and body "<h1>Reminder</h1><p>Don't forget our meeting at 2pm!</p>"

Claude will use the send_email tool to send the email through your deployed server.

API Endpoints

GET /health

Health check endpoint

Response:

{
  "status": "ok",
  "service": "mcp-email-server",
  "gmail_configured": true
}

POST /mcp

HTTP streaming endpoint for MCP protocol communication

This is the main endpoint that MCP clients connect to.

Request format:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/list",
  "params": {}
}

Tool Schema

{
  "name": "send_email",
  "description": "Send an email via Gmail. Supports HTML content in the body and optional CC/BCC recipients.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "to": {
        "type": "string",
        "description": "Recipient email address"
      },
      "subject": {
        "type": "string",
        "description": "Email subject line"
      },
      "body": {
        "type": "string",
        "description": "Email body content (HTML is supported)"
      },
      "cc": {
        "type": "string",
        "description": "CC recipients (comma-separated)"
      },
      "bcc": {
        "type": "string",
        "description": "BCC recipients (comma-separated)"
      }
    },
    "required": ["to", "subject", "body"]
  }
}

Testing

Test the health endpoint:

curl https://your-app.cfapps.io/health

Test listing tools:

curl -X POST https://your-app.cfapps.io/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/list",
    "params": {}
  }'

Test sending an email:

curl -X POST https://your-app.cfapps.io/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "send_email",
      "arguments": {
        "to": "recipient@example.com",
        "subject": "Test Email",
        "body": "<h1>Hello</h1><p>This is a test email.</p>"
      }
    }
  }'

Security Notes

  • Never commit your Gmail credentials to version control
  • Use Gmail App Passwords, not your regular password
  • Store credentials as environment variables in Cloud Foundry
  • Consider adding authentication/authorization for production use
  • Add rate limiting to prevent abuse
  • Use HTTPS in production (automatic with Cloud Foundry)

Architecture

The server uses:

  • Express - HTTP server
  • @modelcontextprotocol/sdk - MCP protocol implementation
  • nodemailer - Email sending functionality
  • HTTP streaming - For MCP communication via POST requests

Troubleshooting

Authentication Errors

  • Ensure 2-Step Verification is enabled on your Gmail account
  • Generate a new App Password specifically for this application
  • Verify environment variables: cf env mcp-email-server

Connection Issues

  • Verify the app is running: cf app mcp-email-server
  • Check logs: cf logs mcp-email-server --recent
  • Test the health endpoint

Email Not Sending

  • Check Cloud Foundry logs for errors
  • Verify Gmail credentials are correct
  • Ensure recipient addresses are valid

Monitoring

View logs:

cf logs mcp-email-server

View recent logs:

cf logs mcp-email-server --recent

Restart the app:

cf restart mcp-email-server

Scaling

Scale instances:

cf scale mcp-email-server -i 2

Scale memory:

cf scale mcp-email-server -m 512M

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured