Skip to main content
Glama

add-email-template

Create reusable email templates with customizable subject and body content for automated email sending through SMTP MCP Server.

Instructions

Add a new email template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the template
subjectYesEmail subject template
bodyYesEmail body template
isDefaultNoWhether this template should be the default

Implementation Reference

  • The core handler function that implements the add-email-template tool logic. It retrieves existing templates, creates a new EmailTemplate with a generated UUID, handles the isDefault flag by unsetting it on other default templates, saves the new template, and returns success with the new template details or error information.
    async function handleAddEmailTemplate(parameters: any) { try { // Get existing templates const templates = await getEmailTemplates(); // Create a new template const newTemplate: EmailTemplate = { id: generateUUID(), name: parameters.name, subject: parameters.subject, body: parameters.body, isDefault: parameters.isDefault ?? false }; // If this is set as default, we'll need to update other templates if (newTemplate.isDefault) { templates.forEach(template => { if (template.isDefault) { template.isDefault = false; saveEmailTemplate(template).catch(err => { logToFile('Error updating template:'); logToFile(err instanceof Error ? err.message : 'Unknown error'); }); } }); } // Save the new template await saveEmailTemplate(newTemplate); return { success: true, template: newTemplate }; } catch (error) { logToFile('Error in handleAddEmailTemplate:'); logToFile(error instanceof Error ? error.message : 'Unknown error'); return { success: false, message: error instanceof Error ? error.message : 'Unknown error' }; } }
  • Tool definition including name, description, and input schema specifying required parameters: name, subject, body; optional: isDefault.
    "add-email-template": { name: "add-email-template", description: "Add a new email template", inputSchema: { type: "object", properties: { 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: ["name", "subject", "body"] } },
  • The switch case in the CallToolRequestSchema handler that routes 'add-email-template' tool calls to the handleAddEmailTemplate function.
    case "add-email-template": return await handleAddEmailTemplate(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