Skip to main content
Glama
Garoth

SendGrid MCP Server

by Garoth

create_template

Create new email templates in SendGrid for marketing campaigns, transactional emails, or automated communications by defining HTML content, plain text versions, and default subject lines.

Instructions

Create a new email template in SendGrid

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the template
subjectYesDefault subject line for the template
html_contentYesHTML content of the template
plain_contentYesPlain text content of the template

Implementation Reference

  • Core handler implementing the creation of a dynamic SendGrid email template and its first version using the SendGrid API.
    async createTemplate(params: { name: string; html_content: string; plain_content: string; subject: string; }): Promise<SendGridTemplate> { const [response] = await this.client.request({ method: 'POST', url: '/v3/templates', body: { name: params.name, generation: 'dynamic' } }); const templateId = (response.body as { id: string }).id; // Create the first version of the template const [versionResponse] = await this.client.request({ method: 'POST', url: `/v3/templates/${templateId}/versions`, body: { template_id: templateId, name: `${params.name} v1`, subject: params.subject, html_content: params.html_content, plain_content: params.plain_content, active: 1 } }); return { id: templateId, name: params.name, generation: 'dynamic', updated_at: new Date().toISOString(), versions: [{ id: (versionResponse.body as { id: string }).id, template_id: templateId, active: 1, name: `${params.name} v1`, html_content: params.html_content, plain_content: params.plain_content, subject: params.subject }] }; }
  • Tool registration in getToolDefinitions array, defining name, description, and input schema for 'create_template'.
    { name: 'create_template', description: 'Create a new email template in SendGrid', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the template' }, subject: { type: 'string', description: 'Default subject line for the template' }, html_content: { type: 'string', description: 'HTML content of the template' }, plain_content: { type: 'string', description: 'Plain text content of the template' } }, required: ['name', 'subject', 'html_content', 'plain_content'] } },
  • MCP tool handler in handleToolCall that invokes the SendGrid service's createTemplate method and formats the response.
    case 'create_template': const template = await service.createTemplate(args); return { content: [{ type: 'text', text: `Template "${args.name}" created with ID: ${template.id}` }] };
  • Input schema defining parameters for the create_template tool.
    inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the template' }, subject: { type: 'string', description: 'Default subject line for the template' }, html_content: { type: 'string', description: 'HTML content of the template' }, plain_content: { type: 'string', description: 'Plain text content of the template' } }, required: ['name', 'subject', 'html_content', 'plain_content'] }

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

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