add_subscriber
Add subscribers to a specific mailing list by providing their email, name, and optional tags. Ensure accurate targeting with unique list IDs using Sitecore Send.
Instructions
Add subscriber to a mailing list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes | Email of the subscriber | ||
| listId | Yes | Id of the mailing list | |
| name | No | Name of the subscriber | |
| tags | No | Tags of the subscriber |
Implementation Reference
- src/tools/api.ts:119-135 (handler)The execute handler for the add_subscriber tool. It uses SendClient to add the subscriber to the specified list and returns success or error message.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 parameters for the add_subscriber tool: listId (required uuid), email (required email), name (optional string), tags (optional array of strings).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)Direct registration of the add_subscriber tool using FastMCP's server.addTool method within the addApiTools function.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:8-8 (registration)Call to addApiTools within addTools function, which registers the add_subscriber tool among others.addApiTools(server, config.api, config.transactionalEmails);
- src/server.ts:15-15 (registration)Top-level call to addTools in the server setup, which ultimately registers the add_subscriber tool.addTools(server, config);