list_contacts
Retrieve all contacts from your SendGrid account with pagination support to manage large contact lists efficiently.
Instructions
List all contacts with optional pagination
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page_size | No | Number of contacts to return (max 1000) | |
| page_token | No | Token for pagination |
Implementation Reference
- src/tools/contacts.ts:454-460 (handler)The handler function that executes the list_contacts tool logic by fetching paginated contacts from the SendGrid Marketing API.handler: async ({ page_size, page_token }: { page_size?: number; page_token?: string }): Promise<ToolResult> => { let url = `https://api.sendgrid.com/v3/marketing/contacts?page_size=${page_size || 100}`; if (page_token) url += `&page_token=${page_token}`; const result = await makeRequest(url); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
- src/tools/contacts.ts:446-453 (schema)The tool configuration object defining title, description, and Zod input schema for pagination parameters.config: { title: "List All Contacts", description: "List all contacts with optional pagination", inputSchema: { page_size: z.number().optional().default(100).describe("Number of contacts to return (max 1000)"), page_token: z.string().optional().describe("Token for pagination"), }, },
- src/index.ts:21-23 (registration)Dynamic registration loop that calls server.registerTool for every tool in allTools, including 'list_contacts'.for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }