How resend/mcp-send-email works
Project type and purpose
• This is a lightweight, command-line “MCP” (Model-Connected-Plugin) microservice built in TypeScript/Node.js.
• Its sole responsibility is to receive email send requests from chat clients (Cursor or Claude Desktop), format them, and invoke the Resend API to dispatch emails (plain text, HTML, scheduled, CC/BCC, reply-to, custom sender).
File structure
• Top-level files:
• index.ts – single entry point defining the CLI/MCP server logic
• email.md – example email template used in demos/testing
• package.json, tsconfig.json, biome.json – Node.js and build configuration
• README.md, CHANGELOG.md – documentation
• Build artifacts (not in tree but referenced): build/index.js (compiled output)
• No separate “frontend” or “database” directories: this is purely a backend microservice/CLI tool.
Key insights from README
• Integrates with two external “clients”: Cursor and Claude Desktop, each invoking the CLI via command or command+args+env.
• Relies on Resend’s HTTP API (via Resend Node.js SDK under the hood).
• Exposes flags and environment variables: API key, sender, reply-to, schedule options.
• No persistent state or database; scheduling is ephemeral or delegated to the Node process.
Main components and their interactions
a. Components
1. Chat Clients (Cursor, Claude Desktop)
2. Local MCP CLI Server (build/index.js)
– CLI interface (parses args/env)
– Email Builder (formats plain text or HTML, handles CC/BCC, reply-to, scheduling)
– Resend Client Library (Node SDK or direct HTTP calls)
3. External Resend API
4. (Optional) Local Scheduler Module – handles future‐delivery logic in process memory
b. Relationships & Data Flow
– Users trigger “send email” in their chat client →
– Chat Client invokes node build/index.js with flags/env →
– CLI parses input and email.md (or stdin) →
– Email Builder constructs payload →
– Resend Client Library issues HTTPS request →
– Resend API responds with send confirmation →
– CLI returns success/failure JSON or console output back to client.
c. Architectural patterns & principles
– Single-responsibility: one module handles CLI parsing, one for payload building, one for HTTP client.
– Externalized configuration: API key and sender via flags or env vars.
– Pluggable integration: designed to be invoked by any tool supporting command plugins (MCP spec).
d. Key technologies
– Node.js + TypeScript, compiled by tsc
– Resend Node.js SDK (or HTTP client)
– MCP specification (Anthropic/Cursor)
– CLI argument parser (e.g., yargs or native process.argv)
Putting it all together
• Inside the MCP Server, vertically stack the sub-components in logical flow:
CLI Parser → Email Builder → Scheduler (optional) → Resend Client.