smtp-mcp-server

smtp-mcp-server

3.2

If you are the rightful owner of smtp-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The MCP SMTP Email Server is a secure, bearer-authenticated email tool designed for use within the 365-SACU infrastructure, leveraging FastAPI and MCP technology for dynamic email generation.

MCP SMTP Email Server

A secure, bearer-authenticated email tool designed for use within the 365-SACU infrastructure. This project exposes a simple FastAPI server with integrated MCP tooling, allowing it to be used with OpenWebUI, Claude Desktop, or CLI for dynamic email generation.


Features

  • FastAPI server with bearer token authentication
  • MCP Tool support for OpenWebUI integration
  • /send_email endpoint for dynamic mail delivery
  • Swagger UI (/docs) with token-based access

Files

FilePurpose
main.pyLaunches FastAPI app, loads MCP tools, exposes routes
mcp_email.pyDefines send_email tool logic + schema
config.pyStores the bearer token and email credentials

Requirements

  • Python 3.11+
  • SMTP server access (e.g., Office365, Gmail, Mailjet)
  • MCP environment: mcpo
  • Dependencies: fastapi, pydantic, smtplib, email, uvicorn

Setup

1. Clone & Install

git clone https://github.com/yourname/365-sacu-email-server
cd 365-sacu-email-server
uv pip install -r requirements.txt

2. Configure

Edit config.py:

MCP_BEARER_TOKEN = "your-secret-token"
SMTP_SERVER = "smtp.office365.com" # i used office 365 for my SMTP, I know M$ Graph exists but that is besides the point. If it truly is better than SMTP let me know...
SMTP_PORT = 587
FROM_ADDRESS = "bot@sacu365.org"
SMTP_USERNAME = "bot@sacu365.org"
SMTP_PASSWORD = "your-email-password"

3. Run

uvicorn main:app --host 0.0.0.0 --port 8020

Then visit: http://localhost:8020/docs


Endpoint

POST /send_email

{
  "to": "you@domain.com",
  "subject": "Test Email",
  "body": "Hello from MCP Email Server"
}

This tool sends an email using your configured SMTP settings.


MCP Integration

To register this tool in OpenWebUI:

URL: http://<host>:8020/openapi.json
Auth: Bearer <your-token>

Then call:

await send_email({"to": ..., "subject": ..., "body": ...})

Architecture

  • MCP tools registered with @mcp.tool()
  • send_email function reads credentials from config and sends via smtplib
  • FastAPI wraps it in a secure route with token enforcement
  • Swagger UI auto-generates schema for OpenWebUI usage

License

MIT. Use freely within your own infrastructure or projects.