Skip to main content
Glama
railsware

Mailtrap Email Sending

by railsware

update-template

Destructive

Modify existing email templates in Mailtrap Email Sending by updating subject lines, HTML content, plain text versions, names, or categories for transactional emails.

Instructions

Update an existing email template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
template_idYesID of the template to update
nameNoNew name for the template
subjectNoNew email subject line
htmlNoNew HTML content of the template
textNoNew plain text version of the template
categoryNoNew category for the template

Implementation Reference

  • Implementation of the updateTemplate handler function that performs the actual API call to update the email template via Mailtrap client, including validation and error handling.
    async function updateTemplate({
      template_id,
      name,
      subject,
      html,
      text,
      category,
    }: UpdateTemplateRequest): Promise<{ content: any[]; isError?: boolean }> {
      try {
        if (!client) {
          throw new Error("MAILTRAP_API_TOKEN environment variable is required");
        }
    
        // Validate that at least one update field is provided
        if (
          name === undefined &&
          subject === undefined &&
          html === undefined &&
          text === undefined &&
          category === undefined
        ) {
          return {
            content: [
              {
                type: "text",
                text: "Error: At least one update field (name, subject, html, text, or category) must be provided",
              },
            ],
            isError: true,
          };
        }
    
        // Validate that if both html and text are being updated, at least one has content
        if (html !== undefined && text !== undefined && !html && !text) {
          return {
            content: [
              {
                type: "text",
                text: "Error: If updating both html and text, at least one must have content",
              },
            ],
            isError: true,
          };
        }
    
        const updateData: any = {};
        if (name !== undefined) updateData.name = name;
        if (subject !== undefined) updateData.subject = subject;
        if (html !== undefined) updateData.body_html = html;
        if (text !== undefined) updateData.body_text = text;
        if (category !== undefined) updateData.category = category;
    
        const template = await client.templates.update(template_id, updateData);
    
        return {
          content: [
            {
              type: "text",
              text: `Template "${template.name}" updated successfully!\nTemplate ID: ${template.id}\nTemplate UUID: ${template.uuid}`,
            },
          ],
        };
      } catch (error) {
        console.error("Error updating template:", error);
    
        const errorMessage = error instanceof Error ? error.message : String(error);
    
        return {
          content: [
            {
              type: "text",
              text: `Failed to update template: ${errorMessage}`,
            },
          ],
          isError: true,
        };
      }
    }
  • JSON Schema defining the input structure for the 'update-template' tool, specifying properties like template_id (required), name, subject, html, text, category.
    const updateTemplateSchema = {
      type: "object",
      properties: {
        template_id: {
          type: "number",
          description: "ID of the template to update",
        },
        name: {
          type: "string",
          description: "New name for the template",
        },
        subject: {
          type: "string",
          description: "New email subject line",
        },
        html: {
          type: "string",
          description: "New HTML content of the template",
        },
        text: {
          type: "string",
          description: "New plain text version of the template",
        },
        category: {
          type: "string",
          description: "New category for the template",
        },
      },
      required: ["template_id"],
      additionalProperties: false,
    };
  • src/server.ts:64-72 (registration)
    Registration of the 'update-template' tool in the tools array of the MCP server, specifying name, description, inputSchema, handler, and annotations.
    {
      name: "update-template",
      description: "Update an existing email template",
      inputSchema: updateTemplateSchema,
      handler: updateTemplate,
      annotations: {
        destructiveHint: true,
      },
    },
Behavior3/5

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

The annotations include 'destructiveHint: true', which already indicates this is a mutation operation. The description adds minimal behavioral context beyond this, as 'Update an existing email template' implies modification but doesn't detail effects like whether changes are reversible, permission requirements, or rate limits. With annotations covering the destructive nature, the description provides basic but insufficient additional insight.

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 with zero wasted words, front-loading the core action ('Update') and resource. It's appropriately sized for the tool's complexity, making it easy for an agent to parse quickly without unnecessary elaboration.

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 the tool's complexity (6 parameters, destructive operation, no output schema), the description is inadequate. It lacks information on return values, error conditions, or how partial updates are handled (e.g., if only some fields are provided). With annotations covering only destructiveness, more context is needed for safe and 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?

The input schema has 100% description coverage, with each parameter clearly documented (e.g., 'template_id' as 'ID of the template to update'). The description adds no extra meaning beyond what the schema provides, such as explaining relationships between parameters or usage examples. Baseline 3 is appropriate since the 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 verb ('Update') and resource ('an existing email template'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'create-template' or 'list-templates' beyond the basic action, missing explicit comparison that would earn a perfect score.

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 like 'create-template' for new templates or 'delete-template' for removal. It also doesn't mention prerequisites (e.g., needing an existing template ID) or contextual constraints, leaving the agent to infer usage from the name 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/railsware/mailtrap-mcp'

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