get_subscriber_by_email
Retrieve subscriber details from a Sitecore Send mailing list using a specific email address and list ID for targeted communications.
Instructions
Get subscriber by email
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes | Email of the subscriber | ||
| listId | Yes | Id of the mailing list |
Implementation Reference
- src/tools/api.ts:85-103 (handler)The main handler function that executes the tool logic: fetches subscriber details by email from a specific list using SendClient, formats key fields (Email, Name, Tags), handles errors.execute: async ({ listId, email }) => { try { const response = await client.subscribers.findByEmail(listId, email); type Keys = keyof typeof response; const keys = ['Email', 'Name', 'Tags'] as Keys[]; return { content: [ { type: "text", text: keys.map(x => `- ${x}: '${response[x]}'`).join("\n") } ] } } catch (e) { return { content: [ { type: "text", text: `Error: ${(e as ApiResponseError).sendResponse?.Error}` } ] } } },
- src/tools/api.ts:77-80 (schema)Zod schema defining input parameters: listId (UUID) and email.parameters: z.object({ listId: z.string().uuid().describe("Id of the mailing list"), email: z.string().email().describe("Email of the subscriber") }),
- src/tools/api.ts:74-104 (registration)Registration of the tool using server.addTool, including name, description, schema, annotations, and handler.server.addTool({ name: "get_subscriber_by_email", description: "Get subscriber by email", parameters: z.object({ listId: z.string().uuid().describe("Id of the mailing list"), email: z.string().email().describe("Email of the subscriber") }), annotations: { title: "Get subscriber by email", openWorldHint: true, }, execute: async ({ listId, email }) => { try { const response = await client.subscribers.findByEmail(listId, email); type Keys = keyof typeof response; const keys = ['Email', 'Name', 'Tags'] as Keys[]; return { content: [ { type: "text", text: keys.map(x => `- ${x}: '${response[x]}'`).join("\n") } ] } } catch (e) { return { content: [ { type: "text", text: `Error: ${(e as ApiResponseError).sendResponse?.Error}` } ] } } }, });