list_email_lists
Retrieve all email marketing lists from SendGrid to manage contacts, segment audiences, and organize recipients for campaigns.
Instructions
List all email lists
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page_size | No | Number of results to return |
Implementation Reference
- src/tools/contacts.ts:15-18 (handler)The handler function that implements the core logic of the list_email_lists tool by making an API request to SendGrid's marketing lists endpoint.handler: async ({ page_size }: { page_size: number }): Promise<ToolResult> => { const result = await makeRequest(`https://api.sendgrid.com/v3/marketing/lists?page_size=${page_size}`); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
- src/tools/contacts.ts:8-14 (schema)Configuration object defining the tool's metadata and input schema using Zod for validation.config: { title: "List Email Lists", description: "List all email lists", inputSchema: { page_size: z.number().optional().default(1000).describe("Number of results to return"), }, },
- src/index.ts:21-23 (registration)Registration of all tools with the MCP server, including list_email_lists via the allTools object.for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }
- src/tools/index.ts:12-12 (registration)Inclusion of contactTools (containing list_email_lists) into the allTools export....contactTools,
- src/tools/contacts.ts:2-2 (helper)Import of the makeRequest helper used in the handler to perform authenticated API calls.import { makeRequest } from "../shared/api.js";