Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

update_template_version

Modify email template versions by updating content, subject lines, and activation status to maintain current messaging across email campaigns.

Instructions

Update the content and settings of a template version

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activeNoSet as active version (1 = active, 0 = inactive)
generate_plain_contentNoAuto-generate plain text from HTML
html_contentNoHTML content of the email template
nameNoNew name for this version
plain_contentNoPlain text version
subjectNoEmail subject line (supports Handlebars)
template_idYesID of the template
test_dataNoJSON string of test data for Handlebars variables
version_idYesID of the version to update

Implementation Reference

  • The main handler function implementing the tool logic: checks read-only mode, builds update payload from provided parameters, validates test_data JSON if present, ensures at least one field to update, and performs PATCH request to SendGrid API endpoint /templates/{template_id}/versions/{version_id}.
    handler: async ({ template_id, version_id, name, subject, html_content, plain_content, active, generate_plain_content, test_data }: { template_id: string; version_id: string; name?: string; subject?: string; html_content?: string; plain_content?: string; active?: number; generate_plain_content?: boolean; test_data?: string; }): Promise<ToolResult> => { const readOnlyCheck = checkReadOnlyMode(); if (readOnlyCheck.blocked) { return { content: [{ type: "text", text: readOnlyCheck.message! }] }; } const versionData: any = {}; if (name !== undefined) versionData.name = name; if (subject !== undefined) versionData.subject = subject; if (html_content !== undefined) versionData.html_content = html_content; if (plain_content !== undefined) versionData.plain_content = plain_content; if (active !== undefined) versionData.active = active; if (generate_plain_content !== undefined) versionData.generate_plain_content = generate_plain_content; if (test_data) { try { versionData.test_data = JSON.parse(test_data); } catch (error) { return { content: [{ type: "text", text: "Error: test_data must be valid JSON" }] }; } } if (Object.keys(versionData).length === 0) { return { content: [{ type: "text", text: "Error: Please provide at least one field to update" }] }; } const result = await makeRequest(`https://api.sendgrid.com/v3/templates/${template_id}/versions/${version_id}`, { method: "PATCH", body: JSON.stringify(versionData), }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
  • Tool configuration including Zod inputSchema defining all optional parameters for updating template version content and settings.
    config: { title: "Update Template Version", description: "Update the content and settings of a template version", inputSchema: { template_id: z.string().describe("ID of the template"), version_id: z.string().describe("ID of the version to update"), name: z.string().optional().describe("New name for this version"), subject: z.string().optional().describe("Email subject line (supports Handlebars)"), html_content: z.string().optional().describe("HTML content of the email template"), plain_content: z.string().optional().describe("Plain text version"), active: z.number().optional().describe("Set as active version (1 = active, 0 = inactive)"), generate_plain_content: z.boolean().optional().describe("Auto-generate plain text from HTML"), test_data: z.string().optional().describe("JSON string of test data for Handlebars variables"), }, },
  • Aggregates all tool modules including templateTools (which contains update_template_version) into single allTools export used by MCP server.
    import { templateTools } from "./templates.js"; export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools,
  • src/index.ts:20-23 (registration)
    Final MCP server registration loop that registers every tool from allTools (including update_template_version) by calling server.registerTool(name, config, handler).
    // Register all tools for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }

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