内容
# 重发电子邮件 MCP
**最完整的 [重发](https://resend.com) MCP 服务器** — 完全覆盖重发 API(电子邮件、域名、联系人、广播、模板、细分、主题、网络钩子、日志) **以及独特的调试/诊断层**,其他重发 MCP 不提供:投递能力分析、DNS 故障排除、电子邮件生命周期检查、退信解释和账户审计。
与 **Claude Code、Cursor、Claude Desktop** 和任何其他 MCP 客户端配合使用。
[](https://www.npmjs.com/package/resend-email-mcp)
[](LICENSE)
[](https://github.com/helbertparanhos/resend-email-mcp/stargazers)
[](https://github.com/helbertparanhos/resend-email-mcp/network/members)
[](https://github.com/helbertparanhos/resend-email-mcp/issues)
[](https://glama.ai/mcp/servers/helbertparanhos/resend-email-mcp)
[](https://www.typescriptlang.org/)
[](https://nodejs.org/)
[](https://modelcontextprotocol.io/)
[](https://claude.ai/code)
[](https://cursor.sh)
[](https://claude.ai/download)
[](https://www.instagram.com/helbertparanhos)
[](https://www.youtube.com/@stratacademy)
[](https://www.linkedin.com/in/helbert-paranhos/)
[](https://buymeacoffee.com/helbertparanhos)
[](https://stratacademy.com.br)
---
## 为什么选择这个 MCP
| | resend-email-mcp | 官方 `resend-mcp` | 最小化 MCP |
|---|:---:|:---:|:---:|
| 发送 / 批量 / 调度 | ✅ | ✅ | 部分 |
| 域名、联系人、广播、模板、细分、主题、网络钩子 | ✅ | ✅ | ❌ |
| API 请求 **日志** 工具 | ✅ | ❌ | ❌ |
| **调试层** (诊断、分析、检查、解释、审计) | ✅ **7 种工具** | ❌ | ❌ |
| 只读安全模式 | ✅ | ❌ | ❌ |
| 新端点的原始逃生口 | ✅ | ❌ | ❌ |
| 幂等键支持 | ✅ | 部分 | ❌ |
**75 种工具 + 2 种资源。**
---
## 快速开始
### 1. 获取重发 API 密钥
在 **https://resend.com/api-keys** 上创建一个。
### 2. 添加到您的 MCP 客户端
#### Claude Code (CLI)
```bash
claude mcp add resend -e RESEND_API_KEY=re_xxxxxxxx -- npx -y resend-email-mcp
```
#### Cursor / Claude Desktop / 通用 (`mcp.json` / `claude_desktop_config.json`)
```json
{
"mcpServers": {
"resend": {
"command": "npx",
"args": ["-y", "resend-email-mcp"],
"env": {
"RESEND_API_KEY": "re_xxxxxxxx",
"RESEND_FROM": "Acme <hello@acme.com>"
}
}
}
}
```
配置文件位置:
- **Claude Desktop (Windows):** `%APPDATA%\Claude\claude_desktop_config.json`
- **Claude Desktop (macOS):** `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Cursor:** `~/.cursor/mcp.json`(或项目特定的 `.cursor/mcp.json`)
重启客户端并询问: *"向 delivered@resend.dev 发送测试电子邮件"* 或 *"审计我的重发账户。"*
---
## 配置
| 环境变量 | 必需 | 描述 |
|---------|:---:|-------------|
| `RESEND_API_KEY` | ✅ | 您的重发 API 密钥 |
| `RESEND_FROM` | – | `send_email` 默认发件人(当省略 `from` 时)(必须是已验证的域名) |
| `RESEND_REPLY_TO` | – | 默认回复地址 |
| `RESEND_READONLY` | – | `true` 阻止所有变更工具(发送/创建/更新/删除)。安全探索生产环境 |
| `RESEND_ATTACHMENTS_DIR` | – | `send_email` 的 `localPath` 附件被限制到的目录。**未设置 = 禁用磁盘读取**(安全默认值;阻止路径遍历) |
| `RESEND_BASE_URL` | – | 重写 API 基本 URL(默认为 `https://api.resend.com`)。必须是 https(仅 localhost 支持 http) |
| `RESEND_MAX_RETRIES` | – | 429/5xx 重试(默认为 `3`) |
---
## 工具
### 电子邮件
`send_email` · `send_batch_emails` · `get_email` · `list_emails` · `update_email` · `cancel_email` · `preview_email`
> `send_email` 接受 base64 `content`、公共 `path`(URL)或 **`localPath`**(磁盘上的文件,自动读取和 base64 编码 - 仅在设置 `RESEND_ATTACHMENTS_DIR` 且限制在该目录内时启用)附件。`preview_email` 预览消息 - 解析最终发件人、调整附件大小并显示警告 - **不发送**。
### 附件(已发送和接收)
`list_email_attachments` · `get_email_attachment` · `list_received_emails` · `get_received_email` · `list_received_attachments` · `get_received_attachment`
### 域名
`create_domain` · `get_domain` · `list_domains` · `update_domain` · `delete_domain` · `verify_domain`
### API 密钥
`create_api_key` · `list_api_keys` · `delete_api_key`
### 广播
`create_broadcast` · `get_broadcast` · `list_broadcasts` · `update_broadcast` · `send_broadcast` · `delete_broadcast`
### 联系人
`create_contact` · `get_contact` · `list_contacts` · `update_contact` · `delete_contact` · `get_contact_topics` · `update_contact_topics` · `list_contact_segments` · `add_contact_to_segment` · `remove_contact_from_segment`
### 联系人属性
`create_contact_property` · `get_contact_property` · `list_contact_properties` · `update_contact_property` · `delete_contact_property`
### 分段
`create_segment` · `get_segment` · `list_segments` · `delete_segment` · `list_segment_contacts`
### 模板
`create_template` · `get_template` · `list_templates` · `update_template` · `delete_template` · `publish_template` · `duplicate_template`
### 主题
`create_topic` · `get_topic` · `list_topics` · `update_topic` · `delete_topic`
### 网络钩子
`create_webhook` · `get_webhook` · `list_webhooks` · `update_webhook` · `delete_webhook`
### 日志
`list_logs` · `get_log`
### 🔍 调试和诊断(差异化)
| 工具 | 功能 |
|------|--------------|
| `diagnose_domain` | 检查每个 DNS 记录(SPF/DKIM/DMARC)并报告缺少的内容 + 如何修复 |
| `analyze_deliverability` | 聚合最近的发送到交付/退信/投诉率,并提供健康评估 |
| `inspect_email` | 渲染单个电子邮件的完整生命周期时间线并标记问题 |
| `explain_bounce` | 分类退信(硬/软/阻止)并建议操作 |
| `audit_account` | 域名、密钥和投递能力的单次健康检查 |
| `search_logs` | 按状态/路径/收件人智能过滤 API 日志以查找失败 |
| `test_send` | 安全模拟通过重发沙盒地址交付/退信/投诉 |
### 逃生口
`resend_raw` — 调用任何尚未在专用工具中封装的重发端点。
## 资源
除了工具外,服务器还公开了两个只读 **MCP 资源**,以便客户端可以提取账户上下文而无需花费工具调用:
| URI | 内容 |
|-----|---------|
| `resend://account` | 域名 + API 密钥快照 |
| `resend://domains` | 所有具有验证状态的发送域名 |
每个工具都带有 MCP 提示(`readOnlyHint`、`destructiveHint`、`idempotentHint`),以便客户端可以显示哪些操作是安全的,哪些需要确认。
---
## 示例提示
- *"诊断为什么 acme.com 未被验证。"* → `diagnose_domain`
- *"我的电子邮件发送本周健康状况如何?"* → `analyze_deliverability`
- *"re_abc123 电子邮件发生了什么?"* → `inspect_email`
- *"为什么那封电子邮件退信了,我该怎么办?"* → `explain_bounce`
- *"我的重发设置可能有问题 - 检查一切。"* → `audit_account`
- *"向 'beta' 分段发送我们的启动新闻通讯。"* → `create_broadcast` + `send_broadcast`
---
## 安全测试
使用重发的沙盒地址(无声誉影响):
- `delivered@resend.dev` — 模拟投递
- `bounced@resend.dev` — 模拟硬退信
- `complained@resend.dev` — 模拟垃圾邮件投诉
或者运行 `test_send` 然后对返回的 ID 运行 `inspect_email`。
启用 `RESEND_READONLY=true` 以在不发送或删除任何内容的情况下探索生产账户。
---
## 故障排除
该 MCP 旨在自我调试 - 当出现故障时,请使用诊断工具而不是猜测。
| 症状/错误 | 可能原因 | 运行什么 |
|-----------------|--------------|-------------|
| `validation_error: from domain is not verified` | 您的 `from`/`RESEND_FROM` 域名未验证 | `list_domains` → `diagnose_domain`(显示缺少的 DNS 记录 + 修复)→ `verify_domain` |
| 电子邮件发送但从未到达 | 投递能力/声誉问题 | `analyze_deliverability` 然后对样本 ID 运行 `inspect_email` |
| `missing_api_key` / `invalid_api_key`(HTTP 401) | `RESEND_API_KEY` 未设置或错误 | 检查 `.env`;在 resend.com/api-keys 上创建密钥 |
| `restricted_api_key` / `not_authorized`(403) | 密钥范围仅限于发送或单个域名 | 使用 `full_access` 密钥(检查 `list_api_keys`) |
| `rate_limit_exceeded`(429) | 请求过多 | 客户端自动重试并退后;减少流量 |
| `daily_quota_exceeded` | 计划发送限制达到 | 升级计划或等待重置 |
| 特定电子邮件退信 | 无效/阻止收件人 | `explain_bounce`(分类硬/软/阻止 + 操作) |
| "我的设置有问题吗?" | — | `audit_account`(一次性健康检查) |
| 请求因未知原因失败 | — | `search_logs` 并设置 `only_errors: true` |
服务器返回的每个错误都包含 HTTP 状态、重发错误名称和可行的 **提示** 行。
---
## 本地开发
```bash
git clone https://github.com/helbertparanhos/resend-email-mcp.git
cd resend-email-mcp
npm install
npm run build
cp .env.example .env # 添加您的 RESEND_API_KEY
npm run inspector # 在构建的服务器上打开 MCP Inspector
```
---
## 许可证
MIT © [Helbert Paranhos / 战略学院](https://stratacademy.com.br)
使用 [模型上下文协议](https://modelcontextprotocol.io) 构建。 与重发无关。