dex_get_contact
Retrieve a contact's details and timeline entries by ID from Dex CRM, with automatic pagination for notes.
Instructions
Retrieve a single contact by ID. Automatically fetches the contact's notes/timeline entries and includes them in the response under a 'notes' key. Use notesLimit to control how many notes are fetched (default 50). If the contact has more notes than a single page, pagination is handled automatically.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contactId | Yes | ||
| includeNotes | No | Fetch and include the contact's notes/timeline entries. Defaults to true. | |
| notesLimit | No | Max number of notes to fetch. Defaults to 50. Paginated automatically if above 50. |
Implementation Reference
- src/tools/contacts.ts:140-186 (handler)The handler function for 'dex_get_contact' that fetches contact data and associated timeline notes.
async (args) => { try { const fetchNotes = args.includeNotes !== false; const notesLimit = args.notesLimit ?? 50; const PAGE_SIZE = 50; const contactPromise = dex.get<Record<string, unknown>>( `/v1/contacts/${args.contactId}` ); if (!fetchNotes) { return toResult(await contactPromise); } const firstPage = await dex.get<{ data?: { items?: unknown[]; nextCursor?: string }; }>("/v1/timeline/", { contactId: args.contactId, take: String(Math.min(notesLimit, PAGE_SIZE)), }); const allItems: unknown[] = firstPage.data?.items ?? []; let nextCursor = firstPage.data?.nextCursor; let remaining = notesLimit - allItems.length; while (nextCursor && remaining > 0) { const page = await dex.get<{ data?: { items?: unknown[]; nextCursor?: string }; }>("/v1/timeline/", { contactId: args.contactId, take: String(Math.min(remaining, PAGE_SIZE)), cursor: nextCursor, }); const items = page.data?.items ?? []; if (items.length === 0) break; allItems.push(...items); nextCursor = page.data?.nextCursor; remaining -= items.length; } const contact = await contactPromise; contact.notes = allItems; return toResult(contact); } catch (error) { - src/tools/contacts.ts:122-139 (registration)The tool registration block for 'dex_get_contact' defining its parameters and description.
server.tool( "dex_get_contact", "Retrieve a single contact by ID. Automatically fetches the contact's notes/timeline entries " + "and includes them in the response under a 'notes' key. Use notesLimit to control how many " + "notes are fetched (default 50). If the contact has more notes than a single page, pagination " + "is handled automatically.", { contactId: z.string(), includeNotes: z .boolean() .optional() .describe("Fetch and include the contact's notes/timeline entries. Defaults to true."), notesLimit: z .number() .min(1) .optional() .describe("Max number of notes to fetch. Defaults to 50. Paginated automatically if above 50."), },