Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

Update Template Version

update_template_version

Modify email template versions in SendGrid by updating content, subject lines, and activation status to refine email campaigns.

Instructions

Update the content and settings of a template version

Input Schema

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

Implementation Reference

  • Handler function that performs PATCH request to SendGrid API to update the specified template version with provided parameters, including read-only check, input validation, and JSON parsing for test_data.
    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) }] };
    },
  • Zod input schema defining parameters for updating a template version, including template_id, version_id, and optional fields like name, subject, html_content, etc.
    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"),
      },
    },
  • src/index.ts:20-23 (registration)
    Main MCP server registration loop that registers all tools from allTools, including update_template_version, using server.registerTool.
    // Register all tools
    for (const [name, tool] of Object.entries(allTools)) {
      server.registerTool(name, tool.config as any, tool.handler as any);
    }
  • Aggregation of all tool sets into allTools object, including templateTools which contains update_template_version.
    export const allTools = {
      ...automationTools,
      ...campaignTools,
      ...contactTools,
      ...mailTools,
      ...miscTools,
      ...statsTools,
      ...templateTools,
  • Tool definition and registration within templateTools object export.
    update_template_version: {
      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"),
        },
      },
      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) }] };
      },
    },
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions updating 'content and settings' but doesn't disclose permissions needed, whether changes are reversible, rate limits, or what happens to existing data. For a mutation tool with zero annotation coverage, this is inadequate.

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 that directly states the tool's purpose without any fluff. It's appropriately sized and front-loaded with essential information.

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 mutation tool with 9 parameters, no annotations, and no output schema, the description is insufficient. It doesn't address behavioral aspects like side effects, error conditions, or response format, leaving significant gaps for an AI agent to understand how to use it correctly.

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 100%, so the schema fully documents all 9 parameters. The description adds no additional parameter details beyond what's in the schema, such as explaining relationships between fields or usage examples. Baseline 3 is appropriate when schema does all the work.

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 ('Update') and resource ('content and settings of a template version'), which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'update_template' or 'create_template_version', which would require 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?

No guidance is provided on when to use this tool versus alternatives like 'update_template' or 'create_template_version'. The description only states what it does, not when it's appropriate or what prerequisites exist.

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