Skip to main content
Glama

update-email-template

Modify existing email templates in the SMTP MCP Server by updating subject, body, name, or default status to maintain consistent communication.

Instructions

Update an existing email template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesID of the template to update
nameNoName of the template
subjectNoEmail subject template
bodyNoEmail body template
isDefaultNoWhether this template should be the default

Implementation Reference

  • The core handler function that implements the update-email-template tool logic. It retrieves email templates, finds the one by ID, applies updates to name, subject, body, and isDefault flag (handling default conflicts), then saves the updated template.
    /** * Handle update-email-template tool call */ async function handleUpdateEmailTemplate(parameters: any) { try { // Get existing templates const templates = await getEmailTemplates(); // Find the template to update const template = templates.find(t => t.id === parameters.id); if (!template) { return { success: false, message: `Email template with ID ${parameters.id} not found` }; } // Update the template const updatedTemplate = { ...template }; if (parameters.name !== undefined) updatedTemplate.name = parameters.name; if (parameters.subject !== undefined) updatedTemplate.subject = parameters.subject; if (parameters.body !== undefined) updatedTemplate.body = parameters.body; // Handle default flag if (parameters.isDefault !== undefined && parameters.isDefault !== template.isDefault) { updatedTemplate.isDefault = parameters.isDefault; // If setting as default, update other templates if (updatedTemplate.isDefault) { templates.forEach(t => { if (t.id !== parameters.id && t.isDefault) { t.isDefault = false; saveEmailTemplate(t).catch(err => { logToFile('Error updating template:'); logToFile(err instanceof Error ? err.message : 'Unknown error'); }); } }); } } // Save the updated template await saveEmailTemplate(updatedTemplate); return { success: true, template: updatedTemplate }; } catch (error) { logToFile('Error in handleUpdateEmailTemplate:'); logToFile(error instanceof Error ? error.message : 'Unknown error'); return { success: false, message: error instanceof Error ? error.message : 'Unknown error' }; } }
  • Defines the tool's metadata (name, description) and input schema for validation, specifying required 'id' and optional fields for updating the template.
    "update-email-template": { name: "update-email-template", description: "Update an existing email template", inputSchema: { type: "object", properties: { id: { type: "string", description: "ID of the template to update" }, name: { type: "string", description: "Name of the template" }, subject: { type: "string", description: "Email subject template" }, body: { type: "string", description: "Email body template" }, isDefault: { type: "boolean", description: "Whether this template should be the default" } }, required: ["id"] } },
  • Registers the tool handler dispatch within the MCP tool call request handler switch statement.
    case "update-email-template": return await handleUpdateEmailTemplate(toolParams);

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/samihalawa/mcp-server-smtp'

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