Resend Email

官方

直接從編輯器使用 Resend API 發送電子郵件。

你可以用 Resend Email MCP 做什麼?

  • 傳送與管理電子郵件 — 請助理透過 send_email 傳送、列出、取得、取消或批次傳送電子郵件,並支援附件、副本/密件副本、排程及自訂標頭。
  • 管理聯絡人與受眾 — 使用 create_contact 建立、更新或移除聯絡人,管理區隔成員資格與主題訂閱,並從 CSV 匯入聯絡人。
  • 建立並傳送廣播 — 透過 create_broadcast 建立、排程、傳送或取消廣播活動,並支援個人化佔位符與預覽文字。
  • 處理內送電子郵件 — 使用 list_received_emails 列出與讀取收到的電子郵件,並從內送訊息下載附件。
  • 管理範本與網域 — 使用 create_templateverify_domain 建立、更新、發布或複製含變數的電子郵件範本,並驗證或設定寄件網域。
  • 監控與自動化 — 使用 list_logssend_event 檢視 API 請求紀錄、管理 Webhook,並透過傳送聯絡人事件來觸發自動化流程。

文件

Resend MCP Server

smithery badge npm version

將您的 AI 代理連線至 Resend 平台。可直接從任何 MCP 用戶端(如 Claude、Cursor 或 Claude Code)寄送與接收電子郵件、管理聯絡人、廣播、網域及更多功能。

我們同時提供由 Resend 代管的遠端 MCP 伺服器本機 MCP 伺服器(本套件)。

遠端 MCP 伺服器

Resend 將 MCP 伺服器代管於:

https://mcp.resend.com/mcp

連線任何支援遠端伺服器(Streamable HTTP)的 MCP 用戶端。無需安裝任何軟體,也無需執行本機程序,因此是網頁型用戶端(如 Claude)與代管代理平台的最佳選擇。

連線時,您的用戶端會開啟瀏覽器視窗,讓您登入 Resend 並透過 OAuth 核准存取。

Claude Code

claude mcp add --transport http resend https://mcp.resend.com/mcp

接著在 Claude Code 中執行 /mcp,然後選取 resend 以完成 OAuth 登入。

Claude

在 Claude(網頁版或桌面版)中,開啟 Settings > Connectors > Add custom connector,然後輸入:

https://mcp.resend.com/mcp

Cursor

開啟命令面板,選擇「Cursor Settings」>「MCP」>「Add new global MCP server」。

{
  "mcpServers": {
    "resend": {
      "url": "https://mcp.resend.com/mcp"
    }
  }
}

Codex

codex mcp add resend --url https://mcp.resend.com/mcp

Copilot

若要在 VS Code 中使用 GitHub Copilot,請將以下內容新增至您的 settings.json

{
  "mcp": {
    "servers": {
      "resend": {
        "type": "http",
        "url": "https://mcp.resend.com/mcp"
      }
    }
  }
}

Windsurf

{
  "mcpServers": {
    "resend": {
      "serverUrl": "https://mcp.resend.com/mcp"
    }
  }
}

Warp

在 Warp 的設定中,前往 Agents > MCP servers,然後點擊 +Add 以新增伺服器。

{
  "resend": {
    "serverUrl": "https://mcp.resend.com/mcp"
  }
}

使用 API 金鑰進行驗證

如果您的用戶端執行於無法進行瀏覽器登入的環境(伺服器、CI 或無頭代理),請改傳遞 Resend API 金鑰 作為 Bearer token,而非使用 OAuth。

Claude Code:

claude mcp add --transport http resend https://mcp.resend.com/mcp --header "Authorization: Bearer re_xxxxxxxxx"

JSON 設定(Cursor、Windsurf 及其他),請新增 Authorization 標頭:

{
  "mcpServers": {
    "resend": {
      "url": "https://mcp.resend.com/mcp",
      "headers": {
        "Authorization": "Bearer re_xxxxxxxxx"
      }
    }
  }
}

本機 MCP 伺服器

代管伺服器執行的是與 NPM 上 resend-mcp 相同的開放原始碼。如果您偏好自行執行伺服器,可以使用 npx 將其整合至任何支援的 MCP 用戶端。您需要:

本機伺服器支援兩種傳輸模式:stdio(預設)與 HTTP

請在下方選擇偏好的模式與用戶端以開始使用。請記得將 re_xxxxxxxxx 替換為您的實際 API 金鑰。

Stdio 傳輸(預設)

快速設定

為所有偵測到的代理與編輯器安裝:

npx add-mcp resend-mcp --name resend --env "RESEND_API_KEY=re_xxxxxxxxx"

Claude Code

claude mcp add resend -e RESEND_API_KEY=re_xxxxxxxxx -- npx -y resend-mcp

Codex

codex mcp add resend \
  --env RESEND_API_KEY=re_xxxxxxxxx \
  -- npx -y resend-mcp

Cursor

開啟命令面板,選擇「Cursor Settings」>「MCP」>「Add new global MCP server」。

{
  "mcpServers": {
    "resend": {
      "command": "npx",
      "args": ["-y", "resend-mcp"],
      "env": {
        "RESEND_API_KEY": "re_xxxxxxxxx"
      }
    }
  }
}

Claude Desktop

開啟 Claude Desktop 設定 >「Developer」分頁 >「Edit Config」。

{
  "mcpServers": {
    "resend": {
      "command": "npx",
      "args": ["-y", "resend-mcp"],
      "env": {
        "RESEND_API_KEY": "re_xxxxxxxxx"
      }
    }
  }
}

Copilot

若要在 VS Code 中使用 GitHub Copilot,請將以下內容新增至您的 settings.json

{
  "mcp": {
    "servers": {
      "resend": {
        "command": "npx",
        "args": ["-y", "resend-mcp"],
        "env": {
          "RESEND_API_KEY": "re_xxxxxxxxx"
        }
      }
    }
  }
}

Gemini CLI

{
  "mcpServers": {
    "resend": {
      "command": "npx",
      "args": ["-y", "resend-mcp"],
      "env": {
        "RESEND_API_KEY": "re_xxxxxxxxx"
      }
    }
  }
}

OpenCode

新增至您的 opencode.json 設定:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "resend": {
      "type": "local",
      "command": ["npx", "-y", "resend-mcp"],
      "enabled": true,
      "environment": {
        "RESEND_API_KEY": "re_xxxxxxxxx"
      }
    }
  }
}

Windsurf

{
  "mcpServers": {
    "resend": {
      "command": "npx",
      "args": ["-y", "resend-mcp"],
      "env": {
        "RESEND_API_KEY": "re_xxxxxxxxx"
      }
    }
  }
}

Devin

在 Devin 中,開啟 Settings > Connections > MCP Servers,然後點擊 Add a custom MCP。完整逐步說明請參閱 Devin 指南

{
  "mcpServers": {
    "resend": {
      "command": "npx",
      "args": ["-y", "resend-mcp"],
      "env": {
        "RESEND_API_KEY": "re_xxxxxxxxx",
        "SENDER_EMAIL_ADDRESS": "onboarding@resend.dev"
      }
    }
  }
}

HTTP 傳輸

透過 HTTP 執行伺服器以用於遠端或網頁型整合,例如部署在您自己的隧道或反向代理之後,而非使用 Resend 的代管遠端 MCP 伺服器。在 HTTP 模式下,每個用戶端會在其 Authorization 標頭中傳遞 Resend API 金鑰作為 Bearer token 來進行驗證。

啟動伺服器:

npx -y resend-mcp --http --port 3000

伺服器將監聽 http://127.0.0.1:3000,並透過 Streamable HTTP 在 /mcp 暴露 MCP 端點。

Claude Code

claude mcp add resend --transport http http://127.0.0.1:3000/mcp --header "Authorization: Bearer re_xxxxxxxxx"

Cursor

開啟命令面板,選擇「Cursor Settings」>「MCP」>「Add new global MCP server」。

{
  "mcpServers": {
    "resend": {
      "url": "http://127.0.0.1:3000/mcp",
      "headers": {
        "Authorization": "Bearer re_xxxxxxxxx"
      }
    }
  }
}

您也可以透過 MCP_PORT 環境變數設定連接埠:

MCP_PORT=3000 npx -y resend-mcp --http

作為函式庫使用

HTTP 傳輸模式也會被匯出,因此可以嵌入其他服務中,而不必透過 CLI 執行。每個連線的用戶端都會使用自己的 Resend API 金鑰作為 Bearer token 進行驗證。

import { runHttp } from 'resend-mcp/http';

// Options are optional — pass `senderEmailAddress` / `replierEmailAddresses`
// to set defaults. Binds the port and returns the Node http.Server, exposing
// the MCP endpoint at POST/GET/DELETE /mcp and a GET /health check.
const server = await runHttp({}, 3000);

預設情況下,伺服器會套用僅限本機的 Host 驗證(DNS-rebinding 防護)。當部署在反向代理或負載平衡器後方時,由於伺服器已受到每請求 Bearer API 金鑰的保護,請將 host 設定為 0.0.0.0,這樣代理轉送的 Host 與負載平衡器的健康檢查才不會被以 403 Invalid Host 拒絕:

const server = await runHttp({}, 3000, { host: '0.0.0.0' });
// or pin specific hostnames instead of disabling validation:
const server = await runHttp({}, 3000, { allowedHosts: ['mcp.example.com'] });

透過 CLI,這對應到 --host / --allowed-hosts(或 MCP_HOST / MCP_ALLOWED_HOSTS)。

選項

您可以傳遞額外引數來設定本機伺服器:

  • --key:您的 Resend API 金鑰(僅限 stdio 模式,因為 HTTP 模式使用用戶端的 Bearer token)
  • --sender:來自已驗證網域的預設寄件者電子郵件地址
  • --reply-to:預設回覆電子郵件地址(可指定多次)
  • --http:使用 HTTP 傳輸而非 stdio(預設:stdio)
  • --port:使用 --http 時的 HTTP 連接埠(預設:3000,或 MCP_PORT 環境變數)
  • --host:使用 --http 時用於 DNS-rebinding 防護的主機(預設:127.0.0.1,或 MCP_HOST)。設為 0.0.0.0 可在代理/負載平衡器後方停用 Host 驗證。
  • --allowed-hosts:使用 --http 時以逗號分隔的 Host 允許清單(或 MCP_ALLOWED_HOSTS

環境變數:

  • RESEND_API_KEY:您的 Resend API 金鑰(stdio 必填,HTTP 選填,因為用戶端會透過 Bearer token 傳遞)
  • SENDER_EMAIL_ADDRESS:來自已驗證網域的預設寄件者電子郵件地址(選填)
  • REPLY_TO_EMAIL_ADDRESSES:以逗號分隔的回覆電子郵件地址(選填)
  • MCP_PORT:使用 --http 時的 HTTP 連接埠(選填)
  • MCP_HOST:使用 --http 時用於 DNS-rebinding 防護的主機(選填)
  • MCP_ALLOWED_HOSTS:使用 --http 時以逗號分隔的 Host 允許清單(選填)

[!NOTE] 如果您未提供寄件者電子郵件地址,MCP 伺服器會在您每次呼叫工具時要求您提供。

MCP 伺服器工具

Resend 的 MCP 伺服器透過單一整合,讓您的 AI 代理以原生方式存取完整的 Resend 平台。您可以使用自然語言管理電子郵件基礎架構的所有層面。

  • 電子郵件(Emails):寄送、列出、取得、取消、更新及批次寄送電子郵件。支援 HTML、純文字、附件(本機檔案、URL 或 base64)、副本/密件副本、回覆地址、排程、標籤、自訂標頭、依主題寄送及冪等金鑰。
  • 收到的電子郵件(Received Emails):列出與讀取入站電子郵件。列出與下載收到的電子郵件附件。
  • 範本(Templates):建立、列出、取得、更新、發布、複製及移除電子郵件範本。支援撰寫範本內容與 {{{VARIABLE}}} 佔位符。
  • 聯絡人(Contacts):建立、列出、取得、更新及移除聯絡人。管理區段成員資格、主題訂閱及 CSV 聯絡人匯入。支援自訂聯絡人屬性。
  • 廣播(Broadcasts):建立、寄送、取消、列出、取得、更新及移除廣播活動。支援排程、個人化佔位符及預覽文字。
  • 自動化(Automations):建立、列出、取得、更新及移除自動化。檢視自動化的執行記錄。
  • 事件(Events):寄送事件以觸發聯絡人的自動化。建立、更新及移除事件定義。
  • 網域(Domains):建立、列出、取得、更新、移除及驗證寄件者網域。設定追蹤、TLS 及寄送/接收功能。建立與驗證網域聲明。
  • 區段(Segments):建立、列出、取得及移除受眾區段。
  • 抑制清單(Suppressions):個別或批次列出、取得、新增及移除抑制清單項目。硬退信與垃圾郵件投訴會自動被抑制;請手動新增地址以遵守「請勿聯絡」要求。
  • 主題(Topics):建立、列出、取得、更新及移除訂閱主題。
  • 聯絡人屬性(Contact Properties):建立、列出、取得、更新及移除自訂聯絡人屬性。
  • API 金鑰(API Keys):建立、列出及移除 API 金鑰。
  • Webhooks:建立、列出、取得、更新及移除用於事件通知的 webhook。
  • 日誌(Logs):列出與檢查 API 請求日誌,包括完整的請求與回應內容。
  • 編輯器(Editor):連線(與中斷連線)至 Resend 儀表板中的視覺化編輯器,並在協作編輯廣播與範本時讀取草稿內容。

本機開發

  1. 複製此專案並建置:
git clone https://github.com/resend/resend-mcp.git
pnpm install
pnpm run build
  1. 若要使用本機建置結果,請將 npx 指令替換為您本機建置的路徑:

Claude Code(stdio):

claude mcp add resend -e RESEND_API_KEY=re_xxxxxxxxx -- node ABSOLUTE_PATH_TO_PROJECT/dist/index.js

Claude Code(HTTP):

claude mcp add resend --transport http http://127.0.0.1:3000/mcp --header "Authorization: Bearer re_xxxxxxxxx"

Cursor / Claude Desktop(stdio):

{
  "mcpServers": {
    "resend": {
      "command": "node",
      "args": ["ABSOLUTE_PATH_TO_PROJECT/dist/index.js"],
      "env": {
        "RESEND_API_KEY": "re_xxxxxxxxx"
      }
    }
  }
}

Cursor(HTTP):

{
  "mcpServers": {
    "resend": {
      "url": "http://127.0.0.1:3000/mcp",
      "headers": {
        "Authorization": "Bearer re_xxxxxxxxx"
      }
    }
  }
}

使用 MCP 用戶端進行即時測試

開發時,您可以在另一個視窗編輯程式碼的同時,於真實的 MCP 用戶端工作階段中測試變更。

概念:執行 tsc --watch 以持續重新建置 dist/,並從不同目錄將另一個 MCP 用戶端指向建置產出的 dist/index.js。當您想要套用程式碼變更時,請重新啟動 MCP 用戶端工作階段(MCP 伺服器是長時間執行的 stdio 程序,不會熱重載)。

以 Claude Code 為例:

  1. 執行 TypeScript 監看器以在儲存時自動重新建置:

    pnpm tsc --watch
    
  2. 在另一個目錄中,建立指向建置輸出的 .mcp.json

    mkdir -p /tmp/mcp-test
    
    // /tmp/mcp-test/.mcp.json
    {
      "mcpServers": {
        "resend-dev": {
          "command": "node",
          "args": ["/absolute/path/to/resend-mcp/dist/index.js"],
          "env": {
            "RESEND_API_KEY": "re_xxxxxxxxx"
          }
        }
      }
    }
    
  3. 從該目錄啟動 Claude Code 並使用 MCP 工具。在進行程式碼變更後,啟動新的 Claude Code 工作階段以套用新的建置結果。

相同的原則適用於任何 MCP 用戶端——將測試環境與開發環境分開,使用 dist/index.js 的絕對路徑,並在重新建置後重新連線 MCP 伺服器。

使用 MCP Inspector 測試

注意: 請確保您已先建置專案(請參閱上方本機開發章節)。

使用 Stdio 傳輸

  1. 設定您的 API 金鑰:

    export RESEND_API_KEY=re_your_key_here
    
  2. 啟動 inspector:

    pnpm inspector
    
  3. 在瀏覽器中(Inspector UI):

    • 選擇 stdio(啟動程序)。
    • Command: node
    • Args: dist/index.js(或 dist/index.js 的完整路徑)
    • Env: RESEND_API_KEY=re_your_key_here(如果您已在同一個終端機匯出,則可留空)。
    • 點擊 Connect,然後使用「List tools」驗證伺服器是否正常運作。

使用 HTTP 傳輸

  1. 在一個終端機中啟動 HTTP 伺服器:

    node dist/index.js --http --port 3000
    
  2. 在另一個終端機中啟動 inspector:

    pnpm inspector
    
  3. 在瀏覽器中(Inspector UI):

    • 選擇 Streamable HTTP(連線至 URL)。
    • URL: http://127.0.0.1:3000/mcp
    • 新增自訂標頭:Authorization: Bearer re_your_key_here 並啟動切換開關。
    • 點擊 Connect,然後使用「List tools」驗證伺服器是否正常運作。