@netsendo/mcp-client 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -12
- package/dist/api-client.d.ts +167 -2
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +163 -4
- package/dist/api-client.js.map +1 -1
- package/dist/index.js +108 -13
- package/dist/index.js.map +1 -1
- package/dist/tools/campaigns.d.ts +2 -2
- package/dist/tools/campaigns.d.ts.map +1 -1
- package/dist/tools/campaigns.js +271 -115
- package/dist/tools/campaigns.js.map +1 -1
- package/dist/tools/helpers.d.ts +28 -0
- package/dist/tools/helpers.d.ts.map +1 -0
- package/dist/tools/helpers.js +53 -0
- package/dist/tools/helpers.js.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +29 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/list-activity.d.ts +10 -0
- package/dist/tools/list-activity.d.ts.map +1 -0
- package/dist/tools/list-activity.js +58 -0
- package/dist/tools/list-activity.js.map +1 -0
- package/dist/tools/list-export.d.ts +10 -0
- package/dist/tools/list-export.d.ts.map +1 -0
- package/dist/tools/list-export.js +60 -0
- package/dist/tools/list-export.js.map +1 -0
- package/dist/tools/list-hygiene.d.ts +11 -0
- package/dist/tools/list-hygiene.d.ts.map +1 -0
- package/dist/tools/list-hygiene.js +143 -0
- package/dist/tools/list-hygiene.js.map +1 -0
- package/dist/tools/list-import.d.ts +11 -0
- package/dist/tools/list-import.d.ts.map +1 -0
- package/dist/tools/list-import.js +88 -0
- package/dist/tools/list-import.js.map +1 -0
- package/dist/tools/list-members.d.ts +10 -0
- package/dist/tools/list-members.d.ts.map +1 -0
- package/dist/tools/list-members.js +144 -0
- package/dist/tools/list-members.js.map +1 -0
- package/dist/tools/lists.d.ts.map +1 -1
- package/dist/tools/lists.js +79 -0
- package/dist/tools/lists.js.map +1 -1
- package/dist/tools/notifications.d.ts +11 -0
- package/dist/tools/notifications.d.ts.map +1 -0
- package/dist/tools/notifications.js +43 -0
- package/dist/tools/notifications.js.map +1 -0
- package/dist/tools/subscribers.js +1 -1
- package/dist/tools/subscribers.js.map +1 -1
- package/dist/tools/suppressions.d.ts +11 -0
- package/dist/tools/suppressions.d.ts.map +1 -0
- package/dist/tools/suppressions.js +54 -0
- package/dist/tools/suppressions.js.map +1 -0
- package/dist/types.d.ts +431 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/tools/campaigns.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Tools for managing email/SMS campaigns (Messages)
|
|
5
5
|
*/
|
|
6
|
-
import { z } from
|
|
6
|
+
import { z } from "zod";
|
|
7
7
|
export function registerCampaignTools(server, api) {
|
|
8
8
|
// List Campaigns
|
|
9
|
-
server.tool(
|
|
9
|
+
server.tool("list_campaigns", `List all campaigns (email/SMS messages) with optional filtering.
|
|
10
10
|
|
|
11
11
|
Returns campaign details including:
|
|
12
12
|
- id, subject, channel (email/sms)
|
|
@@ -14,12 +14,21 @@ Returns campaign details including:
|
|
|
14
14
|
- status (draft/scheduled/sending/sent/active)
|
|
15
15
|
- sent_count, planned_recipients
|
|
16
16
|
- scheduled_at, created_at`, {
|
|
17
|
-
channel: z
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
channel: z
|
|
18
|
+
.enum(["email", "sms"])
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Filter by channel type"),
|
|
21
|
+
type: z
|
|
22
|
+
.enum(["broadcast", "autoresponder"])
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("Filter by campaign type"),
|
|
25
|
+
status: z
|
|
26
|
+
.string()
|
|
27
|
+
.optional()
|
|
28
|
+
.describe("Filter by status (draft, scheduled, sending, sent, active)"),
|
|
29
|
+
search: z.string().optional().describe("Search campaigns by subject"),
|
|
30
|
+
page: z.number().optional().describe("Page number for pagination"),
|
|
31
|
+
per_page: z.number().optional().describe("Items per page (max 100)"),
|
|
23
32
|
}, async ({ channel, type, status, search, page, per_page }) => {
|
|
24
33
|
try {
|
|
25
34
|
const campaigns = await api.listMessages({
|
|
@@ -31,10 +40,11 @@ Returns campaign details including:
|
|
|
31
40
|
per_page: Math.min(per_page ?? 25, 100),
|
|
32
41
|
});
|
|
33
42
|
return {
|
|
34
|
-
content: [
|
|
35
|
-
|
|
43
|
+
content: [
|
|
44
|
+
{
|
|
45
|
+
type: "text",
|
|
36
46
|
text: JSON.stringify({
|
|
37
|
-
campaigns: campaigns.data.map(c => ({
|
|
47
|
+
campaigns: campaigns.data.map((c) => ({
|
|
38
48
|
id: c.id,
|
|
39
49
|
subject: c.subject,
|
|
40
50
|
channel: c.channel,
|
|
@@ -47,25 +57,32 @@ Returns campaign details including:
|
|
|
47
57
|
})),
|
|
48
58
|
pagination: campaigns.meta,
|
|
49
59
|
}, null, 2),
|
|
50
|
-
}
|
|
60
|
+
},
|
|
61
|
+
],
|
|
51
62
|
};
|
|
52
63
|
}
|
|
53
64
|
catch (error) {
|
|
54
65
|
return {
|
|
55
|
-
content: [
|
|
66
|
+
content: [
|
|
67
|
+
{
|
|
68
|
+
type: "text",
|
|
69
|
+
text: `Error: ${error.message}`,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
56
72
|
isError: true,
|
|
57
73
|
};
|
|
58
74
|
}
|
|
59
75
|
});
|
|
60
76
|
// Get Campaign Details
|
|
61
|
-
server.tool(
|
|
62
|
-
campaign_id: z.number().describe(
|
|
77
|
+
server.tool("get_campaign", "Get detailed information about a specific campaign including contact lists, exclusions, and configuration.", {
|
|
78
|
+
campaign_id: z.number().describe("Campaign ID"),
|
|
63
79
|
}, async ({ campaign_id }) => {
|
|
64
80
|
try {
|
|
65
81
|
const campaign = await api.getMessage(campaign_id);
|
|
66
82
|
return {
|
|
67
|
-
content: [
|
|
68
|
-
|
|
83
|
+
content: [
|
|
84
|
+
{
|
|
85
|
+
type: "text",
|
|
69
86
|
text: JSON.stringify({
|
|
70
87
|
id: campaign.id,
|
|
71
88
|
subject: campaign.subject,
|
|
@@ -74,9 +91,17 @@ Returns campaign details including:
|
|
|
74
91
|
type: campaign.type,
|
|
75
92
|
status: campaign.status,
|
|
76
93
|
mailbox: campaign.mailbox,
|
|
77
|
-
content_preview: campaign.content?.substring(0, 500) +
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
content_preview: campaign.content?.substring(0, 500) +
|
|
95
|
+
(campaign.content?.length > 500 ? "..." : ""),
|
|
96
|
+
contact_lists: campaign.contact_lists?.map((l) => ({
|
|
97
|
+
id: l.id,
|
|
98
|
+
name: l.name,
|
|
99
|
+
subscribers: l.subscribers_count,
|
|
100
|
+
})),
|
|
101
|
+
excluded_lists: campaign.excluded_lists?.map((l) => ({
|
|
102
|
+
id: l.id,
|
|
103
|
+
name: l.name,
|
|
104
|
+
})),
|
|
80
105
|
scheduled_at: campaign.scheduled_at,
|
|
81
106
|
day: campaign.day,
|
|
82
107
|
time_of_day: campaign.time_of_day,
|
|
@@ -85,18 +110,24 @@ Returns campaign details including:
|
|
|
85
110
|
is_active: campaign.is_active,
|
|
86
111
|
created_at: campaign.created_at,
|
|
87
112
|
}, null, 2),
|
|
88
|
-
}
|
|
113
|
+
},
|
|
114
|
+
],
|
|
89
115
|
};
|
|
90
116
|
}
|
|
91
117
|
catch (error) {
|
|
92
118
|
return {
|
|
93
|
-
content: [
|
|
119
|
+
content: [
|
|
120
|
+
{
|
|
121
|
+
type: "text",
|
|
122
|
+
text: `Error: ${error.message}`,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
94
125
|
isError: true,
|
|
95
126
|
};
|
|
96
127
|
}
|
|
97
128
|
});
|
|
98
129
|
// Create Campaign
|
|
99
|
-
server.tool(
|
|
130
|
+
server.tool("create_campaign", `Create a new email or SMS campaign. The campaign is created as a DRAFT by default.
|
|
100
131
|
|
|
101
132
|
⚠️ CRITICAL: You MUST specify 'channel' parameter - choose 'email' OR 'sms'!
|
|
102
133
|
|
|
@@ -160,41 +191,76 @@ EXAMPLE SMS CAMPAIGN:
|
|
|
160
191
|
- Forgetting to include 'channel' parameter → causes validation error
|
|
161
192
|
- Using 'send_email' instead of 'create_campaign' for bulk sends
|
|
162
193
|
- Not specifying mailbox_id for email campaigns`, {
|
|
163
|
-
subject: z.string().min(1).describe(
|
|
164
|
-
channel: z
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
194
|
+
subject: z.string().min(1).describe("Campaign subject line / title"),
|
|
195
|
+
channel: z
|
|
196
|
+
.enum(["email", "sms"])
|
|
197
|
+
.describe('⚠️ REQUIRED: Campaign channel - must be exactly "email" or "sms"'),
|
|
198
|
+
type: z
|
|
199
|
+
.enum(["broadcast", "autoresponder"])
|
|
200
|
+
.describe('REQUIRED: Campaign type - "broadcast" (one-time) or "autoresponder" (triggered on subscription)'),
|
|
201
|
+
content: z
|
|
202
|
+
.string()
|
|
203
|
+
.optional()
|
|
204
|
+
.describe("Email/SMS content (HTML for email, plain text for SMS)"),
|
|
205
|
+
preheader: z
|
|
206
|
+
.string()
|
|
207
|
+
.optional()
|
|
208
|
+
.describe("Email preheader/preview text (shown in inbox preview)"),
|
|
209
|
+
mailbox_id: z
|
|
210
|
+
.number()
|
|
211
|
+
.optional()
|
|
212
|
+
.describe("Mailbox ID for sending (use list_mailboxes to get available IDs)"),
|
|
213
|
+
contact_list_ids: z
|
|
214
|
+
.array(z.number())
|
|
215
|
+
.optional()
|
|
216
|
+
.describe("Array of contact list IDs to send to (use list_contact_lists to get IDs)"),
|
|
217
|
+
excluded_list_ids: z
|
|
218
|
+
.array(z.number())
|
|
219
|
+
.optional()
|
|
220
|
+
.describe("Array of contact list IDs to EXCLUDE from sending"),
|
|
221
|
+
scheduled_at: z
|
|
222
|
+
.string()
|
|
223
|
+
.optional()
|
|
224
|
+
.describe('ISO 8601 datetime to schedule sending (e.g., 2024-12-25T10:00:00Z). If provided, campaign status will be "scheduled"'),
|
|
225
|
+
day: z
|
|
226
|
+
.number()
|
|
227
|
+
.optional()
|
|
228
|
+
.describe("For autoresponders only: day offset after subscription (0 = same day)"),
|
|
229
|
+
time_of_day: z
|
|
230
|
+
.string()
|
|
231
|
+
.optional()
|
|
232
|
+
.describe('For autoresponders only: time to send (format: HH:MM, e.g., "09:00")'),
|
|
233
|
+
timezone: z
|
|
234
|
+
.string()
|
|
235
|
+
.optional()
|
|
236
|
+
.describe("Timezone for scheduling (e.g., Europe/Warsaw, America/New_York)"),
|
|
237
|
+
}, async ({ subject, channel, type, content, preheader, mailbox_id, contact_list_ids, excluded_list_ids, scheduled_at, day, time_of_day, timezone, }) => {
|
|
176
238
|
try {
|
|
177
239
|
// Additional validation with clear error messages
|
|
178
240
|
if (!channel) {
|
|
179
241
|
return {
|
|
180
|
-
content: [
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
242
|
+
content: [
|
|
243
|
+
{
|
|
244
|
+
type: "text",
|
|
245
|
+
text: 'Error: The "channel" parameter is REQUIRED. Please specify channel: "email" or "sms". This determines whether you\'re creating an email campaign or SMS campaign.',
|
|
246
|
+
},
|
|
247
|
+
],
|
|
184
248
|
isError: true,
|
|
185
249
|
};
|
|
186
250
|
}
|
|
187
|
-
if (![
|
|
251
|
+
if (!["email", "sms"].includes(channel)) {
|
|
188
252
|
return {
|
|
189
|
-
content: [
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
253
|
+
content: [
|
|
254
|
+
{
|
|
255
|
+
type: "text",
|
|
256
|
+
text: `Error: Invalid channel "${channel}". The channel parameter must be exactly "email" or "sms".`,
|
|
257
|
+
},
|
|
258
|
+
],
|
|
193
259
|
isError: true,
|
|
194
260
|
};
|
|
195
261
|
}
|
|
196
|
-
if (channel ===
|
|
197
|
-
console.error(
|
|
262
|
+
if (channel === "email" && !mailbox_id) {
|
|
263
|
+
console.error("[NetSendo MCP] Warning: Creating email campaign without mailbox_id. Campaign will need mailbox configured before sending.");
|
|
198
264
|
}
|
|
199
265
|
const campaign = await api.createMessage({
|
|
200
266
|
subject,
|
|
@@ -211,11 +277,12 @@ EXAMPLE SMS CAMPAIGN:
|
|
|
211
277
|
timezone,
|
|
212
278
|
});
|
|
213
279
|
return {
|
|
214
|
-
content: [
|
|
215
|
-
|
|
280
|
+
content: [
|
|
281
|
+
{
|
|
282
|
+
type: "text",
|
|
216
283
|
text: JSON.stringify({
|
|
217
284
|
success: true,
|
|
218
|
-
message:
|
|
285
|
+
message: "Campaign created successfully",
|
|
219
286
|
campaign: {
|
|
220
287
|
id: campaign.id,
|
|
221
288
|
subject: campaign.subject,
|
|
@@ -223,37 +290,49 @@ EXAMPLE SMS CAMPAIGN:
|
|
|
223
290
|
type: campaign.type,
|
|
224
291
|
status: campaign.status,
|
|
225
292
|
},
|
|
226
|
-
next_steps: campaign.status ===
|
|
227
|
-
?
|
|
293
|
+
next_steps: campaign.status === "draft"
|
|
294
|
+
? "Campaign is in DRAFT status. Use set_campaign_lists to add recipients, then send_campaign or schedule_campaign to send."
|
|
228
295
|
: undefined,
|
|
229
296
|
}, null, 2),
|
|
230
|
-
}
|
|
297
|
+
},
|
|
298
|
+
],
|
|
231
299
|
};
|
|
232
300
|
}
|
|
233
301
|
catch (error) {
|
|
234
302
|
return {
|
|
235
|
-
content: [
|
|
303
|
+
content: [
|
|
304
|
+
{
|
|
305
|
+
type: "text",
|
|
306
|
+
text: `Error: ${error.message}`,
|
|
307
|
+
},
|
|
308
|
+
],
|
|
236
309
|
isError: true,
|
|
237
310
|
};
|
|
238
311
|
}
|
|
239
312
|
});
|
|
240
313
|
// Update Campaign
|
|
241
|
-
server.tool(
|
|
314
|
+
server.tool("update_campaign", `Update an existing campaign (draft or scheduled only).
|
|
242
315
|
|
|
243
316
|
UPDATABLE FIELDS:
|
|
244
317
|
- subject, content, preheader, mailbox_id
|
|
245
318
|
- For autoresponders: day, time_of_day, is_active
|
|
246
319
|
|
|
247
320
|
NOTE: Sent campaigns cannot be modified.`, {
|
|
248
|
-
campaign_id: z.number().describe(
|
|
249
|
-
subject: z.string().optional().describe(
|
|
250
|
-
content: z.string().optional().describe(
|
|
251
|
-
preheader: z.string().optional().describe(
|
|
252
|
-
mailbox_id: z.number().optional().describe(
|
|
253
|
-
day: z.number().optional().describe(
|
|
254
|
-
time_of_day: z
|
|
255
|
-
|
|
256
|
-
|
|
321
|
+
campaign_id: z.number().describe("Campaign ID to update"),
|
|
322
|
+
subject: z.string().optional().describe("New subject line"),
|
|
323
|
+
content: z.string().optional().describe("New content"),
|
|
324
|
+
preheader: z.string().optional().describe("New preheader"),
|
|
325
|
+
mailbox_id: z.number().optional().describe("New mailbox ID"),
|
|
326
|
+
day: z.number().optional().describe("New day offset (autoresponders)"),
|
|
327
|
+
time_of_day: z
|
|
328
|
+
.string()
|
|
329
|
+
.optional()
|
|
330
|
+
.describe("New time of day (autoresponders)"),
|
|
331
|
+
is_active: z
|
|
332
|
+
.boolean()
|
|
333
|
+
.optional()
|
|
334
|
+
.describe("Activate/deactivate autoresponder"),
|
|
335
|
+
}, async ({ campaign_id, subject, content, preheader, mailbox_id, day, time_of_day, is_active, }) => {
|
|
257
336
|
try {
|
|
258
337
|
const campaign = await api.updateMessage(campaign_id, {
|
|
259
338
|
subject,
|
|
@@ -265,106 +344,160 @@ NOTE: Sent campaigns cannot be modified.`, {
|
|
|
265
344
|
is_active,
|
|
266
345
|
});
|
|
267
346
|
return {
|
|
268
|
-
content: [
|
|
269
|
-
|
|
347
|
+
content: [
|
|
348
|
+
{
|
|
349
|
+
type: "text",
|
|
270
350
|
text: JSON.stringify({
|
|
271
351
|
success: true,
|
|
272
|
-
message:
|
|
352
|
+
message: "Campaign updated successfully",
|
|
273
353
|
campaign: {
|
|
274
354
|
id: campaign.id,
|
|
275
355
|
subject: campaign.subject,
|
|
276
356
|
status: campaign.status,
|
|
277
357
|
},
|
|
278
358
|
}, null, 2),
|
|
279
|
-
}
|
|
359
|
+
},
|
|
360
|
+
],
|
|
280
361
|
};
|
|
281
362
|
}
|
|
282
363
|
catch (error) {
|
|
283
364
|
return {
|
|
284
|
-
content: [
|
|
365
|
+
content: [
|
|
366
|
+
{
|
|
367
|
+
type: "text",
|
|
368
|
+
text: `Error: ${error.message}`,
|
|
369
|
+
},
|
|
370
|
+
],
|
|
285
371
|
isError: true,
|
|
286
372
|
};
|
|
287
373
|
}
|
|
288
374
|
});
|
|
289
375
|
// Set Campaign Lists
|
|
290
|
-
server.tool(
|
|
291
|
-
campaign_id: z.number().describe(
|
|
292
|
-
contact_list_ids: z
|
|
376
|
+
server.tool("set_campaign_lists", "Set the recipient contact lists for a campaign. Replaces any existing lists.", {
|
|
377
|
+
campaign_id: z.number().describe("Campaign ID"),
|
|
378
|
+
contact_list_ids: z
|
|
379
|
+
.array(z.number())
|
|
380
|
+
.describe("Array of contact list IDs to send to"),
|
|
293
381
|
}, async ({ campaign_id, contact_list_ids }) => {
|
|
294
382
|
try {
|
|
295
383
|
const result = await api.setMessageLists(campaign_id, contact_list_ids);
|
|
296
384
|
return {
|
|
297
|
-
content: [
|
|
298
|
-
|
|
385
|
+
content: [
|
|
386
|
+
{
|
|
387
|
+
type: "text",
|
|
299
388
|
text: JSON.stringify({
|
|
300
389
|
success: true,
|
|
301
|
-
message:
|
|
390
|
+
message: "Recipient lists updated",
|
|
302
391
|
planned_recipients: result.planned_recipients,
|
|
303
392
|
}, null, 2),
|
|
304
|
-
}
|
|
393
|
+
},
|
|
394
|
+
],
|
|
305
395
|
};
|
|
306
396
|
}
|
|
307
397
|
catch (error) {
|
|
308
398
|
return {
|
|
309
|
-
content: [
|
|
399
|
+
content: [
|
|
400
|
+
{
|
|
401
|
+
type: "text",
|
|
402
|
+
text: `Error: ${error.message}`,
|
|
403
|
+
},
|
|
404
|
+
],
|
|
310
405
|
isError: true,
|
|
311
406
|
};
|
|
312
407
|
}
|
|
313
408
|
});
|
|
314
409
|
// Set Campaign Exclusions
|
|
315
|
-
server.tool(
|
|
316
|
-
campaign_id: z.number().describe(
|
|
317
|
-
excluded_list_ids: z
|
|
410
|
+
server.tool("set_campaign_exclusions", "Set exclusion lists for a campaign. Subscribers on these lists will NOT receive the campaign.", {
|
|
411
|
+
campaign_id: z.number().describe("Campaign ID"),
|
|
412
|
+
excluded_list_ids: z
|
|
413
|
+
.array(z.number())
|
|
414
|
+
.describe("Array of contact list IDs to exclude"),
|
|
318
415
|
}, async ({ campaign_id, excluded_list_ids }) => {
|
|
319
416
|
try {
|
|
320
417
|
const result = await api.setMessageExclusions(campaign_id, excluded_list_ids);
|
|
321
418
|
return {
|
|
322
|
-
content: [
|
|
323
|
-
|
|
419
|
+
content: [
|
|
420
|
+
{
|
|
421
|
+
type: "text",
|
|
324
422
|
text: JSON.stringify({
|
|
325
423
|
success: true,
|
|
326
|
-
message:
|
|
424
|
+
message: "Exclusion lists updated",
|
|
327
425
|
planned_recipients: result.planned_recipients,
|
|
328
426
|
}, null, 2),
|
|
329
|
-
}
|
|
427
|
+
},
|
|
428
|
+
],
|
|
330
429
|
};
|
|
331
430
|
}
|
|
332
431
|
catch (error) {
|
|
333
432
|
return {
|
|
334
|
-
content: [
|
|
433
|
+
content: [
|
|
434
|
+
{
|
|
435
|
+
type: "text",
|
|
436
|
+
text: `Error: ${error.message}`,
|
|
437
|
+
},
|
|
438
|
+
],
|
|
335
439
|
isError: true,
|
|
336
440
|
};
|
|
337
441
|
}
|
|
338
442
|
});
|
|
339
443
|
// Schedule Campaign
|
|
340
|
-
server.tool(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
444
|
+
server.tool("schedule_campaign", `Schedule a campaign for future sending.
|
|
445
|
+
|
|
446
|
+
TIMEZONE HANDLING:
|
|
447
|
+
By default, the scheduled_at time is interpreted in the user's profile timezone.
|
|
448
|
+
You can override this by specifying a timezone parameter.
|
|
449
|
+
|
|
450
|
+
Examples:
|
|
451
|
+
- scheduled_at: "2024-12-25T10:00:00" → Uses user's timezone from profile
|
|
452
|
+
- scheduled_at: "2024-12-25T10:00:00Z" → Explicit UTC (Z suffix)
|
|
453
|
+
- scheduled_at: "2024-12-25T10:00:00", timezone: "Europe/Warsaw" → Polish time
|
|
454
|
+
|
|
455
|
+
Common timezones:
|
|
456
|
+
- Europe/Warsaw (Poland)
|
|
457
|
+
- Europe/London (UK)
|
|
458
|
+
- America/New_York (US Eastern)
|
|
459
|
+
- America/Los_Angeles (US Pacific)
|
|
460
|
+
- UTC`, {
|
|
461
|
+
campaign_id: z.number().describe("Campaign ID"),
|
|
462
|
+
scheduled_at: z
|
|
463
|
+
.string()
|
|
464
|
+
.describe("ISO 8601 datetime for sending (e.g., 2024-12-25T10:00:00)"),
|
|
465
|
+
timezone: z
|
|
466
|
+
.string()
|
|
467
|
+
.optional()
|
|
468
|
+
.describe("Timezone for interpreting scheduled_at (e.g., Europe/Warsaw). If not provided, uses user profile timezone."),
|
|
469
|
+
}, async ({ campaign_id, scheduled_at, timezone }) => {
|
|
344
470
|
try {
|
|
345
|
-
const campaign = await api.scheduleMessage(campaign_id, scheduled_at);
|
|
471
|
+
const campaign = await api.scheduleMessage(campaign_id, scheduled_at, timezone);
|
|
346
472
|
return {
|
|
347
|
-
content: [
|
|
348
|
-
|
|
473
|
+
content: [
|
|
474
|
+
{
|
|
475
|
+
type: "text",
|
|
349
476
|
text: JSON.stringify({
|
|
350
477
|
success: true,
|
|
351
|
-
message:
|
|
478
|
+
message: "Campaign scheduled",
|
|
352
479
|
campaign_id: campaign.id,
|
|
353
480
|
scheduled_at: campaign.scheduled_at,
|
|
354
481
|
status: campaign.status,
|
|
355
482
|
}, null, 2),
|
|
356
|
-
}
|
|
483
|
+
},
|
|
484
|
+
],
|
|
357
485
|
};
|
|
358
486
|
}
|
|
359
487
|
catch (error) {
|
|
360
488
|
return {
|
|
361
|
-
content: [
|
|
489
|
+
content: [
|
|
490
|
+
{
|
|
491
|
+
type: "text",
|
|
492
|
+
text: `Error: ${error.message}`,
|
|
493
|
+
},
|
|
494
|
+
],
|
|
362
495
|
isError: true,
|
|
363
496
|
};
|
|
364
497
|
}
|
|
365
498
|
});
|
|
366
499
|
// Send Campaign
|
|
367
|
-
server.tool(
|
|
500
|
+
server.tool("send_campaign", `Send a campaign immediately or activate an autoresponder.
|
|
368
501
|
|
|
369
502
|
BEHAVIOR:
|
|
370
503
|
- Broadcast: Queues all recipients for immediate sending
|
|
@@ -373,69 +506,92 @@ BEHAVIOR:
|
|
|
373
506
|
PREREQUISITES:
|
|
374
507
|
- Campaign must have contact lists (use set_campaign_lists first)
|
|
375
508
|
- Must have content, subject, and mailbox configured`, {
|
|
376
|
-
campaign_id: z.number().describe(
|
|
509
|
+
campaign_id: z.number().describe("Campaign ID"),
|
|
377
510
|
}, async ({ campaign_id }) => {
|
|
378
511
|
try {
|
|
379
512
|
const result = await api.sendMessage(campaign_id);
|
|
380
513
|
return {
|
|
381
|
-
content: [
|
|
382
|
-
|
|
514
|
+
content: [
|
|
515
|
+
{
|
|
516
|
+
type: "text",
|
|
383
517
|
text: JSON.stringify({
|
|
384
518
|
success: true,
|
|
385
|
-
message: result.message.type ===
|
|
519
|
+
message: result.message.type === "autoresponder"
|
|
520
|
+
? "Autoresponder activated"
|
|
521
|
+
: "Campaign queued for sending",
|
|
386
522
|
campaign_id: result.message.id,
|
|
387
523
|
status: result.message.status,
|
|
388
524
|
recipients_added: result.recipients_added,
|
|
389
525
|
}, null, 2),
|
|
390
|
-
}
|
|
526
|
+
},
|
|
527
|
+
],
|
|
391
528
|
};
|
|
392
529
|
}
|
|
393
530
|
catch (error) {
|
|
394
531
|
return {
|
|
395
|
-
content: [
|
|
532
|
+
content: [
|
|
533
|
+
{
|
|
534
|
+
type: "text",
|
|
535
|
+
text: `Error: ${error.message}`,
|
|
536
|
+
},
|
|
537
|
+
],
|
|
396
538
|
isError: true,
|
|
397
539
|
};
|
|
398
540
|
}
|
|
399
541
|
});
|
|
400
542
|
// Get Campaign Stats
|
|
401
|
-
server.tool(
|
|
402
|
-
campaign_id: z.number().describe(
|
|
543
|
+
server.tool("get_campaign_stats", "Get sending statistics for a campaign including delivery status breakdown.", {
|
|
544
|
+
campaign_id: z.number().describe("Campaign ID"),
|
|
403
545
|
}, async ({ campaign_id }) => {
|
|
404
546
|
try {
|
|
405
547
|
const stats = await api.getMessageStats(campaign_id);
|
|
406
548
|
return {
|
|
407
|
-
content: [
|
|
408
|
-
|
|
549
|
+
content: [
|
|
550
|
+
{
|
|
551
|
+
type: "text",
|
|
409
552
|
text: JSON.stringify(stats, null, 2),
|
|
410
|
-
}
|
|
553
|
+
},
|
|
554
|
+
],
|
|
411
555
|
};
|
|
412
556
|
}
|
|
413
557
|
catch (error) {
|
|
414
558
|
return {
|
|
415
|
-
content: [
|
|
559
|
+
content: [
|
|
560
|
+
{
|
|
561
|
+
type: "text",
|
|
562
|
+
text: `Error: ${error.message}`,
|
|
563
|
+
},
|
|
564
|
+
],
|
|
416
565
|
isError: true,
|
|
417
566
|
};
|
|
418
567
|
}
|
|
419
568
|
});
|
|
420
569
|
// Delete Campaign
|
|
421
|
-
server.tool(
|
|
422
|
-
campaign_id: z.number().describe(
|
|
570
|
+
server.tool("delete_campaign", "Delete a campaign. Only draft or scheduled campaigns can be deleted.", {
|
|
571
|
+
campaign_id: z.number().describe("Campaign ID to delete"),
|
|
423
572
|
}, async ({ campaign_id }) => {
|
|
424
573
|
try {
|
|
425
574
|
await api.deleteMessage(campaign_id);
|
|
426
575
|
return {
|
|
427
|
-
content: [
|
|
428
|
-
|
|
576
|
+
content: [
|
|
577
|
+
{
|
|
578
|
+
type: "text",
|
|
429
579
|
text: JSON.stringify({
|
|
430
580
|
success: true,
|
|
431
|
-
message:
|
|
581
|
+
message: "Campaign deleted successfully",
|
|
432
582
|
}, null, 2),
|
|
433
|
-
}
|
|
583
|
+
},
|
|
584
|
+
],
|
|
434
585
|
};
|
|
435
586
|
}
|
|
436
587
|
catch (error) {
|
|
437
588
|
return {
|
|
438
|
-
content: [
|
|
589
|
+
content: [
|
|
590
|
+
{
|
|
591
|
+
type: "text",
|
|
592
|
+
text: `Error: ${error.message}`,
|
|
593
|
+
},
|
|
594
|
+
],
|
|
439
595
|
isError: true,
|
|
440
596
|
};
|
|
441
597
|
}
|