SMTP-EDC now includes Model Context Protocol (MCP) server support, enabling AI assistants and other MCP clients to interact with SMTP functionality through a standardized protocol.
The Model Context Protocol (MCP) is an open-source protocol that standardizes how applications and AI models interact with external context, tools, and data sources. It provides a modular client-server architecture for dynamic integration of capabilities into AI-driven workflows.
The MCP server can be started in two modes:
# Start MCP server with STDIO transport
smtp-edc mcp-server -transport stdio
# With debug logging
smtp-edc mcp-server -transport stdio -debug
# Start MCP server with HTTP transport on default port 8080
smtp-edc mcp-server -transport http
# Custom port
smtp-edc mcp-server -transport http -port 9090
# With debug logging
smtp-edc mcp-server -transport http -debug
MCP server can be configured using a JSON configuration file. Create a mcp-config.json
file:
{
"transport": {
"type": "stdio",
"http": {
"port": 8080,
"host": "localhost",
"enableCors": true,
"enableHttps": false
}
},
"server": {
"name": "smtp-edc-mcp",
"version": "1.0.0",
"description": "SMTP-EDC Model Context Protocol Server",
"debug": false,
"maxClients": 10,
"timeout": 30
},
"security": {
"requireAuth": false,
"apiKeys": [],
"allowedIps": ["127.0.0.1", "::1"]
}
}
The MCP server exposes the following tools for SMTP operations:
Test SMTP server connection and capabilities.
Parameters:
server
(string, required): SMTP server hostname or IPport
(integer): SMTP server port (default: 587)username
(string): Authentication usernamepassword
(string): Authentication passwordauthType
(string): Authentication type (plain, login, cram-md5)starttls
(boolean): Use STARTTLSskipVerify
(boolean): Skip TLS certificate verificationExample:
{
"tool": "smtp_test_connection",
"arguments": {
"server": "smtp.gmail.com",
"port": 587,
"username": "user@gmail.com",
"password": "app-password",
"authType": "plain",
"starttls": true
}
}
Send an email via SMTP.
Parameters:
server
(string, required): SMTP server hostname or IPport
(integer): SMTP server port (default: 587)username
(string): Authentication usernamepassword
(string): Authentication passwordfrom
(string, required): Sender email addressto
(array, required): Recipient email addressescc
(array): CC recipient email addressesbcc
(array): BCC recipient email addressessubject
(string, required): Email subjectbody
(string, required): Email body (text or HTML)isHTML
(boolean): Whether the body is HTMLauthType
(string): Authentication typestarttls
(boolean): Use STARTTLSskipVerify
(boolean): Skip TLS certificate verificationExample:
{
"tool": "smtp_send_email",
"arguments": {
"server": "smtp.gmail.com",
"port": 587,
"username": "sender@gmail.com",
"password": "app-password",
"from": "sender@gmail.com",
"to": ["recipient@example.com"],
"subject": "Test Email",
"body": "This is a test email sent via MCP.",
"authType": "plain",
"starttls": true
}
}
Validate email addresses and optionally check MX records.
Parameters:
addresses
(array, required): Email addresses to validatecheckMX
(boolean): Check MX records for domainsExample:
{
"tool": "smtp_validate_addresses",
"arguments": {
"addresses": ["test@example.com", "invalid-email"],
"checkMX": true
}
}
Load and process an email template.
Parameters:
templateName
(string, required): Name of the template to loadvariables
(object): Variables to substitute in the templateExample:
{
"tool": "smtp_load_template",
"arguments": {
"templateName": "welcome",
"variables": {
"name": "John Doe",
"company": "Example Corp"
}
}
}
The MCP server provides access to the following resources:
Returns the current SMTP-EDC configuration settings.
Returns a list of available email templates.
Returns authentication attempt statistics.
To use SMTP-EDC with Claude Desktop, add the following to your Claude Desktop configuration:
{
"mcpServers": {
"smtp-edc": {
"command": "smtp-edc",
"args": ["mcp-server", "-transport", "stdio"],
"env": {}
}
}
}
For custom MCP client implementations, connect to the server using either:
http://localhost:8080
)requireAuth
in the configuration to require API key authenticationAuthorization
headerallowedIps
to restrict access to specific IP addresses# Python example using MCP client
import mcp_client
client = mcp_client.connect("stdio", ["smtp-edc", "mcp-server"])
result = client.call_tool("smtp_test_connection", {
"server": "smtp.gmail.com",
"port": 587,
"username": "test@gmail.com",
"password": "app-password",
"starttls": True
})
print(result)
// JavaScript example using MCP client
const mcp = require('mcp-client');
const client = await mcp.connect('http', 'http://localhost:8080');
const result = await client.callTool('smtp_send_email', {
server: 'smtp.gmail.com',
port: 587,
from: 'sender@gmail.com',
to: ['recipient@example.com'],
subject: 'Test Email',
body: 'Hello from MCP!',
username: 'sender@gmail.com',
password: 'app-password',
starttls: true
});
console.log(result);
requireAuth
setting matches client expectationsEnable debug mode for detailed logging:
smtp-edc mcp-server -debug
For detailed API documentation and protocol specifications, refer to:
To contribute to the MCP integration:
The MCP integration is part of SMTP-EDC and is licensed under the MIT License.