Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

create_contact

Add new contacts to your SendGrid email marketing lists by providing email addresses, names, and custom field data for targeted communication.

Instructions

Create new contacts in your SendGrid account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contactsYesArray of contact objects

Implementation Reference

  • The handler function that implements the core logic of the create_contact tool. It checks for read-only mode and performs a PUT request to the SendGrid API to create the provided contacts.
    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) }] }; },
  • Tool configuration including the input schema, which defines 'contacts' as an array of ContactSchema objects.
    config: { title: "Create Contact", description: "Create new contacts in your SendGrid account", inputSchema: { contacts: z.array(ContactSchema).describe("Array of contact objects"), }, },
  • Zod schema defining the structure of a single contact object used in the create_contact tool's input.
    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) and spreads it into the allTools object, aggregating all tools for 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:20-23 (registration)
    Main server registration loop that registers every tool in allTools, including create_contact, with the MCP server.
    // Register all tools 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