Skip to main content
Glama

delete-email-template

Remove an email template from the SMTP MCP Server by specifying its ID to manage your email template collection.

Instructions

Delete an email template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesID of the template to delete

Implementation Reference

  • The primary handler function for the 'delete-email-template' tool. It retrieves all templates, verifies the target template exists, handles reassignment of the default template if necessary, calls the low-level delete function, and returns appropriate success/error responses.
    async function handleDeleteEmailTemplate(parameters: any) { try { // Get existing templates const templates = await getEmailTemplates(); // Find the template to delete const template = templates.find(t => t.id === parameters.id); if (!template) { return { success: false, message: `Email template with ID ${parameters.id} not found` }; } // If deleting default template, make another one default if (template.isDefault && templates.length > 1) { const anotherTemplate = templates.find(t => t.id !== parameters.id); if (anotherTemplate) { anotherTemplate.isDefault = true; await saveEmailTemplate(anotherTemplate); } } // Delete the template await deleteEmailTemplate(parameters.id); return { success: true, message: 'Email template deleted successfully' }; } catch (error) { logToFile('Error in handleDeleteEmailTemplate:'); logToFile(error instanceof Error ? error.message : 'Unknown error'); return { success: false, message: error instanceof Error ? error.message : 'Unknown error' }; } }
  • Tool definition and input schema for 'delete-email-template', specifying the required 'id' parameter.
    "delete-email-template": { name: "delete-email-template", description: "Delete an email template", inputSchema: { type: "object", properties: { id: { type: "string", description: "ID of the template to delete" } }, required: ["id"] } },
  • Low-level utility function that deletes the specified email template file from the filesystem.
    export async function deleteEmailTemplate(templateId: string): Promise<boolean> { try { const templatePath = path.join(TEMPLATES_DIR, `${templateId}.json`); await fs.remove(templatePath); return true; } catch (error) { logToFile('Error deleting email template:'); return false; } }
  • Switch case registration that dispatches 'delete-email-template' tool calls to the handler function.
    case "delete-email-template": return await handleDeleteEmailTemplate(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