邮戳MCP服务器
用于Postmark电子邮件服务的MCP服务器实现。
特性
- 暴露一个模型上下文协议(MCP)服务器,用于通过Postmark发送电子邮件
- 通过环境变量进行简单配置
- 全面的错误处理和优雅的关机
- 安全的日志记录实践(无敏感数据泄露)
- 自动电子邮件跟踪配置
反馈
我们很乐意收到您的来信!请通过我们的 反馈表.
需求
- Node.js(建议使用v16或更高版本)
- 邮戳帐户和服务器令牌
设置
- 克隆存储库:
git clone https://github.com/ActiveCampaign/postmark-mcp
cd postmark-mcp- 安装依赖项:
npm install- 配置环境变量:
- 复制 .env.example 向 .env:
cp .env.example .env- 编辑 .env 并填写您的邮戳凭据和设置。
| 变量 | 描述 | 必填 |
|---|---|---|
| POSTMAR_SERVER_TOKEN | 您的POSTMARK服务器API令牌 | 是 |
| DEFAULT_SENDER_EMAIL | 默认发件人电子邮件地址 | 是 |
| DEFAULT_MESSAGE_STREAM | 邮戳消息流(例如“出站”) | 是 |
- 运行服务器:
npm start通过Cursor Deeplink快速安装
您可以通过单击以下按钮在Cursor中快速安装此MCP服务器:
备注:单击按钮后,您需要: 1. 设置您的POSTMARK_SERVER_TOKEN在MCP配置中 1. 设置您的DEFAULT_SENDER_EMAIL在MCP配置中 1. 设置您的DEFAULT_MESSAGE_STREAM在MCP配置中(默认为“出站”)
Claude和Cursor MCP配置示例
{
"mcpServers": {
"postmark": {
"command": "node",
"args": ["path/to/postmark-mcp/index.js"],
"env": {
"POSTMARK_SERVER_TOKEN": "your-postmark-server-token",
"DEFAULT_SENDER_EMAIL": "your-sender-email@example.com",
"DEFAULT_MESSAGE_STREAM": "your-message-stream"
}
}
}
}工具参考
本节提供了Postmark MCP服务器工具的完整参考,包括示例提示和每个工具的预期有效载荷。
目录
- send电子邮件 - sendEmailWithTemplate
- 列表模板
- 获取交货状态
电子邮件管理工具
1.发送电子邮件
发送一封短信电子邮件。
示例提示:
Send an email using Postmark to recipient@example.com with the subject "Meeting Reminder" and the message "Don't forget our team meeting tomorrow at 2 PM. Please bring your quarterly statistics report (and maybe some snacks).""预期有效载荷:
{
"to": "recipient@example.com",
"subject": "Meeting Reminder",
"textBody": "Don't forget our team meeting tomorrow at 2 PM. Please bring your quarterly statistics report (and maybe some snacks).",
"htmlBody": "HTML version of the email body", // Optional
"from": "sender@example.com", // Optional, uses DEFAULT_SENDER_EMAIL if not provided
"tag": "meetings" // Optional
}响应格式:
Email sent successfully!
MessageID: message-id-here
To: recipient@example.com
Subject: Meeting Reminder2.使用模板发送电子邮件
使用预定义的模板发送电子邮件。
示例提示:
Send an email with Postmark template alias "welcome" to customer@example.com with the following template variables:
{
"name": "John Doe",
"product_name": "MyApp",
"login_url": "https://myapp.com/login"
}预期有效载荷:
{
"to": "customer@example.com",
"templateId": 12345, // Either templateId or templateAlias must be provided, but not both
"templateAlias": "welcome", // Either templateId or templateAlias must be provided, but not both
"templateModel": {
"name": "John Doe",
"product_name": "MyApp",
"login_url": "https://myapp.com/login"
},
"from": "sender@example.com", // Optional, uses DEFAULT_SENDER_EMAIL if not provided
"tag": "onboarding" // Optional
}响应格式:
Template email sent successfully!
MessageID: message-id-here
To: recipient@example.com
Template: template-id-or-alias-here模板管理工具
3.列表模板
列出所有可用模板。
示例提示:
Show me a list of all the email templates available in our Postmark account.响应格式:
📋 Found 2 templates:
• Basic
- ID: 12345678
- Alias: basic
- Subject: none
• Welcome
- ID: 02345679
- Alias: welcome
- Subject: none统计和跟踪工具
4.获取交货状态
检索电子邮件传递统计信息。
示例提示:
Show me our Postmark email delivery statistics from 2025-05-01 to 2025-05-15 for the "marketing" tag.预期有效载荷:
{
"tag": "marketing", // Optional
"fromDate": "2025-05-01", // Optional, YYYY-MM-DD format
"toDate": "2025-05-15" // Optional, YYYY-MM-DD format
}响应格式:
Email Statistics Summary
Sent: 100 emails
Open Rate: 45.5% (45/99 tracked emails)
Click Rate: 15.2% (15/99 tracked links)
Period: 2025-05-01 to 2025-05-15
Tag: marketing实现细节
自动配置
所有电子邮件都会自动配置为:
TrackOpens: trueTrackLinks: "HtmlAndText"- 来自的消息流
DEFAULT_MESSAGE_STREAM环境变量
错误处理
服务器实现了全面的错误处理:
- 验证所有必需的环境变量
- SIGTERM和SIGINT的优雅关闭
- API调用的正确错误处理
- 日志中不暴露敏感信息
- 一致的错误消息格式
日志记录
- 使用适当的日志级别(
info对于正常操作,error错误) - 从日志中排除敏感信息
- 提供清晰的操作状态和结果
______________________________________________________________________
*有关API邮政标志的更多信息,请访问 Postmark的开发者文档.*
