Delete Custom Field
delete_custom_fieldRemove a custom field definition from your SendGrid account by providing its unique field ID.
Instructions
Delete a custom field definition
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| field_id | Yes | ID of the custom field to delete |
Implementation Reference
- src/tools/contacts.ts:234-253 (handler)Handler function that deletes a custom field definition by sending a DELETE request to SendGrid's marketing field_definitions API. It first checks read-only mode, then sends the DELETE request and returns a success message.
delete_custom_field: { config: { title: "Delete Custom Field", description: "Delete a custom field definition", inputSchema: { field_id: z.string().describe("ID of the custom field to delete"), }, }, handler: async ({ field_id }: { field_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/field_definitions/${field_id}`, { method: "DELETE", }); return { content: [{ type: "text", text: `Custom field ${field_id} deleted successfully.` }] }; }, }, - src/tools/contacts.ts:235-240 (schema)Input schema for delete_custom_field, requiring a single field_id string parameter.
config: { title: "Delete Custom Field", description: "Delete a custom field definition", inputSchema: { field_id: z.string().describe("ID of the custom field to delete"), }, - src/tools/index.ts:9-17 (registration)Registration: contactTools (which includes delete_custom_field) is spread into the allTools export object.
export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools, }; - src/index.ts:20-23 (registration)Registration: All tools including delete_custom_field are registered with the MCP server via registerTool.
// Register all tools for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); } - src/shared/api.ts:3-18 (helper)Helper function makeRequest used by the handler to make HTTP requests to the SendGrid API.
export async function makeRequest(url: string, options: RequestInit = {}): Promise<any> { const response = await fetch(url, { headers: { ...getAuthHeaders(), ...options.headers, }, ...options, }); if (!response.ok) { const errorText = await response.text(); throw new Error(`SendGrid API error (${response.status}): ${errorText}`); } return response.json(); }