Update Template
update_templateUpdate the name of an existing email template using its ID. Provide the template ID and new name to apply changes.
Instructions
Update the name of an existing template
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| template_id | Yes | ID of the template to update | |
| name | Yes | New name for the template |
Implementation Reference
- src/tools/templates.ts:74-85 (handler)The handler function for update_template tool. It checks read-only mode, then sends a PATCH request to SendGrid's API to update the template name.
handler: async ({ template_id, name }: { template_id: string; name: string }): Promise<ToolResult> => { const readOnlyCheck = checkReadOnlyMode(); if (readOnlyCheck.blocked) { return { content: [{ type: "text", text: readOnlyCheck.message! }] }; } const result = await makeRequest(`https://api.sendgrid.com/v3/templates/${template_id}`, { method: "PATCH", body: JSON.stringify({ name }), }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }, - src/tools/templates.ts:66-73 (schema)Input schema for update_template: defines template_id (required string) and name (required string) as Zod-validated inputs.
config: { title: "Update Template", description: "Update the name of an existing template", inputSchema: { template_id: z.string().describe("ID of the template to update"), name: z.string().describe("New name for the template"), }, }, - src/tools/templates.ts:6-6 (registration)The update_template tool is registered as a property of the exported 'templateTools' object.
export const templateTools = { - src/tools/index.ts:7-16 (registration)templateTools (including update_template) are imported and spread into the allTools export, which is used by the MCP server registration.
import { templateTools } from "./templates.js"; export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools, - src/shared/env.ts:85-94 (helper)The checkReadOnlyMode helper used by the handler to block writes when READ_ONLY is set.
export function checkReadOnlyMode(): { blocked: boolean; message?: string } { const env = getEnv(); if (env.READ_ONLY) { return { blocked: true, message: "❌ Operation blocked: Server is running in READ_ONLY mode. Set READ_ONLY=false in your environment to enable write operations." }; } return { blocked: false }; }