Skip to main content
Glama
Garoth

SendGrid MCP Server

by Garoth

delete_contacts

Remove email addresses from your SendGrid contact database to maintain clean mailing lists and comply with data privacy requirements.

Instructions

Delete contacts from your SendGrid account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailsYesArray of email addresses to delete

Implementation Reference

  • Core handler function that implements deleting SendGrid contacts by first searching for them by email addresses and then deleting them using the SendGrid Marketing Contacts API.
    async deleteContactsByEmails(emails: string[]): Promise<void> { // First get the contact IDs for the emails const [searchResponse] = await this.client.request({ method: 'POST', url: '/v3/marketing/contacts/search', body: { query: `email IN (${emails.map(email => `'${email}'`).join(',')})` } }); const contacts = (searchResponse.body as { result: SendGridContact[] }).result || []; const contactIds = contacts.map(contact => contact.id).filter(id => id) as string[]; if (contactIds.length > 0) { // Then delete the contacts by their IDs await this.client.request({ method: 'DELETE', url: '/v3/marketing/contacts', qs: { ids: contactIds.join(',') } }); } }
  • Tool registration within getToolDefinitions array, defining name, description, and input schema for the delete_contacts tool.
    { name: 'delete_contacts', description: 'Delete contacts from your SendGrid account', inputSchema: { type: 'object', properties: { emails: { type: 'array', items: { type: 'string' }, description: 'Array of email addresses to delete' } }, required: ['emails'] } },
  • Input schema definition specifying that delete_contacts requires an array of email strings.
    inputSchema: { type: 'object', properties: { emails: { type: 'array', items: { type: 'string' }, description: 'Array of email addresses to delete' } }, required: ['emails'] }
  • Dispatcher in handleToolCall that invokes the deleteContactsByEmails service method and formats the tool response.
    case 'delete_contacts': await service.deleteContactsByEmails(args.emails); return { content: [{ type: 'text', text: `Successfully deleted ${args.emails.length} contacts` }] };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Garoth/sendgrid-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server