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']
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states this is a creation operation, implying it's a write/mutation tool, but doesn't cover critical aspects like permissions required, whether it's idempotent, rate limits, error handling, or what happens on success (e.g., returns a template ID). For a mutation tool with zero annotation coverage, this is a significant gap.

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 gets straight to the point with zero wasted words. It's appropriately sized for a straightforward creation tool and front-loads the essential information (create + email template + SendGrid).

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?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens after creation (e.g., returns a template ID or confirmation), error conditions, or behavioral constraints. The combination of mutation nature and lack of structured metadata means the description should provide more context about the operation's behavior and outcomes.

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%, with all four parameters clearly documented in the schema (name, subject, html_content, plain_content). The description adds no additional parameter information beyond what's in the schema. According to the rules, when schema coverage is high (>80%), the baseline score is 3 even with no param info in the description.

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') and resource ('email template in SendGrid'), making the purpose immediately understandable. It distinguishes this tool from siblings like 'delete_template' or 'get_template' by specifying it's for creation rather than deletion or retrieval. However, it doesn't explicitly differentiate from other creation tools like 'create_contact_list', though the resource type (email template vs contact list) is implied.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing SendGrid account access), when not to use it (e.g., for updating existing templates), or direct alternatives among siblings. The agent must infer usage from the tool name and context alone.

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

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