remove_contact_from_lists
Remove specific contacts from email marketing lists to manage subscriber groups and maintain list accuracy for targeted communications.
Instructions
Remove contacts from a specific email list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contact_ids | Yes | Array of contact IDs to remove from the list | |
| list_id | Yes | ID of the list to remove contacts from |
Implementation Reference
- src/tools/contacts.ts:338-348 (handler)The handler function that implements the core logic of the 'remove_contact_from_lists' tool. It checks for read-only mode and then issues a DELETE request to the SendGrid Marketing Campaigns API to remove the specified contact IDs from the given list ID.handler: async ({ list_id, contact_ids }: { list_id: string; contact_ids: string[] }): Promise<ToolResult> => { const readOnlyCheck = checkReadOnlyMode(); if (readOnlyCheck.blocked) { return { content: [{ type: "text", text: readOnlyCheck.message! }] }; } const result = await makeRequest(`https://api.sendgrid.com/v3/marketing/lists/${list_id}/contacts?contact_ids=${contact_ids.join(',')}`, { method: "DELETE", }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
- src/tools/contacts.ts:330-337 (schema)The tool configuration including title, description, and Zod input schema defining parameters list_id (string) and contact_ids (array of strings).config: { title: "Remove Contacts from a Specific List", description: "Remove contacts from a specific email list", inputSchema: { list_id: z.string().describe("ID of the list to remove contacts from"), contact_ids: z.array(z.string()).describe("Array of contact IDs to remove from the list"), }, },
- src/index.ts:21-23 (registration)The MCP server registration loop that dynamically registers all tools from the allTools object, including 'remove_contact_from_lists', by iterating over entries and calling server.registerTool for each.for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }