Skip to main content
Glama
deyikong

SendGrid MCP Server

by deyikong

get_contact

Retrieve detailed contact information from SendGrid by providing a contact ID for email marketing and management purposes.

Instructions

Get detailed information about a specific contact by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contact_idYesID of the contact to retrieve

Implementation Reference

  • The handler function executes the tool logic by fetching the contact details from the SendGrid API using the provided contact_id and returning the result as formatted JSON.
    handler: async ({ contact_id }: { contact_id: string }): Promise<ToolResult> => {
      const result = await makeRequest(`https://api.sendgrid.com/v3/marketing/contacts/${contact_id}`);
      return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    },
  • Zod input schema validating the 'contact_id' parameter as a required string.
    inputSchema: {
      contact_id: z.string().describe("ID of the contact to retrieve"),
    },
  • The 'get_contact' tool is registered as part of the contactTools object exported from contacts.ts, which is then aggregated into allTools.
    get_contact: {
      config: {
        title: "Get Contact Details",
        description: "Get detailed information about a specific contact by ID",
        inputSchema: {
          contact_id: z.string().describe("ID of the contact to retrieve"),
        },
      },
      handler: async ({ contact_id }: { contact_id: string }): Promise<ToolResult> => {
        const result = await makeRequest(`https://api.sendgrid.com/v3/marketing/contacts/${contact_id}`);
        return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
      },
    },
  • src/index.ts:21-23 (registration)
    Final registration of all tools, including 'get_contact', to the MCP server using a loop over allTools.
    for (const [name, tool] of Object.entries(allTools)) {
      server.registerTool(name, tool.config as any, tool.handler as any);
    }
  • Aggregation of contactTools (containing get_contact) into the allTools object.
    export const allTools = {
      ...automationTools,
      ...campaignTools,
      ...contactTools,

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