remove_contact_from_lists
Remove specific contacts from an email marketing list in SendGrid to manage subscriber data and maintain list accuracy.
Instructions
Remove contacts from a specific email list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | ID of the list to remove contacts from | |
| contact_ids | Yes | Array of contact IDs to remove from the list |
Implementation Reference
- src/tools/contacts.ts:338-348 (handler)The main handler function that implements the remove_contact_from_lists tool by sending a DELETE request to the SendGrid API to remove specified contacts from a given list, with read-only mode check.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)Configuration including title, description, and Zod input schema for validating 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/tools/index.ts:3-10 (registration)Imports contactTools (which contains remove_contact_from_lists) and spreads it into the allTools object for top-level registration.import { contactTools } from "./contacts.js"; import { mailTools } from "./mail.js"; import { miscTools } from "./misc.js"; import { statsTools } from "./stats.js"; import { templateTools } from "./templates.js"; export const allTools = { ...automationTools,
- src/index.ts:5-23 (registration)Imports allTools and loops through to register each tool (including remove_contact_from_lists) with the MCP server using registerTool.import { allTools } from "./tools/index.js"; import { allResources } from "./resources/index.js"; import { allPrompts } from "./prompts/index.js"; import { validateEnvironment, getSafeEnvInfo } from "./shared/env.js"; const server = new McpServer({ name: "sendgrid-mcp", version: "1.0.0", }); // Register all resources for (const [uri, resource] of Object.entries(allResources)) { server.registerResource(uri, uri, resource.config, resource.handler); } // Register all tools for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }