Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

Create Template Version

create_template_version

Add a new version to an existing email template with updated HTML content, subject line, and settings for testing and deployment.

Instructions

Create a new version of a template with HTML content and settings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
template_idYesID of the template to add version to
nameYesName for this version
subjectYesEmail subject line (supports Handlebars)
html_contentYesHTML content of the email template (supports Handlebars)
plain_contentNoPlain text version (optional)
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

  • The handler function that executes the tool: checks read-only mode, constructs version data, handles optional fields, parses test_data if provided, and makes POST request to SendGrid API to create template version.
    handler: async ({ 
      template_id, 
      name, 
      subject, 
      html_content, 
      plain_content, 
      active, 
      generate_plain_content, 
      test_data 
    }: { 
      template_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 = {
        name,
        subject,
        html_content,
        active: active ?? 1,
        generate_plain_content: generate_plain_content ?? true,
      };
      
      if (plain_content) {
        versionData.plain_content = 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" }] };
        }
      }
      
      const result = await makeRequest(`https://api.sendgrid.com/v3/templates/${template_id}/versions`, {
        method: "POST",
        body: JSON.stringify(versionData),
      });
      
      return { 
        content: [{ 
          type: "text", 
          text: `Template version created successfully!\n\n${JSON.stringify(result, null, 2)}\n\nYou can now use this template with the Mail API using template_id: ${template_id}` 
        }] 
      };
    },
  • Tool configuration including title, description, and Zod-based input schema defining parameters for creating a template version.
    config: {
      title: "Create Template Version",
      description: "Create a new version of a template with HTML content and settings",
      inputSchema: {
        template_id: z.string().describe("ID of the template to add version to"),
        name: z.string().describe("Name for this version"),
        subject: z.string().describe("Email subject line (supports Handlebars)"),
        html_content: z.string().describe("HTML content of the email template (supports Handlebars)"),
        plain_content: z.string().optional().describe("Plain text version (optional)"),
        active: z.number().optional().default(1).describe("Set as active version (1 = active, 0 = inactive)"),
        generate_plain_content: z.boolean().optional().default(true).describe("Auto-generate plain text from HTML"),
        test_data: z.string().optional().describe("JSON string of test data for Handlebars variables"),
      },
    },
  • Aggregates all individual tool modules (including templateTools containing create_template_version) into allTools export.
    export const allTools = {
      ...automationTools,
      ...campaignTools,
      ...contactTools,
      ...mailTools,
      ...miscTools,
      ...statsTools,
      ...templateTools,
    };
  • src/index.ts:21-23 (registration)
    Registers all tools from allTools to the MCP server using server.registerTool, including create_template_version.
    for (const [name, tool] of Object.entries(allTools)) {
      server.registerTool(name, tool.config as any, tool.handler as any);
    }
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. It mentions 'HTML content and settings' but doesn't disclose behavioral traits like whether this operation requires specific permissions, if it's idempotent, what happens to previous versions, or if there are rate limits. The description is minimal and lacks crucial operational context for a mutation tool.

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 front-loads the core purpose. Every word earns its place with no redundancy or unnecessary elaboration, making it easy to parse quickly.

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 8 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns, error conditions, or behavioral implications like versioning effects. Given the complexity and lack of structured data, more context is needed for effective use.

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 8 parameters. The description adds no additional parameter semantics beyond implying that 'settings' might refer to parameters like 'active' or 'generate_plain_content'. Baseline 3 is appropriate when schema does the heavy lifting.

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 ('Create a new version') and resource ('template'), specifying it involves 'HTML content and settings'. It distinguishes from 'create_template' which creates a new template rather than a version. However, it doesn't explicitly differentiate from 'update_template_version' which might modify existing versions.

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 'create_template' (for new templates) or 'update_template_version' (for modifying existing versions). The description lacks context about prerequisites, such as needing an existing template ID, or when this operation is 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