Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

Update Contact

update_contact

Update existing contact details in SendGrid by providing the contact ID and new field values.

Instructions

Update existing contact information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contactsYesArray of contact objects with updates

Implementation Reference

  • The handler function for update_contact tool. Accepts an array of contact objects with updates, checks read-only mode, then makes a PUT request to SendGrid's marketing contacts API endpoint.
    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) }] };
    },
  • Input schema for update_contact. Defines a Zod array of contact objects with required 'id' field and optional fields: email, first_name, last_name, phone_number, address fields, and custom_fields.
    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"),
    },
  • Tool registration within the contactTools object (exported from src/tools/contacts.ts). The tool is then spread into the allTools export in src/tools/index.ts.
    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) }] };
      },
    },
  • Helper function checkReadOnlyMode used by the update_contact handler to block write operations when READ_ONLY is enabled.
    export function checkReadOnlyMode(): { blocked: boolean; message?: string } {
      const env = getEnv();
      if (env.READ_ONLY) {
        return {
          blocked: true,
          message: "❌ Operation blocked: Server is running in READ_ONLY mode. Set READ_ONLY=false in your environment to enable write operations."
        };
      }
      return { blocked: false };
    }
  • Helper function makeRequest used by the update_contact handler to make the HTTP PUT request to the SendGrid API.
    export async function makeRequest(url: string, options: RequestInit = {}): Promise<any> {
      const response = await fetch(url, {
        headers: {
          ...getAuthHeaders(),
          ...options.headers,
        },
        ...options,
      });
    
      if (!response.ok) {
        const errorText = await response.text();
        throw new Error(`SendGrid API error (${response.status}): ${errorText}`);
      }
    
      return response.json();
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations and the description does not disclose behavioral traits like idempotency, merge semantics, required permissions, or error conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no redundant information. Could be expanded slightly to include behavioral notes without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema and no behavioral context provided. The description fails to mention merge behavior or that the contact must exist, which is essential for correct usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% coverage with descriptions for each field, so baseline is 3. The description adds no additional parameter meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'update' and resource 'contact', distinguishing it from siblings like create_contact or delete_contact.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives (e.g., when updating vs creating), nor any mention of prerequisites such as the contact must exist.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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