Skip to main content
Glama
Hawstein

MCP Server Resend

by Hawstein

send_email

Send emails via the Resend API with support for plain text, attachments, and optional scheduling. Specify custom sender and reply-to addresses to personalize your messages.

Instructions

Sends an email using the Resend API. Supports plain text content, attachments and optional scheduling. Can specify custom sender and reply-to addresses.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attachmentsNoOptional. List of attachments. Each attachment must have a filename and either localPath (path to a local file) or remoteUrl (URL to a file on the internet).
contentYesPlain text email content
fromNoOptional. If provided, uses this as the sender email address; otherwise uses SENDER_EMAIL_ADDRESS environment variable
replyToNoOptional. If provided, uses these as the reply-to email addresses; otherwise uses REPLY_TO_EMAIL_ADDRESSES environment variable
scheduledAtNoOptional parameter to schedule the email. This uses natural language. Examples would be 'tomorrow at 10am' or 'in 2 hours' or 'next day at 9am PST' or 'Friday at 3pm ET'.
subjectYesEmail subject line
toYesRecipient email address

Implementation Reference

  • The core handler logic for the 'send_email' tool within the CallToolRequestSchema handler. Validates input arguments, processes attachments from local paths or remote URLs, sends the email using the Resend API, and returns success or error response.
    case SEND_EMAIL_TOOL.name: {
      if (!isEmailArgs(args)) {
        throw new Error("Invalid arguments for send_email tool");
      }
    
      const fromEmail = args.from || SENDER_EMAIL_ADDRESS.trim();
      if (!fromEmail) {
        throw new Error("Sender email must be provided either via args or SENDER_EMAIL_ADDRESS environment variable");
      }
    
      const replyToEmails = args.replyTo || REPLY_TO_EMAIL_ADDRESSES;
    
      // Convert attachments to Resend API format
      const attachments = args.attachments?.map(attachment => {
        if (attachment.localPath) {
          // Check if file exists
          if (!existsSync(attachment.localPath)) {
            throw new Error(`Attachment file not found: ${attachment.localPath}`);
          }
          // Try to read the file
          try {
            // readFileSync can read any file format as it reads files in binary mode
            const content = readFileSync(attachment.localPath).toString('base64');
            return {
              filename: attachment.filename,
              content,
              path: undefined
            };
          } catch (error) {
            throw new Error(`Failed to read attachment file: ${attachment.localPath}. Error: ${error instanceof Error ? error.message : String(error)}`);
          }
        }
    
        // If using remoteUrl
        return {
          filename: attachment.filename,
          content: undefined,
          path: attachment.remoteUrl
        };
      });
    
      const response = await resend.emails.send({
        to: args.to,
        from: fromEmail,
        subject: args.subject,
        text: args.content,
        replyTo: replyToEmails,
        scheduledAt: args.scheduledAt,
        attachments,
      });
    
      if (response.error) {
        throw new Error(`Failed to send email: ${JSON.stringify(response.error)}`);
      }
    
      return {
        content: [{
          type: "text",
          text: `Email sent successfully! ${JSON.stringify(response.data)}`
        }]
      };
    }
  • Input schema (JSON Schema) for the 'send_email' tool, defining parameters like to, subject, content, optional from, replyTo, scheduledAt, and attachments with validation rules.
    inputSchema: {
      type: "object",
      properties: {
        to: {
          type: "string",
          format: "email",
          description: "Recipient email address"
        },
        subject: {
          type: "string",
          description: "Email subject line"
        },
        content: {
          type: "string",
          description: "Plain text email content"
        },
        from: {
          type: "string",
          format: "email",
          description: "Optional. If provided, uses this as the sender email address; otherwise uses SENDER_EMAIL_ADDRESS environment variable"
        },
        replyTo: {
          type: "array",
          items: {
            type: "string",
            format: "email"
          },
          description: "Optional. If provided, uses these as the reply-to email addresses; otherwise uses REPLY_TO_EMAIL_ADDRESSES environment variable"
        },
        scheduledAt: {
          type: "string",
          description: "Optional parameter to schedule the email. This uses natural language. Examples would be 'tomorrow at 10am' or 'in 2 hours' or 'next day at 9am PST' or 'Friday at 3pm ET'."
        },
        attachments: {
          type: "array",
          items: {
            type: "object",
            properties: {
              filename: {
                type: "string",
                description: "Name of the attachment file"
              },
              localPath: {
                type: "string",
                description: "Absolute path to a local file on user's computer. Required if remoteUrl is not provided."
              },
              remoteUrl: {
                type: "string",
                description: "URL to a file on the internet. Required if localPath is not provided."
              }
            },
            required: ["filename"],
            oneOf: [
              { required: ["localPath"] },
              { required: ["remoteUrl"] }
            ]
          },
          description: "Optional. List of attachments. Each attachment must have a filename and either localPath (path to a local file) or remoteUrl (URL to a file on the internet)."
        }
      },
      required: ["to", "subject", "content"]
    }
  • index.ts:181-183 (registration)
    Registration of the 'send_email' tool in the ListToolsRequestSchema handler, making it discoverable by clients.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [SEND_EMAIL_TOOL],
    }));
  • Type guard function 'isEmailArgs' used to validate the arguments passed to the send_email handler.
    function isEmailArgs(args: unknown): args is {
      to: string;
      subject: string;
      content: string;
      from?: string;
      replyTo?: string[];
      scheduledAt?: string;
      attachments?: Attachment[];
    } {
      if (
        typeof args !== "object" ||
        args === null
      ) {
        return false;
      }
    
      const emailArgs = args as {
        to: unknown;
        subject: unknown;
        content: unknown;
        attachments?: unknown[];
      };
    
      if (
        !("to" in emailArgs) ||
        typeof emailArgs.to !== "string" ||
        !("subject" in emailArgs) ||
        typeof emailArgs.subject !== "string" ||
        !("content" in emailArgs) ||
        typeof emailArgs.content !== "string"
      ) {
        return false;
      }
    
      // Check optional attachments if present
      if ("attachments" in emailArgs) {
        if (!Array.isArray(emailArgs.attachments)) return false;
        if (!emailArgs.attachments.every(isAttachment)) return false;
      }
    
      return true;
    }
  • Type guard function 'isAttachment' used to validate individual attachment objects in the send_email handler.
    function isAttachment(arg: unknown): arg is Attachment {
      if (typeof arg !== "object" || arg === null) return false;
    
      const attachment = arg as Attachment;
      if (typeof attachment.filename !== "string") return false;
    
      // Must have either localPath or remoteUrl, but not both
      const hasLocalPath = "localPath" in attachment && typeof attachment.localPath === "string";
      const hasRemoteUrl = "remoteUrl" in attachment && typeof attachment.remoteUrl === "string";
      return hasLocalPath !== hasRemoteUrl; // XOR operation
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions features like attachments and scheduling but lacks critical details: it doesn't specify authentication requirements (e.g., API keys), error handling, rate limits, or what happens on success/failure. For a tool that sends emails, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured in two sentences, with no wasted words. It front-loads the core purpose and efficiently lists key features. However, it could be slightly more informative without losing conciseness, such as by hinting at behavioral aspects.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of an email-sending tool with 7 parameters, no annotations, and no output schema, the description is incomplete. It lacks essential context like authentication needs, error handling, rate limits, and response format. This makes it inadequate for an agent to use the tool reliably in varied scenarios.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal semantic value beyond the input schema, which has 100% coverage. It mentions 'plain text content, attachments and optional scheduling' and 'custom sender and reply-to addresses,' but these are already covered in the schema descriptions. No additional syntax or constraints are provided, so it meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Sends an email using the Resend API.' It specifies the action (send) and resource (email), and mentions key capabilities like plain text content, attachments, and scheduling. However, without sibling tools, there's no need for differentiation, so it doesn't score a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It lists features but doesn't specify scenarios, prerequisites, or exclusions. For example, it doesn't mention when scheduling might fail or if there are rate limits, leaving the agent with minimal usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Hawstein/resend-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server