create_template
Create dynamic transactional email templates in SendGrid to automate personalized communications and streamline email workflows.
Instructions
Create a new dynamic transactional template
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the template | |
| generation | No | Template generation type | dynamic |
Implementation Reference
- src/tools/templates.ts:48-62 (handler)The async handler function that implements the core logic of the 'create_template' tool. It performs a read-only mode check, then sends a POST request to the SendGrid API to create a new template with the provided name and optional generation type.handler: async ({ name, generation }: { name: string; generation?: 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", { method: "POST", body: JSON.stringify({ name, generation: generation || "dynamic" }), }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
- src/tools/templates.ts:40-47 (schema)The tool configuration including title, description, and Zod input schema defining the parameters: required 'name' (string) and optional 'generation' (enum: legacy or dynamic, defaults to dynamic).config: { title: "Create New Template", description: "Create a new dynamic transactional template", inputSchema: { name: z.string().describe("Name of the template"), generation: z.enum(["legacy", "dynamic"]).optional().default("dynamic").describe("Template generation type"), }, },
- src/index.ts:21-23 (registration)The MCP server tool registration loop that dynamically registers all tools from the allTools object, including 'create_template' from the templates tools group.for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }
- src/tools/index.ts:16-16 (registration)Aggregation of all template tools (including create_template) into the central allTools export via object spread....templateTools,