Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

create_custom_field

Add custom fields to SendGrid contacts to store additional data like text, numbers, or dates for enhanced contact management and segmentation.

Instructions

Create a new custom field for contacts

Input Schema

NameRequiredDescriptionDefault
field_typeYesType of the field
nameYesName of the custom field

Input Schema (JSON Schema)

{ "properties": { "field_type": { "description": "Type of the field", "enum": [ "Text", "Number", "Date" ], "type": "string" }, "name": { "description": "Name of the custom field", "type": "string" } }, "required": [ "name", "field_type" ], "type": "object" }

Implementation Reference

  • The handler function implements the core logic: checks if in read-only mode, then sends a POST request to SendGrid API to create the custom field with given name and type.
    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 including title, description, and Zod inputSchema for parameters '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"), }, },
  • Imports contactTools (which includes create_custom_field) and spreads it into the allTools object exported for main server registration.
    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:21-23 (registration)
    Registers all tools from allTools, including create_custom_field, to the MCP server using registerTool with config and handler.
    for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); }

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