Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

update_contact

Modify existing contact details in SendGrid, including email, name, address, phone, and custom fields to maintain accurate subscriber information.

Instructions

Update existing contact information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contactsYesArray of contact objects with updates

Implementation Reference

  • Handler function for update_contact tool. Checks read-only mode, then sends a PUT request to SendGrid's /marketing/contacts endpoint with the updated contacts array.
    handler: async ({ contacts }: { contacts: any[] }): 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/contacts", { method: "PUT", body: JSON.stringify({ contacts }), }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
  • Zod input schema for update_contact tool, defining the structure of contacts array with optional fields for updating contact information.
    inputSchema: { contacts: z.array( z.object({ id: z.string().describe("Contact ID (required for updates)"), email: z.string().email().optional().describe("Email address"), first_name: z.string().optional().describe("First name"), last_name: z.string().optional().describe("Last name"), phone_number: z.string().optional().describe("Phone number"), address_line_1: z.string().optional().describe("Address line 1"), address_line_2: z.string().optional().describe("Address line 2"), city: z.string().optional().describe("City"), state_province_region: z.string().optional().describe("State/Province/Region"), postal_code: z.string().optional().describe("Postal code"), country: z.string().optional().describe("Country"), custom_fields: z.record(z.any()).optional().describe("Custom field values"), }) ).describe("Array of contact objects with updates"), },
  • Definition and registration of the update_contact tool within the contactTools object.
    update_contact: { config: { title: "Update Contact", description: "Update existing contact information", inputSchema: { contacts: z.array( z.object({ id: z.string().describe("Contact ID (required for updates)"), email: z.string().email().optional().describe("Email address"), first_name: z.string().optional().describe("First name"), last_name: z.string().optional().describe("Last name"), phone_number: z.string().optional().describe("Phone number"), address_line_1: z.string().optional().describe("Address line 1"), address_line_2: z.string().optional().describe("Address line 2"), city: z.string().optional().describe("City"), state_province_region: z.string().optional().describe("State/Province/Region"), postal_code: z.string().optional().describe("Postal code"), country: z.string().optional().describe("Country"), custom_fields: z.record(z.any()).optional().describe("Custom field values"), }) ).describe("Array of contact objects with updates"), }, }, handler: async ({ contacts }: { contacts: any[] }): 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/contacts", { method: "PUT", body: JSON.stringify({ contacts }), }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }, },
  • Registration of contactTools (including update_contact) into the allTools object exported for use in MCP.
    export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools,

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