list_email_lists
Retrieve all email marketing lists from your SendGrid account to manage contacts, organize subscribers, and create targeted 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)Handler function that performs an API request to SendGrid's marketing/lists endpoint to list email lists, with optional page_size parameter, and returns the result as formatted JSON.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)Tool configuration including title, description, and Zod input schema for the page_size parameter.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:5-23 (registration)Final registration of all tools (including list_email_lists) to the MCP server by iterating over allTools and calling server.registerTool.import { allTools } from "./tools/index.js"; import { allResources } from "./resources/index.js"; import { allPrompts } from "./prompts/index.js"; import { validateEnvironment, getSafeEnvInfo } from "./shared/env.js"; const server = new McpServer({ name: "sendgrid-mcp", version: "1.0.0", }); // Register all resources for (const [uri, resource] of Object.entries(allResources)) { server.registerResource(uri, uri, resource.config, resource.handler); } // 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:3-12 (registration)Import of contactTools and spreading into the allTools object, effectively registering list_email_lists as part of the tools collection.import { contactTools } from "./contacts.js"; import { mailTools } from "./mail.js"; import { miscTools } from "./misc.js"; import { statsTools } from "./stats.js"; import { templateTools } from "./templates.js"; export const allTools = { ...automationTools, ...campaignTools, ...contactTools,