Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

create_contact_with_lists

Add new email contacts to specific SendGrid mailing lists for targeted email marketing campaigns.

Instructions

Create new contacts and assign them to specific email lists

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contactsYesArray of contact objects
list_idsYesArray of list IDs to add the contact to

Implementation Reference

  • The handler function that executes the tool: checks read-only mode, sends PUT request to SendGrid API to create contacts and assign to specified lists, returns the API response.
    handler: async ({ contacts, list_ids }: { contacts: any[]; list_ids: 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/contacts", { method: "PUT", body: JSON.stringify({ contacts, list_ids }), }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
  • Tool configuration including title, description, and input schema using Zod for validation.
    config: { title: "Create Contact with Lists", description: "Create new contacts and assign them to specific email lists", inputSchema: { contacts: z.array(ContactSchema).describe("Array of contact objects"), list_ids: z.array(z.string()).describe("Array of list IDs to add the contact to"), }, },
  • Zod schema for individual contact objects referenced in the tool's input schema.
    export const ContactSchema = z.object({ email: z.string().describe("Contact email address"), first_name: z.string().optional().describe("First name"), last_name: z.string().optional().describe("Last name"), custom_fields: z.record(z.any()).optional().describe("Custom field values"), });
  • Imports contactTools (containing create_contact_with_lists) and spreads it into the allTools object for global tool 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, };

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