Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

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

Implementation Reference

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

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