Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

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
NameRequiredDescriptionDefault
nameYesName of the custom field
field_typeYesType of the field

Implementation Reference

  • 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) }] }; },
  • 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"), }, },
  • 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) }] }; }, },
  • contactTools (including create_custom_field) is merged into the allTools export used for MCP tool registration.
    ...contactTools,

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