update_template
Modify the name of an existing email template in SendGrid to reflect content changes or organizational updates.
Instructions
Update the name of an existing template
Input Schema
TableJSON 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 that checks for read-only mode and sends a PATCH request to the SendGrid 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)Tool configuration including title, description, and Zod input schema defining the required parameters: template_id and name.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:65-86 (registration)The complete tool definition and registration within the exported templateTools object.update_template: { 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"), }, }, 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/index.ts:7-17 (registration)Import of templateTools and spreading into the allTools export, aggregating all tools for higher-level registration.import { templateTools } from "./templates.js"; export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools, };
- src/index.ts:21-23 (registration)Loop that registers every tool from allTools with the MCP server using registerTool.for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }