create_custom_field
Add custom fields to SendGrid contacts to store specific data like text, numbers, or dates for targeted email marketing and segmentation.
Instructions
Create a new custom field for contacts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the custom field | |
| field_type | Yes | Type of the field |
Implementation Reference
- src/tools/contacts.ts:197-208 (handler)The handler function that executes the tool logic: checks read-only mode and makes a POST request to SendGrid API to create the custom field.handler: async ({ name, field_type }: { name: string; field_type: 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", { method: "POST", body: JSON.stringify({ name, field_type }), }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
- src/tools/contacts.ts:189-196 (schema)Tool configuration with input schema using Zod for name (string) and field_type (enum: Text, Number, Date).config: { title: "Create Custom Field", description: "Create a new custom field for contacts", inputSchema: { name: z.string().describe("Name of the custom field"), field_type: z.enum(["Text", "Number", "Date"]).describe("Type of the field"), }, },
- src/tools/contacts.ts:188-209 (registration)The tool 'create_custom_field' is defined and registered within the contactTools object exported from this file.create_custom_field: { config: { title: "Create Custom Field", description: "Create a new custom field for contacts", inputSchema: { name: z.string().describe("Name of the custom field"), field_type: z.enum(["Text", "Number", "Date"]).describe("Type of the field"), }, }, handler: async ({ name, field_type }: { name: string; field_type: 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", { method: "POST", body: JSON.stringify({ name, field_type }), }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }, },
- src/tools/index.ts:12-12 (registration)contactTools (including create_custom_field) is merged into the allTools export used for MCP tool registration....contactTools,