list_templates
Retrieve all transactional email templates (legacy and dynamic) from SendGrid for managing email campaigns and automation workflows.
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 implements the core logic of the list_templates tool. It constructs the SendGrid API endpoint URL with optional parameters for filtering by template generation and pagination, fetches the data, and returns the result as formatted JSON.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:8-15 (schema)The tool configuration object defining the title, description, and Zod-based input schema for validating parameters 'generations' (optional string filter) and 'page_size' (optional number, default 50).config: { title: "List All Templates", description: "Retrieve all transactional templates (legacy and dynamic)", 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:7-16 (registration)Registration of the templateTools (including list_templates) by importing from templates.ts and spreading into the central allTools export, which serves as the MCP tools registry.import { templateTools } from "./templates.js"; export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools,