add_contacts_to_list
Add email addresses to a SendGrid contact list for email marketing campaigns. Specify the list ID and email array to manage subscriber groups.
Instructions
Add contacts to an existing SendGrid list
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"list_id": "<list_id>",
"emails": "<emails>"
},
"name": "add_contacts_to_list"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | ID of the contact list | |
| emails | Yes | Array of email addresses to add to the list |
Implementation Reference
- src/services/sendgrid.ts:118-128 (handler)Core handler function that implements adding contacts to a SendGrid marketing list by updating contacts with the list_ids.
async addContactsToList(listId: string, contactEmails: string[]) { const [response] = await this.client.request({ method: 'PUT', url: '/v3/marketing/contacts', body: { list_ids: [listId], contacts: contactEmails.map(email => ({ email })) } }); return response; } - src/tools/index.ts:112-128 (schema)Input schema defining parameters list_id and emails for the add_contacts_to_list tool.
inputSchema: { type: 'object', properties: { list_id: { type: 'string', description: 'ID of the contact list' }, emails: { type: 'array', items: { type: 'string' }, description: 'Array of email addresses to add to the list' } }, required: ['list_id', 'emails'] } - src/tools/index.ts:109-129 (registration)Tool definition and registration within the getToolDefinitions array.
{ name: 'add_contacts_to_list', description: 'Add contacts to an existing SendGrid list', inputSchema: { type: 'object', properties: { list_id: { type: 'string', description: 'ID of the contact list' }, emails: { type: 'array', items: { type: 'string' }, description: 'Array of email addresses to add to the list' } }, required: ['list_id', 'emails'] } }, - src/tools/index.ts:407-409 (helper)Dispatcher case in handleToolCall that invokes the service handler and formats the response.
case 'add_contacts_to_list': await service.addContactsToList(args.list_id, args.emails); return { content: [{ type: 'text', text: `Added ${args.emails.length} contacts to list ${args.list_id}` }] };