list_templates
Retrieve all transactional email templates (legacy and dynamic) from SendGrid to manage and organize your email marketing campaigns and automated communications.
Instructions
Retrieve all transactional templates (legacy and dynamic)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| generations | No | Filter by template generation (legacy or dynamic) | |
| page_size | No | Number of templates to return (max 200) |
Implementation Reference
- src/tools/templates.ts:16-22 (handler)The handler function that executes the list_templates tool, fetching templates from SendGrid API with optional filters.handler: async ({ generations, page_size }: { generations?: string; page_size?: number }): Promise<ToolResult> => { let url = `https://api.sendgrid.com/v3/templates?page_size=${page_size || 50}`; if (generations) url += `&generations=${generations}`; const result = await makeRequest(url); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
- src/tools/templates.ts:11-14 (schema)Zod schema for input validation of the list_templates tool parameters.inputSchema: { generations: z.string().optional().describe("Filter by template generation (legacy or dynamic)"), page_size: z.number().optional().default(50).describe("Number of templates to return (max 200)"), },
- src/tools/index.ts:9-17 (registration)Includes templateTools (containing list_templates) into the allTools export.export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools, };
- src/index.ts:21-23 (registration)Registers all tools from allTools with the MCP server, including list_templates.for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }