关于 resend-integration-skills
resend-integration-skills 是一份面向使用编码 Agent 的 Resend 邮件集成指南,涵盖 MCP 服务构建、配置和验证。它说明如何在 GitHub Copilot、VS Code、Cursor 和 Claude Desktop 中接入邮件功能。
主要功能
- 01构建 Resend MCP 服务
- 02配置多种 MCP 客户端
- 03发送及预约邮件
- 04管理邮件受众和广播
- 05提供密钥与域名配置建议
适用场景
- 01为编码 Agent 配置 Resend 邮件发送
- 02在本地或 GitHub Copilot 环境测试邮件
- 03向受众发送营销广播
- 04排查 MCP 连接和认证问题
MCP 相关
指南介绍 Resend MCP 服务及其在客户端中的配置方式。该服务向 LLM 和 Agent 提供发送、预约邮件以及受众管理等工具。
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ gocallum/ nextjs16-agent-skills --skill resend-integration-skills安装后在 Claude Code 中输入/resend-integration-skills确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
README.mdreferences/CONFIGURATION.mdEXAMPLES.mdscripts/setup-resend-mcp.sh详细介绍
链接
- Resend 官方网站:https://resend.com
- Resend API 文档:https://resend.com/docs/api-reference
- Resend MCP 服务:https://resend.com/docs/knowledge-base/mcp-server
- Resend MCP GitHub 仓库:https://github.com/resend/mcp-send-email
- MCP 协议规范:https://modelcontextprotocol.io
- GitHub MCP 注册表:https://github.com/mcp
- VS Code Insider 设置:https://code.visualstudio.com/insiders
快速入门
1. 前置条件
- Node.js 20 或更高版本(必需 — MCP 服务指定了
engines: { "node": ">=20" }) - Resend 账户(可在 https://resend.com 免费注册)
- 已启用 Agent 模式的 GitHub Copilot Pro 或 Cursor
- VS Code Insider(完整支持 MCP 所必需)
- npm 或 pnpm 包管理器
2. 克隆并构建 Resend MCP 服务
# Clone the Resend MCP server repository
git clone https://github.com/resend/mcp-send-email.git
cd mcp-send-email
# Install dependencies (npm or pnpm both supported)
npm install
# or if you prefer pnpm:
# pnpm install
# Build the project (TypeScript compilation + executable permissions)
npm run build
构建过程:
- 将 TypeScript 编译为 JavaScript
- 为构建后的脚本设置可执行权限(Unix/macOS)
- 创建 MCP 服务可执行文件
build/index.js
3. 创建 Resend API 密钥
- 访问 https://resend.com/api-keys
- 创建新的 API 密钥
- 将密钥复制到剪贴板(配置时需要用到)
4.(可选)验证域名
如需从自定义域名发送邮件:
- 前往 https://resend.com/domains
- 添加并验证域名
- 使用
--sender标志更新 MCP 配置(参见“配置”部分)
5. 为客户端配置 MCP
根据你的 GitHub Copilot 套餐选择配置方式:
对于 GitHub Copilot 编码 Agent(仓库级配置):
这是推荐的团队协作方式。仓库管理员在仓库级别配置 MCP 服务。
- 在 GitHub.com 上打开你的仓库
- 前往 Settings → Copilot → Coding agent
- 添加以下 JSON 配置:
{
"mcpServers": {
"resend": {
"type": "local",
"command": "node",
"args": ["/absolute/path/to/mcp-send-email/build/index.js"],
"env": {
"RESEND_API_KEY": "COPILOT_MCP_RESEND_API_KEY"
},
"tools": ["*"]
}
}
}
-
设置 Copilot 环境:
- 前往 Settings → Environments
- 创建名为
copilot的新环境 - 添加密钥:
COPILOT_MCP_RESEND_API_KEY,值为你的 API 密钥
-
点击 Save,Copilot 将验证配置
对于 VS Code 本地开发(开发者配置):
如果你在本地开发或更倾向于使用 VS Code 配置:
- 在项目根目录创建
.vscode/mcp.json:
{
"servers": {
"resend": {
"type": "command",
"command": "node",
"args": ["/absolute/path/to/mcp-send-email/build/index.js"],
"env": {
"RESEND_API_KEY": "re_xxxxxxxxxxxxxx"
}
}
}
}
- 获取
build/index.js的绝对路径:- 在 VS Code 中右键点击
build/index.js→ Copy Path
- 在 VS Code 中右键点击
对于 Cursor Agent 模式:
打开 Cursor 设置(Cmd+Shift+P → "Cursor Settings"),并将以下内容添加到 MCP 配置中:
{
"mcpServers": {
"resend": {
"type": "command",
"command": "node /absolute/path/to/mcp-send-email/build/index.js --key=re_xxxxxxxxxxxxxx"
}
}
}
对于 Claude Desktop:
- 打开 Claude Desktop 设置
- 前往 Developer 标签页 → Edit Config
- 添加配置:
{
"mcpServers": {
"resend": {
"command": "node",
"args": ["/absolute/path/to/mcp-send-email/build/index.js"],
"env": {
"RESEND_API_KEY": "re_xxxxxxxxxxxxxx",
"SENDER_EMAIL_ADDRESS": "[email protected]",
"REPLY_TO_EMAIL_ADDRESS": "[email protected]"
}
}
}
}
6. 使用 email.md 模式测试连接
Resend 官方仓库包含使用 email.md 文件的测试模式:
-
在项目中创建
email.md:to: [email protected] subject: Test from Resend MCP content: This is a test email. Hello! This is a test email sent via Resend MCP. # You can also test CC and BCC: # cc: [email protected] # bcc: [email protected] -
在 Cursor 中(启用 Agent 模式):
- 打开
email.md文件 - 选择全部文本(
Cmd+A/Ctrl+A) - 按
Cmd+L/Ctrl+L(或使用上下文菜单) - 告诉 Cursor:“将此内容作为邮件发送”或“使用 resend MCP 发送此邮件”
- 确保处于 Agent 模式(在聊天下拉菜单中切换)
- 打开
-
在 Claude Desktop 中:
- 在聊天中粘贴 email.md 的内容
- 请 Claude 发送:“使用 resend 工具发送此邮件”
-
在 GitHub Copilot 中:
- 打开 email.md 文件
- 在聊天中引用它:“@email.md 使用 resend 发送此邮件”
如果配置正确,邮件将立即发送,你也会收到确认信息。
核心概念
MCP 配置类型
使用 GitHub Copilot 配置 Resend MCP 主要有两种方式:
1. GitHub Copilot 编码 Agent(仓库级)
- 在 GitHub 仓库设置中配置(需要仓库管理员权限)
- 将 Copilot 任务分配给 GitHub issue 时使用
- 需要明确指定
tools数组,列出 Copilot 可使用的工具 - API 密钥存储为 GitHub Actions secrets(前缀为
COPILOT_MCP_) - 可自主执行,无需审批(需考虑安全因素)
2. VS Code 本地开发
- 在
.vscode/mcp.json中配置(本地开发者设置) - 用于使用 VS Code Insider 进行本地开发
- API 密钥直接存储在配置中或环境变量中
- 更适合个人开发者或测试
Resend MCP 服务
Resend MCP 服务是一个本地 Node.js 应用,可将 Resend 的电子邮件功能作为工具提供给大模型。它实现了 Model Context Protocol,使 AI Agent 能够:
- 发送电子邮件:通过自然语言命令发送(纯文本或 HTML)
- 安排电子邮件发送时间:计划未来发送
- 添加收件人(To、CC、BCC)
- 配置发件人信息(From、Reply-To)
- 向受众细分群体群发电子邮件
- 管理受众:列出 Resend 受众,以便定向发送
- 支持 HTML 和纯文本电子邮件正文
近期新增内容(截至 2026 年初):
- 用于营销活动的群发和受众管理工具
- 通过 Zod schemas 改进错误处理和验证
MCP 配置方法
运行 Resend MCP 服务有三种方式:
- Command 类型(VS Code/Cursor):通过内联参数直接执行 Node.js
- Stdio 类型(Claude Desktop):服务通过环境变量处理 I/O
- HTTP 类型(远程/云端):通过 HTTP 端点公开服务
GitHub Copilot 编码 Agent 专项说明
对于 GitHub Copilot 编码 Agent(基于仓库的设置):
-
必须配置
tools数组:指定 Copilot 可使用 Resend MCP 服务中的哪些工具- 使用
"tools": ["send_email", "schedule_email", ...]将特定工具加入允许列表 - 使用
"tools": ["*"]启用所有工具 - 使用 MCP 服务文档中的特定工具名称
- 使用
-
无需审批:配置完成后,Copilot 将自主使用这些工具,无需询问
-
安全注意事项:Copilot 将通过配置的工具自动访问 Resend API,因此只启用所需的工具
-
环境变量处理:API 密钥必须以
COPILOT_MCP_为前缀,存储为 GitHub Actions secrets- 在配置中引用为
"COPILOT_MCP_RESEND_API_KEY"(不含密钥值) - GitHub 会自动将密钥值传递给 MCP 服务
- 在配置中引用为
身份验证
Resend MCP 服务需要:
- RESEND_API_KEY(必需):你的 Resend API 密钥,获取地址为 https://resend.com/api-keys
- SENDER_EMAIL_ADDRESS(可选):已验证域名的电子邮件地址。如果未设置,AI 将提示你输入
- REPLY_TO_EMAIL_ADDRESS(可选):用于 Reply-To 标头的电子邮件地址
已验证的域名
默认情况下,Resend 允许使用测试域名 [email protected] 向你自己的账户邮箱发送电子邮件。若要发送到其他地址:
- 用于测试:使用默认发件人
[email protected](无需验证) - 使用自定义域名:在 https://resend.com/domains 验证你的域名
- 使用已验证的域名创建发件人邮箱
- 在 MCP 环境变量中配置该邮箱(
SENDER_EMAIL_ADDRESS)
注意:如果未提供 SENDER_EMAIL_ADDRESS,每次发送电子邮件时,MCP 服务都会提示你输入。
代码示例
示例 1:通过 Copilot Chat 发送简单电子邮件
在启用了 GitHub Copilot Agent 模式的 VS Code Insider 中:
@workspace I need to send a notification email to [email protected] about the project completion. Use the resend MCP tool to send "Project ABC is now live" as the email body.
示例 2:使用自定义配置发送 HTML 电子邮件
Send an HTML email to [email protected] with subject "Monthly Report" and body formatted as an HTML table showing Q1 metrics. Use Resend MCP to send it.
示例 3:发送包含 CC/BCC 的电子邮件
Send an email from [email protected] to [email protected] CC'ing [email protected] about account activation. Use Resend MCP.
示例 4:安排电子邮件发送时间
Schedule an email to be sent tomorrow at 9 AM using Resend MCP, reminding the team about the standup meeting.
示例 5:与数据处理集成
Read the CSV file users.csv, extract the top 10 active users with their emails, and send each a personalized thank you email using Resend MCP. Include their usage statistics in the email.
高级功能
群发邮件
向 Resend 账户中的受众群组发送邮件:
Send a broadcast email to my 'premium_users' audience with subject 'New Feature Release' using Resend MCP
受众管理
查询和管理受众:
List all my audiences in Resend using the MCP tool
最佳实践
GitHub Copilot 编码 Agent 安全
重要:为 GitHub Copilot 编码 Agent 配置 Resend MCP 时:
-
工具白名单——仅启用 Copilot 需要的特定工具:
"tools": ["send_email", "schedule_email"]而不是通过
"*"启用所有工具 -
密钥管理——切勿将 API 密钥提交到版本控制中
- 将 API 密钥存储为 GitHub Actions 密钥(Settings → Environments)
- 密钥名称必须以
COPILOT_MCP_开头 - 在配置中按名称引用密钥
-
限定 API 密钥的权限范围——如果可用,可考虑使用受限的 Resend API 密钥
-
检查 Copilot 的操作——检查 Copilot 创建的拉取请求,确认邮件发送方式恰当
-
环境隔离——使用
copilot环境管理哪些仓库/工作流可以访问邮件发送功能
配置管理
-
开发时使用
.env.local:# .env.local (not committed) RESEND_API_KEY=re_test_xxx [email protected] -
为不同环境分别配置:
- 开发环境:测试 API 密钥、有限的收件人
- 生产环境:完整 API 密钥、允许所有收件人
-
在
README.md中记录必需的环境变量:## Environment Variables - RESEND_API_KEY: Resend API key (required) - SENDER_EMAIL_ADDRESS: Verified sender email (optional) - REPLY_TO_EMAIL_ADDRESS: Reply-to email (optional)
邮件内容
- 营销邮件始终包含退订链接
- 使用多个邮件客户端测试邮件(Gmail、Outlook、Apple Mail)
- 确保模板适配移动设备
- 使用清晰的主题行说明邮件用途
- 为 HTML 邮件提供纯文本替代内容,方便无障碍访问
AI Agent 用法
- 提供上下文,说明邮件应发送给哪些人
- 在初始设置中指定发件人信息
- 发送前检查 AI 生成的邮件内容
- 对于需要多个步骤的复杂工作流,使用 Agent 模式
- 先向自己的邮箱发送测试邮件,再发送给其他人
故障排除
问题:“Node 版本过旧”或“需要 Node 20+”
解决方案:检查并更新 Node.js 版本
node --version # Should be v20.0.0 or higher
- 从 https://nodejs.org 安装 Node.js 20+(推荐 LTS 版本)
- macOS:
brew install node@20(如果使用 Homebrew) - Windows:从 https://nodejs.org 下载或使用
nvm-windows - Linux:运行
nvm install 20或使用包管理器 - 验证:
node --version应显示v20.x.x或更高版本 - 安装后重启终端/IDE
问题:“找不到命令:node”
解决方案:Node.js 尚未安装或不在 PATH 中
- 从 https://nodejs.org 安装 Node.js(需要 20+ 版本)
- 验证安装:
node --version - 安装后重启终端/IDE
问题:“需要 RESEND_API_KEY”
解决方案:未提供 API 密钥或密钥无效
- 在 https://resend.com/api-keys 生成新密钥
- 确保密钥以
re_开头 - 检查 MCP 配置中的环境变量名称是否正确
- 确认密钥中没有多余的空格
问题:“邮件未送达 / 401 未授权”
解决方案:身份验证或域名验证问题
- 确认 API 密钥正确且有效
- 在 https://resend.com/domains 检查域名是否已验证
- 确保发件人邮箱与已验证的域名匹配
- 在 Resend 控制面板中检查是否存在速率限制或投递错误
问题:“npm run build”期间构建命令失败
解决方案:依赖项或 TypeScript 编译错误
# Clear and reinstall dependencies
rm -rf node_modules package-lock.json
npm install
npm run build
常见构建错误:
- TypeScript 编译错误:检查是否已安装所有依赖项
- Unix/macOS 上权限被拒绝:构建脚本包含
chmod +x——尝试从其他目录运行 - 找不到模块:删除
node_modules并重新安装
问题:“IDE 工具列表中未显示 MCP 服务”
解决方案:配置或服务启动问题
GitHub Copilot:
- 确认
.vscode/mcp.json位于项目根目录(而非子目录中) - 检查
build/index.js的绝对路径是否正确 - 重新加载 VS Code 窗口(macOS 上按 Cmd+R,Windows 上按 Ctrl+R)
- 确认已启用 Agent 模式(在聊天中切换)
Cursor:
- 打开 Cursor 设置(Cmd+Shift+P → “Cursor Settings”)
- 转到 MCP 标签页
- 确认配置语法为有效的 JSON
- 检查绝对路径是否存在且可读
- 重启 Cursor 应用
Claude Desktop:
- 完全关闭 Claude
- 确认
claude_desktop_config.json语法正确 - 检查
build/index.js文件是否存在 - 重新打开 Claude Desktop
- 在“开发者”标签页中检查 resend 工具
问题:“发送邮件正常,但 AI 不会主动使用 Resend MCP”
解决方案:Agent 模型或模式问题
- 切换到 Claude Sonnet 4 或 GPT-4.1(对工具的理解更好)
- 明确启用 Agent 模式
- 明确提及:“使用 resend MCP 工具发送……”
- 检查 MCP 服务是否正在运行(查看控制台输出)
问题:“收到‘invalid sender’错误”
解决方案:发件人邮箱尚未验证
- 访问 https://resend.com/domains
- 如果使用自定义域名,请验证该域名
- 测试时使用默认邮箱 [email protected]
- 更新 MCP 配置中的 SENDER_EMAIL_ADDRESS
- 重启 MCP 服务
高级配置
使用 HTTP 传输的自定义 MCP 服务
适用于共享团队环境或基于云的设置:
{
"servers": {
"resend": {
"type": "http",
"url": "https://your-mcp-server.example.com/mcp"
}
}
}
HTTP 服务应将请求转发到 Resend API。
特定环境的配置
为不同环境使用不同的 .mcp.json 文件:
# Development
cp .mcp.dev.json .vscode/mcp.json
# Production
cp .mcp.prod.json .vscode/mcp.json
与 Claude Desktop 和 GitHub Copilot 集成
你可以同时配置两者:
Claude Desktop 配置:
{
"mcpServers": {
"resend": {
"command": "node",
"args": ["/path/to/mcp-send-email/build/index.js"],
"env": {
"RESEND_API_KEY": "re_xxxxx"
}
}
}
}
VS Code .vscode/mcp.json:
{
"servers": {
"resend": {
"type": "command",
"command": "node /path/to/mcp-send-email/build/index.js",
"env": {
"RESEND_API_KEY": "re_xxxxx"
}
}
}
}
两者都会使用同一个本地 MCP 服务实例。
工作流示例
事务性邮件工作流
- 设置阶段:使用生产环境 API 密钥部署 MCP 服务
- 自动化阶段:在 Claude Desktop 或 Copilot 中进行配置
- 集成阶段:通过 AI Agent 在应用程序逻辑中使用
When order is confirmed, send confirmation email with order details using Resend MCP - 监控阶段:在 Resend 控制面板中检查投递状态
营销活动工作流
- 准备邮件模板和收件人列表
- 使用 AI Agent 生成个性化内容
- 发送前检查生成的邮件
- 通过 Resend MCP 分批发送
- 监控打开率和互动情况
通知工作流
- 为你的通知服务配置 Resend MCP
- 为不同类型的通知创建邮件模板
- 使用 AI Agent 将通知整理为邮件
- 通过 Resend MCP 向订阅者发送
- 跟踪投递情况并处理退信