Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

delete_segment

Remove a contact segment from your SendGrid account to maintain organized email lists and improve marketing efficiency.

Instructions

Delete an existing segment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
segment_idYesID of the segment to delete

Implementation Reference

  • The handler function that executes the delete_segment tool. It checks read-only mode, then sends a DELETE request to the SendGrid Marketing API to delete the specified segment.
    handler: async ({ segment_id }: { segment_id: 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/segments/2.0/${segment_id}`, { method: "DELETE", }); return { content: [{ type: "text", text: `Segment ${segment_id} deleted successfully.` }] }; },
  • Tool configuration including title, description, and Zod input schema for validating the segment_id parameter.
    config: { title: "Delete Segment", description: "Delete an existing segment", inputSchema: { segment_id: z.string().describe("ID of the segment to delete"), }, },
  • Definition and registration of the delete_segment tool within the contactTools object.
    delete_segment: { config: { title: "Delete Segment", description: "Delete an existing segment", inputSchema: { segment_id: z.string().describe("ID of the segment to delete"), }, }, handler: async ({ segment_id }: { segment_id: 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/segments/2.0/${segment_id}`, { method: "DELETE", }); return { content: [{ type: "text", text: `Segment ${segment_id} deleted successfully.` }] }; }, },
  • Spreads contactTools (containing delete_segment) into the allTools object for global tool registry.
    export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools,
  • src/index.ts:21-23 (registration)
    Registers all tools from allTools, including delete_segment, with the MCP server using registerTool.
    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