list_contacts
Retrieve all stored contacts from your SendGrid email marketing account to manage your subscriber database and communication lists.
Instructions
List all contacts in your SendGrid account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/index.ts:382-393 (handler)The handler function for the 'list_contacts' tool in the handleToolCall switch statement. It calls service.listAllContacts() and formats the response as JSON text.
case 'list_contacts': const allContacts = await service.listAllContacts(); return { content: [{ type: 'text', text: JSON.stringify(allContacts.map(c => ({ email: c.email, first_name: c.first_name, last_name: c.last_name })), null, 2) }] }; - src/tools/index.ts:22-30 (schema)The tool schema definition including name, description, and empty inputSchema (no parameters required). Part of getToolDefinitions array used for MCP tool registration.
{ name: 'list_contacts', description: 'List all contacts in your SendGrid account', inputSchema: { type: 'object', properties: {}, required: [] } }, - src/services/sendgrid.ts:53-62 (helper)The SendGridService method listAllContacts() that performs the API call to search and retrieve all contacts.
async listAllContacts(): Promise<SendGridContact[]> { const [response] = await this.client.request({ method: 'POST', url: '/v3/marketing/contacts/search', body: { query: "email IS NOT NULL" // Get all contacts that have an email } }); return (response.body as { result: SendGridContact[] }).result || []; }