Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

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
NameRequiredDescriptionDefault
contact_idsYesArray of contact IDs to remove from the list
list_idYesID of the list to remove contacts from

Implementation Reference

  • 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) }] }; },
  • 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); }

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/deyikong/sendgrid-mcp'

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