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
| Name | Required | Description | Default |
|---|---|---|---|
| segment_id | Yes | ID of the segment to delete |
Implementation Reference
- src/tools/contacts.ts:530-540 (handler)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.` }] }; },
- src/tools/contacts.ts:523-529 (schema)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"), }, },
- src/tools/contacts.ts:522-541 (registration)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.` }] }; }, },
- src/tools/index.ts:9-16 (registration)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); }