add_subscriber
Add a new subscriber to a Sitecore Send mailing list by providing their email address and list ID, enabling targeted email marketing campaigns.
Instructions
Add subscriber to a mailing list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| listId | Yes | Id of the mailing list | |
| Yes | Email of the subscriber | ||
| name | No | Name of the subscriber | |
| tags | No | Tags of the subscriber |
Implementation Reference
- src/tools/api.ts:119-135 (handler)The execute handler function that adds a subscriber to the specified mailing list using the SendClient API, handling success and error responses.execute: async ({ listId, email, name, tags }) => { try { const response = await client.subscribers.add(listId, { Email: email, Name: name, Tags: tags }); return { content: [ { type: "text", text: `Subscriber '${response.Email}' successfully added to mailing list '${listId}'` } ] } } catch (e) { return { content: [ { type: "text", text: `Error: ${(e as ApiResponseError).sendResponse?.Error}` } ] } } }
- src/tools/api.ts:109-114 (schema)Zod schema defining the input parameters for the add_subscriber tool: listId (UUID), email, optional name and tags.parameters: z.object({ listId: z.string().uuid().describe("Id of the mailing list"), email: z.string().email().describe("Email of the subscriber"), name: z.string().optional().describe("Name of the subscriber"), tags: z.array(z.string()).optional().describe("Tags of the subscriber") }),
- src/tools/api.ts:106-136 (registration)Registration of the 'add_subscriber' tool using server.addTool, including name, description, schema, annotations, and execute handler.server.addTool({ name: "add_subscriber", description: "Add subscriber to a mailing list", parameters: z.object({ listId: z.string().uuid().describe("Id of the mailing list"), email: z.string().email().describe("Email of the subscriber"), name: z.string().optional().describe("Name of the subscriber"), tags: z.array(z.string()).optional().describe("Tags of the subscriber") }), annotations: { title: "Add subscriber to a mailing list", openWorldHint: true, }, execute: async ({ listId, email, name, tags }) => { try { const response = await client.subscribers.add(listId, { Email: email, Name: name, Tags: tags }); return { content: [ { type: "text", text: `Subscriber '${response.Email}' successfully added to mailing list '${listId}'` } ] } } catch (e) { return { content: [ { type: "text", text: `Error: ${(e as ApiResponseError).sendResponse?.Error}` } ] } } } });
- src/tools/index.ts:7-9 (registration)High-level tool registration function that calls addApiTools, which includes registering the 'add_subscriber' tool.addSmptTools(server, config.smtp); addApiTools(server, config.api, config.transactionalEmails); }