delete_segment
Remove a contact segment from your SendGrid email marketing lists to maintain organized audience targeting.
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 performs the actual deletion of a segment using SendGrid's API DELETE request, with read-only mode check.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)The tool's configuration including title, description, and Zod input schema 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/index.ts:2-17 (registration)Local registration of contactTools (containing delete_segment) into the allTools object by spreading.import { campaignTools } from "./campaigns.js"; 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, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools, };
- src/index.ts:5-23 (registration)Top-level registration loop that registers all tools from allTools (including delete_segment) with the MCP server.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); }