create_template
Create dynamic transactional email templates for automated email campaigns and personalized communications using SendGrid's API.
Instructions
Create a new dynamic transactional template
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| generation | No | Template generation type | dynamic |
| name | Yes | Name of the template |
Input Schema (JSON Schema)
{
"properties": {
"generation": {
"default": "dynamic",
"description": "Template generation type",
"enum": [
"legacy",
"dynamic"
],
"type": "string"
},
"name": {
"description": "Name of the template",
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
}
Implementation Reference
- src/tools/templates.ts:48-62 (handler)The handler function that implements the core logic for creating a new SendGrid dynamic template via API POST request, including read-only mode check.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)Tool configuration including title, description, and Zod input schema for validating 'name' and optional 'generation' parameters.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:20-23 (registration)Registers all tools from allTools (which includes create_template) with the MCP server using registerTool.// Register all tools for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }
- src/tools/index.ts:9-17 (registration)Combines all tool objects including templateTools (containing create_template) into allTools export for top-level registration.export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools, };