delete-template
Remove an email template from the Mailtrap MCP server by specifying its ID to clean up unused or outdated templates.
Instructions
Delete an existing email template
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| template_id | Yes | ID of the template to delete |
Implementation Reference
- The main handler function for the 'delete-template' tool. It uses the Mailtrap client to delete the template by ID and returns a success or error message in the specified format.
async function deleteTemplate({ template_id, }: DeleteTemplateRequest): Promise<{ content: any[]; isError?: boolean }> { try { if (!client) { throw new Error("MAILTRAP_API_TOKEN environment variable is required"); } await client.templates.delete(template_id); return { content: [ { type: "text", text: `Template with ID ${template_id} deleted successfully!`, }, ], }; } catch (error) { console.error("Error deleting template:", error); const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to delete template: ${errorMessage}`, }, ], isError: true, }; } } - Input schema (JSON Schema) for the 'delete-template' tool, validating the required 'template_id' parameter.
const deleteTemplateSchema = { type: "object", properties: { template_id: { type: "number", description: "ID of the template to delete", }, }, required: ["template_id"], additionalProperties: false, }; export default deleteTemplateSchema; - src/server.ts:73-81 (registration)Registration of the 'delete-template' tool within the tools array in the MCP server setup.
{ name: "delete-template", description: "Delete an existing email template", inputSchema: deleteTemplateSchema, handler: deleteTemplate, annotations: { destructiveHint: true, }, },