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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the template to delete |
Implementation Reference
- src/requestHandler.ts:534-573 (handler)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' }; } }
- src/tools.ts:353-366 (schema)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"] } },
- src/config.ts:249-258 (helper)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; } }
- src/requestHandler.ts:96-97 (registration)Switch case registration that dispatches 'delete-email-template' tool calls to the handler function.case "delete-email-template": return await handleDeleteEmailTemplate(toolParams);