Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

Send Mail

send_mail

Send emails programmatically using SendGrid's API to automate transactional and marketing communications.

Instructions

Send an email using SendGrid Mail Send API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
personalizationsYesPersonalization settings for recipients
fromYes
subjectNoDefault subject if not set in personalizations
contentYesEmail content
reply_toNo

Implementation Reference

  • The handler function that implements the send_mail tool. It checks if read-only mode is active and, if not, sends the email data as JSON via POST to SendGrid's /v3/mail/send endpoint using makeRequest.
    handler: async (mailData: any): Promise<ToolResult> => {
      const readOnlyCheck = checkReadOnlyMode();
      if (readOnlyCheck.blocked) {
        return { content: [{ type: "text", text: readOnlyCheck.message! }] };
      }
      
      const result = await makeRequest("https://api.sendgrid.com/v3/mail/send", {
        method: "POST",
        body: JSON.stringify(mailData),
      });
      return { content: [{ type: "text", text: `Email sent successfully. Response: ${JSON.stringify(result, null, 2)}` }] };
    },
  • The tool configuration object defining the title, description, and inputSchema using Zod for validating parameters such as personalizations, from email, content, and reply_to.
    config: {
      title: "Send Mail",
      description: "Send an email using SendGrid Mail Send API",
      inputSchema: {
        personalizations: z.array(z.object({
          to: z.array(EmailAddressSchema),
          cc: z.array(EmailAddressSchema).optional(),
          bcc: z.array(EmailAddressSchema).optional(),
          subject: z.string().optional(),
          substitutions: z.record(z.any()).optional(),
        })).describe("Personalization settings for recipients"),
        from: EmailAddressSchema,
        subject: z.string().optional().describe("Default subject if not set in personalizations"),
        content: z.array(z.object({
          type: z.string().describe("Content type (text/plain, text/html)"),
          value: z.string().describe("Content body"),
        })).describe("Email content"),
        reply_to: EmailAddressSchema.optional(),
      },
    },
  • src/tools/mail.ts:6-41 (registration)
    The mailTools export that defines and registers the send_mail tool object with its config and handler, which is later included in allTools.
    export const mailTools = {
      send_mail: {
        config: {
          title: "Send Mail",
          description: "Send an email using SendGrid Mail Send API",
          inputSchema: {
            personalizations: z.array(z.object({
              to: z.array(EmailAddressSchema),
              cc: z.array(EmailAddressSchema).optional(),
              bcc: z.array(EmailAddressSchema).optional(),
              subject: z.string().optional(),
              substitutions: z.record(z.any()).optional(),
            })).describe("Personalization settings for recipients"),
            from: EmailAddressSchema,
            subject: z.string().optional().describe("Default subject if not set in personalizations"),
            content: z.array(z.object({
              type: z.string().describe("Content type (text/plain, text/html)"),
              value: z.string().describe("Content body"),
            })).describe("Email content"),
            reply_to: EmailAddressSchema.optional(),
          },
        },
        handler: async (mailData: any): Promise<ToolResult> => {
          const readOnlyCheck = checkReadOnlyMode();
          if (readOnlyCheck.blocked) {
            return { content: [{ type: "text", text: readOnlyCheck.message! }] };
          }
          
          const result = await makeRequest("https://api.sendgrid.com/v3/mail/send", {
            method: "POST",
            body: JSON.stringify(mailData),
          });
          return { content: [{ type: "text", text: `Email sent successfully. Response: ${JSON.stringify(result, null, 2)}` }] };
        },
      },
    };
  • src/index.ts:21-23 (registration)
    The loop that registers all tools from allTools (including send_mail) with the MCP server by calling server.registerTool for each.
    for (const [name, tool] of Object.entries(allTools)) {
      server.registerTool(name, tool.config as any, tool.handler as any);
    }
  • Spreads the mailTools (containing send_mail) into the allTools export used for global registration.
    ...mailTools,
Behavior2/5

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

No annotations are provided, so the description carries full burden. While 'Send an email' implies a write operation, the description doesn't disclose critical behavioral aspects like authentication requirements, rate limits, error handling, whether emails are queued or sent immediately, or what happens on success/failure. This is inadequate for a mutation tool with zero annotation coverage.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a tool with this complexity level and gets straight to the point without unnecessary elaboration.

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?

For a 5-parameter mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns, error conditions, or important behavioral constraints. The agent would need to guess about the tool's operation based solely on the API name reference.

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?

Schema description coverage is 60%, providing some parameter documentation. The description adds no parameter-specific information beyond what's implied by 'SendGrid Mail Send API.' It doesn't explain the structure of personalizations, content types, or relationships between parameters like subject fields. The description doesn't compensate for the 40% coverage gap.

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 action ('Send an email') and specifies the implementation method ('using SendGrid Mail Send API'), which distinguishes it from other email-related tools. However, it doesn't explicitly differentiate from potential sibling tools that might also send emails through different mechanisms.

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. With multiple sibling tools for contact management, template creation, and statistics retrieval, there's no indication whether this is the primary email sending method or when other tools might be more appropriate.

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

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/deyikong/sendgrid-mcp'

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