Get Contact Details
get_contactRetrieve detailed information about a specific contact using its ID for email marketing and transactional email operations.
Instructions
Get detailed information about a specific contact by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contact_id | Yes | ID of the contact to retrieve |
Implementation Reference
- src/tools/contacts.ts:351-362 (handler)The get_contact tool definition including the config (title, description, inputSchema with contact_id) and the handler that makes a GET request to the SendGrid marketing contacts API endpoint.
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/tools/contacts.ts:355-357 (schema)Input schema for get_contact - requires a contact_id string parameter.
inputSchema: { contact_id: z.string().describe("ID of the contact to retrieve"), }, - src/index.ts:20-23 (registration)Tools are registered dynamically by iterating allTools, which includes contactTools spread from src/tools/contacts.ts. The name 'get_contact' is used as the tool name when registered.
// Register all tools for (const [name, tool] of Object.entries(allTools)) { server.registerTool(name, tool.config as any, tool.handler as any); } - src/shared/api.ts:3-18 (helper)The makeRequest helper used by get_contact's handler to call the SendGrid API with authentication headers.
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(); } - src/tools/index.ts:3-12 (registration)contactTools (which contains get_contact) is imported and spread into allTools 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,