Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

send_mail

Send transactional emails and marketing communications using SendGrid's API. Configure recipients, content, and delivery settings to manage email campaigns and automated messaging.

Instructions

Send an email using SendGrid Mail Send API

Input Schema

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

Implementation Reference

  • The handler function executes the send_mail tool: checks if in read-only mode, if not, makes a POST request to SendGrid's /v3/mail/send endpoint with the provided mailData, and returns a success response with the API result.
    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)}` }] }; },
  • Zod schema defining the input parameters for the send_mail tool, including personalizations (to, cc, bcc, subject, substitutions), from, default subject, content (type and value), and optional reply_to.
    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/index.ts:21-23 (registration)
    Registers all tools from the allTools object (which includes send_mail from mailTools) with the MCP server using server.registerTool.
    for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }
  • Aggregates and exports allTools by spreading mailTools (containing send_mail) along with other tool sets.
    export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools, };

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