mcp-email-tool
v1.0.0
Published
A Model Context Protocol (MCP) tool for sending emails
Downloads
3
Readme
MCP Email Tool
A Model Context Protocol (MCP) tool for sending emails using SMTP.
Installation
npm install mcp-email-toolUsage
Command Line
# Start the email tool with SMTP configuration
npx mcp-email-tool --host smtp.example.com --port 587 --user [email protected] --pass your_password --sender [email protected]
# Or using environment variables
export SMTP_HOST=smtp.example.com
export SMTP_PORT=587
export [email protected]
export SMTP_PASS=your_password
export [email protected]
npx mcp-email-toolProgrammatic Usage
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
async function sendEmail() {
const server = new McpServer({
name: "email-client",
version: "1.0.0",
});
const transport = new StdioServerTransport();
await server.connect(transport);
try {
const result = await server.invoke("send-email", {
to: "[email protected]",
subject: "Test Email",
text: "This is a test email",
html: "<p>This is a test email</p>",
cc: ["[email protected]"],
bcc: ["[email protected]"],
replyTo: ["[email protected]"]
});
console.log("Email sent successfully:", result);
} catch (error) {
console.error("Error sending email:", error);
}
await transport.close();
}Configuration
The tool can be configured using either command-line arguments or environment variables:
Command Line Arguments
--host: SMTP host (default: smtp.example.com)--port: SMTP port (default: 587)--secure: Use secure connection (default: false)--user: SMTP username--pass: SMTP password--sender: Default sender email address
Environment Variables
SMTP_HOST: SMTP hostSMTP_PORT: SMTP portSMTP_SECURE: Use secure connectionSMTP_USER: SMTP usernameSMTP_PASS: SMTP passwordSENDER_EMAIL_ADDRESS: Default sender email address
Email Parameters
The tool accepts the following parameters when sending an email:
to: Recipient email address (required)subject: Email subject (required)text: Plain text email content (required)html: HTML email content (optional)cc: Array of CC email addresses (optional)bcc: Array of BCC email addresses (optional)replyTo: Array of reply-to email addresses (optional)from: Sender email address (optional, uses default if not provided)
License
MIT
