add_contact
Add email contacts to SendGrid marketing lists for email campaigns and audience management.
Instructions
Add a contact to your SendGrid marketing contacts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes | Contact email address | ||
| first_name | No | Contact first name (optional) | |
| last_name | No | Contact last name (optional) | |
| custom_fields | No | Custom field values (optional) |
Implementation Reference
- src/services/sendgrid.ts:64-73 (handler)Core handler function in SendGridService that adds a single contact by sending a PUT request to SendGrid's /v3/marketing/contacts endpoint.async addContact(contact: SendGridContact) { const [response] = await this.client.request({ method: 'PUT', url: '/v3/marketing/contacts', body: { contacts: [contact] } }); return response; }
- src/tools/index.ts:399-401 (handler)Tool call handler case in handleToolCall that invokes the service.addContact method with tool arguments and returns a success response.case 'add_contact': await service.addContact(args as SendGridContact); return { content: [{ type: 'text', text: `Contact ${args.email} added successfully` }] };
- src/tools/index.ts:69-94 (registration)Registration of the 'add_contact' tool in getToolDefinitions, including name, description, and input schema for MCP tool protocol.{ name: 'add_contact', description: 'Add a contact to your SendGrid marketing contacts', inputSchema: { type: 'object', properties: { email: { type: 'string', description: 'Contact email address' }, first_name: { type: 'string', description: 'Contact first name (optional)' }, last_name: { type: 'string', description: 'Contact last name (optional)' }, custom_fields: { type: 'object', description: 'Custom field values (optional)' } }, required: ['email'] } },
- src/types/index.ts:3-9 (schema)TypeScript interface defining the structure of a SendGridContact, used for type safety in the addContact handler and matching the tool inputSchema.export interface SendGridContact { id?: string; email: string; first_name?: string; last_name?: string; custom_fields?: Record<string, any>; }