@netsendo/mcp-client 1.5.1 → 1.6.1

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.
Files changed (71) hide show
  1. package/README.md +127 -2
  2. package/dist/api-client.d.ts +19 -1
  3. package/dist/api-client.d.ts.map +1 -1
  4. package/dist/api-client.js +27 -2
  5. package/dist/api-client.js.map +1 -1
  6. package/dist/bridge.d.ts +23 -0
  7. package/dist/bridge.d.ts.map +1 -0
  8. package/dist/bridge.js +152 -0
  9. package/dist/bridge.js.map +1 -0
  10. package/dist/config.d.ts +1 -9
  11. package/dist/config.d.ts.map +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/tools/annotations.d.ts +18 -0
  14. package/dist/tools/annotations.d.ts.map +1 -0
  15. package/dist/tools/annotations.js +28 -0
  16. package/dist/tools/annotations.js.map +1 -0
  17. package/dist/tools/automations.d.ts +12 -0
  18. package/dist/tools/automations.d.ts.map +1 -0
  19. package/dist/tools/automations.js +184 -0
  20. package/dist/tools/automations.js.map +1 -0
  21. package/dist/tools/campaign-extras.d.ts +175 -0
  22. package/dist/tools/campaign-extras.d.ts.map +1 -0
  23. package/dist/tools/campaign-extras.js +283 -0
  24. package/dist/tools/campaign-extras.js.map +1 -0
  25. package/dist/tools/campaigns.d.ts.map +1 -1
  26. package/dist/tools/campaigns.js +82 -93
  27. package/dist/tools/campaigns.js.map +1 -1
  28. package/dist/tools/custom-fields.d.ts +12 -0
  29. package/dist/tools/custom-fields.d.ts.map +1 -0
  30. package/dist/tools/custom-fields.js +94 -0
  31. package/dist/tools/custom-fields.js.map +1 -0
  32. package/dist/tools/forms.d.ts +10 -0
  33. package/dist/tools/forms.d.ts.map +1 -0
  34. package/dist/tools/forms.js +163 -0
  35. package/dist/tools/forms.js.map +1 -0
  36. package/dist/tools/funnels.js +3 -3
  37. package/dist/tools/funnels.js.map +1 -1
  38. package/dist/tools/index.d.ts.map +1 -1
  39. package/dist/tools/index.js +16 -0
  40. package/dist/tools/index.js.map +1 -1
  41. package/dist/tools/list-import.js +4 -4
  42. package/dist/tools/list-import.js.map +1 -1
  43. package/dist/tools/lists.d.ts.map +1 -1
  44. package/dist/tools/lists.js +208 -97
  45. package/dist/tools/lists.js.map +1 -1
  46. package/dist/tools/messaging.d.ts.map +1 -1
  47. package/dist/tools/messaging.js +2 -1
  48. package/dist/tools/messaging.js.map +1 -1
  49. package/dist/tools/notifications.js +1 -1
  50. package/dist/tools/notifications.js.map +1 -1
  51. package/dist/tools/subscribers.js +2 -2
  52. package/dist/tools/subscribers.js.map +1 -1
  53. package/dist/tools/system-content.d.ts +12 -0
  54. package/dist/tools/system-content.d.ts.map +1 -0
  55. package/dist/tools/system-content.js +150 -0
  56. package/dist/tools/system-content.js.map +1 -0
  57. package/dist/tools/tags.d.ts +11 -0
  58. package/dist/tools/tags.d.ts.map +1 -0
  59. package/dist/tools/tags.js +61 -0
  60. package/dist/tools/tags.js.map +1 -0
  61. package/dist/tools/templates.d.ts +10 -0
  62. package/dist/tools/templates.d.ts.map +1 -0
  63. package/dist/tools/templates.js +294 -0
  64. package/dist/tools/templates.js.map +1 -0
  65. package/dist/tools/webhooks.d.ts +11 -0
  66. package/dist/tools/webhooks.d.ts.map +1 -0
  67. package/dist/tools/webhooks.js +130 -0
  68. package/dist/tools/webhooks.js.map +1 -0
  69. package/dist/types.d.ts +2 -1
  70. package/dist/types.d.ts.map +1 -1
  71. package/package.json +3 -3
@@ -0,0 +1,283 @@
1
+ /**
2
+ * NetSendo MCP Server - Campaign editor extras
3
+ *
4
+ * The editor fields shared by create_campaign / update_campaign (trigger,
5
+ * tags, translations, tracked links, CRM contacts, audience field filters,
6
+ * A/B config) and the campaign actions: test send, preview, duplicate,
7
+ * activation, recipient count, re-sending failed / missed recipients.
8
+ */
9
+ import { z } from 'zod';
10
+ import { ok, fail, compact } from './helpers.js';
11
+ export const TRIGGER_TYPES = [
12
+ 'signup',
13
+ 'anniversary',
14
+ 'birthday',
15
+ 'inactivity',
16
+ 'page_visit',
17
+ 'custom',
18
+ 'recent_subscribers',
19
+ 'opened_message',
20
+ 'not_opened_message',
21
+ ];
22
+ const FIELD_FILTER_OPERATORS = [
23
+ 'any_of', 'none_of', 'contains', 'not_contains', 'starts_with', 'ends_with',
24
+ 'is_set', 'is_empty', 'gt', 'gte', 'lt', 'lte', 'between',
25
+ ];
26
+ const fieldFilter = z.object({
27
+ custom_field_id: z.number().describe('Custom field ID (list_custom_fields)'),
28
+ operator: z.enum(FIELD_FILTER_OPERATORS),
29
+ values: z
30
+ .array(z.string())
31
+ .optional()
32
+ .describe('Values to compare with; omit for is_set/is_empty; two values for between'),
33
+ });
34
+ /**
35
+ * Optional editor fields accepted by POST/PUT /messages. Every key is
36
+ * optional; on update an omitted key leaves the stored value untouched and an
37
+ * empty array clears it.
38
+ */
39
+ export const campaignEditorShape = {
40
+ template_id: z
41
+ .number()
42
+ .optional()
43
+ .describe('Template ID (list_templates) — your own or a public system template. It is only a REFERENCE: sending always uses the campaign\'s own `content`. To build from a template, call get_template and copy its `html` into `content` (then edit it).'),
44
+ send_in_subscriber_timezone: z
45
+ .boolean()
46
+ .optional()
47
+ .describe('Send at time_of_day in each subscriber\'s own timezone instead of the campaign timezone'),
48
+ trigger_type: z
49
+ .enum(TRIGGER_TYPES)
50
+ .nullable()
51
+ .optional()
52
+ .describe(`Optional trigger (mostly for autoresponders). Saving it creates/updates an automation rule "Auto: <subject>" that sends this message; null removes the trigger and its rule. The rule is active only while the message is scheduled/active.
53
+ - signup: when someone joins the list (trigger_config.list_id, defaults to the first recipient list)
54
+ - anniversary: yearly on the subscription date
55
+ - birthday: on the subscriber's birthday field
56
+ - inactivity: after trigger_config.inactive_days without activity (7/14/30/60/90)
57
+ - page_visit: when a tracked page matching trigger_config.url_pattern is visited
58
+ - custom: when the tag trigger_config.tag_id is added
59
+ - recent_subscribers: audience filter — only people who joined in the last trigger_config.recent_days days
60
+ - opened_message / not_opened_message: audience filter — only people who did / did not open trigger_config.message_id`),
61
+ trigger_config: z
62
+ .object({
63
+ list_id: z.number().optional(),
64
+ message_id: z.number().optional().describe('For opened_message / not_opened_message: a sent campaign ID'),
65
+ tag_id: z.number().optional().describe('For custom (list_tags)'),
66
+ inactive_days: z.number().optional().describe('For inactivity'),
67
+ recent_days: z.number().optional().describe('For recent_subscribers'),
68
+ url_pattern: z.string().optional().describe('For page_visit, e.g. "/pricing*"'),
69
+ })
70
+ .nullable()
71
+ .optional()
72
+ .describe('Settings for trigger_type (see trigger_type). All referenced IDs must belong to this account.'),
73
+ tag_ids: z
74
+ .array(z.number())
75
+ .optional()
76
+ .describe('Campaign tags for reporting (list_tags). Replaces the current set.'),
77
+ translations: z
78
+ .array(z.object({
79
+ language: z.string().max(5).describe('Language code, e.g. "en", "de"'),
80
+ subject: z.string(),
81
+ preheader: z.string().optional(),
82
+ content: z.string().optional().describe('HTML for this language; omit to reuse the main content'),
83
+ }))
84
+ .optional()
85
+ .describe('Multi-language versions (subscriber language picks one). Replaces all translations; [] removes them.'),
86
+ tracked_links: z
87
+ .array(z.object({
88
+ url: z.string().describe('Exact link URL as it appears in the content'),
89
+ tracking_enabled: z.boolean().optional().describe('Default true'),
90
+ share_data_enabled: z.boolean().optional().describe('Append subscriber data to the URL'),
91
+ shared_fields: z.array(z.string()).optional().describe('Fields to append, e.g. ["email","first_name"]'),
92
+ subscribe_to_list_ids: z.array(z.number()).optional().describe('Add the clicker to these lists'),
93
+ unsubscribe_from_list_ids: z.array(z.number()).optional().describe('Remove the clicker from these lists'),
94
+ }))
95
+ .optional()
96
+ .describe('Per-link click settings. Replaces the whole set: links not listed lose their settings.'),
97
+ crm_contact_ids: z.array(z.number()).optional().describe('Individual CRM contacts to include besides the lists'),
98
+ excluded_crm_contact_ids: z.array(z.number()).optional().describe('CRM contacts to exclude'),
99
+ include_field_filters: z
100
+ .array(fieldFilter)
101
+ .optional()
102
+ .describe('Audience narrowing by custom field: only list members matching these are sent to. [] clears.'),
103
+ include_field_filter_match: z.enum(['all', 'any']).optional().describe('Combine include filters with AND (all) or OR (any)'),
104
+ exclude_field_filters: z
105
+ .array(fieldFilter)
106
+ .optional()
107
+ .describe('Drop subscribers matching these (combined with excluded lists: only matching members of those lists are dropped). [] clears.'),
108
+ exclude_field_filter_match: z.enum(['all', 'any']).optional(),
109
+ ab_test_config: z
110
+ .object({
111
+ enabled: z.boolean(),
112
+ test_type: z.enum(['subject', 'content', 'sender', 'send_time', 'full']).optional(),
113
+ winning_metric: z.enum(['open_rate', 'click_rate', 'conversion_rate']).optional(),
114
+ sample_percentage: z.number().min(5).max(50).optional(),
115
+ test_duration_hours: z.number().min(1).max(72).optional(),
116
+ auto_select_winner: z.boolean().optional(),
117
+ confidence_threshold: z.number().min(60).max(99).optional(),
118
+ variants: z
119
+ .array(z.object({
120
+ variant_letter: z.string().max(1).describe('"A", "B", ...'),
121
+ subject: z.string().optional(),
122
+ preheader: z.string().optional(),
123
+ is_control: z.boolean().optional().describe('Control uses the campaign subject/preheader'),
124
+ }))
125
+ .optional(),
126
+ })
127
+ .optional()
128
+ .describe('Inline A/B subject test (needs enabled=true and at least 2 variants; enabled=false removes a draft test). For full control use the *_ab_test tools.'),
129
+ };
130
+ /** Compact, agent-oriented view of a campaign returned by the API. */
131
+ export function summarizeCampaign(c, contentChars = 500) {
132
+ const content = typeof c.content === 'string' ? c.content : '';
133
+ const lists = c.contact_lists ?? [];
134
+ const excluded = c.excluded_lists ?? [];
135
+ const translations = c.translations ?? [];
136
+ return {
137
+ id: c.id,
138
+ subject: c.subject,
139
+ preheader: c.preheader,
140
+ channel: c.channel,
141
+ type: c.type,
142
+ status: c.status,
143
+ is_active: c.is_active,
144
+ mailbox_id: c.mailbox_id,
145
+ template_id: c.template_id,
146
+ day: c.day,
147
+ time_of_day: c.time_of_day,
148
+ timezone: c.timezone,
149
+ send_in_subscriber_timezone: c.send_in_subscriber_timezone,
150
+ scheduled_at: c.scheduled_at,
151
+ trigger_type: c.trigger_type,
152
+ trigger_config: c.trigger_config,
153
+ automation_rule: c.automation_rule,
154
+ contact_lists: lists.map((l) => ({ id: l.id, name: l.name })),
155
+ excluded_lists: excluded.map((l) => ({ id: l.id, name: l.name })),
156
+ crm_contact_ids: c.crm_contact_ids,
157
+ excluded_crm_contact_ids: c.excluded_crm_contact_ids,
158
+ field_filters: c.field_filters,
159
+ include_field_filter_match: c.include_field_filter_match,
160
+ exclude_field_filter_match: c.exclude_field_filter_match,
161
+ tag_ids: c.tag_ids,
162
+ translations: translations.map((t) => ({ language: t.language, subject: t.subject, preheader: t.preheader })),
163
+ tracked_links: c.tracked_links,
164
+ ab_test_config: c.ab_test_config,
165
+ sent_count: c.sent_count,
166
+ planned_recipients: c.planned_recipients_count,
167
+ content_length: content.length,
168
+ content: contentChars > 0 && content.length > contentChars ? `${content.substring(0, contentChars)}...` : content,
169
+ };
170
+ }
171
+ export function registerCampaignExtraTools(server, api) {
172
+ server.tool('send_campaign_test', `Send a TEST email of a campaign to up to 5 addresses (subject gets a "[TEST] " prefix). Nothing is queued and stats are not affected.
173
+
174
+ Placeholders ([[first_name]], [[email]], ...) are filled from: subscriber_id if given, else the subscriber with the test address, else the first subscriber on the campaign's lists, else sample data (Jan Kowalski). Uses the campaign's mailbox (or its list/user default) unless mailbox_id is given. Email campaigns only. Needs messages:write.`, {
175
+ campaign_id: z.number().describe('Campaign ID'),
176
+ emails: z.array(z.string().email()).min(1).max(5).describe('Recipient addresses for the test'),
177
+ subscriber_id: z.number().optional().describe('Personalise with this subscriber\'s data'),
178
+ mailbox_id: z.number().optional().describe('Send through this mailbox instead (list_mailboxes)'),
179
+ language: z.string().optional().describe('Send this translation (e.g. "en") instead of the main version'),
180
+ }, async ({ campaign_id, ...body }) => {
181
+ try {
182
+ const res = await api.request('post', `/messages/${campaign_id}/test`, { data: compact(body) });
183
+ return ok({ success: true, message: res.message, ...res.data });
184
+ }
185
+ catch (error) {
186
+ return fail(error);
187
+ }
188
+ });
189
+ server.tool('preview_campaign', `Render a campaign exactly as a recipient sees it: subject and full HTML with placeholders resolved and the preheader injected. Read-only (messages:read).
190
+
191
+ Personalised with subscriber_id / subscriber_email if given (must be on this account), else the first subscriber on the campaign's lists, else sample data. The result lists unresolved_placeholders (unknown [[tags]]) — fix those before sending. Use language to preview a translation.`, {
192
+ campaign_id: z.number().describe('Campaign ID'),
193
+ subscriber_id: z.number().optional(),
194
+ subscriber_email: z.string().email().optional(),
195
+ language: z.string().optional().describe('Preview this translation, e.g. "en"'),
196
+ max_html_chars: z
197
+ .number()
198
+ .optional()
199
+ .describe('Truncate the returned HTML to this many characters (default 20000, 0 = no limit)'),
200
+ }, async ({ campaign_id, max_html_chars, ...params }) => {
201
+ try {
202
+ const res = await api.request('post', `/messages/${campaign_id}/preview`, { data: compact(params) });
203
+ const limit = max_html_chars ?? 20000;
204
+ const html = res.data.html ?? '';
205
+ return ok({
206
+ ...res.data,
207
+ html_length: html.length,
208
+ html: limit > 0 && html.length > limit ? `${html.substring(0, limit)}... [truncated]` : html,
209
+ });
210
+ }
211
+ catch (error) {
212
+ return fail(error);
213
+ }
214
+ });
215
+ server.tool('duplicate_campaign', 'Copy a campaign as a new DRAFT (subject "[KOPIA] <subject>" unless you pass one). Lists, exclusions, field filters, tracked links, translations, trigger settings and content are copied; sending state and stats are not. Edit the copy with update_campaign.', {
216
+ campaign_id: z.number().describe('Campaign ID to copy'),
217
+ subject: z.string().optional().describe('Subject for the copy'),
218
+ }, async ({ campaign_id, subject }) => {
219
+ try {
220
+ const res = await api.request('post', `/messages/${campaign_id}/duplicate`, {
221
+ data: compact({ subject }),
222
+ });
223
+ return ok({ success: true, message: res.message, campaign: summarizeCampaign(res.data, 0) });
224
+ }
225
+ catch (error) {
226
+ return fail(error);
227
+ }
228
+ });
229
+ server.tool('set_campaign_active', `Activate or pause an AUTORESPONDER (queue message). Activating a draft promotes it to "scheduled" so new subscribers get it after its day offset, schedules the current subscribers whose send time is still ahead, and enables its trigger rule. Deactivating stops further sends. Omit is_active to toggle. Broadcasts are rejected — use send_campaign / schedule_campaign.`, {
230
+ campaign_id: z.number().describe('Autoresponder campaign ID'),
231
+ is_active: z.boolean().optional().describe('true = activate, false = pause; omit to toggle'),
232
+ }, async ({ campaign_id, is_active }) => {
233
+ try {
234
+ const res = await api.request('post', `/messages/${campaign_id}/toggle-active`, {
235
+ data: compact({ is_active }),
236
+ });
237
+ return ok({ success: true, message: res.message, ...res.data, warnings: res.warnings });
238
+ }
239
+ catch (error) {
240
+ return fail(error);
241
+ }
242
+ });
243
+ server.tool('get_campaign_recipient_count', 'Count who a campaign would go to right now: its lists plus selected CRM contacts, minus exclusions, field filters and inactive/unsubscribed people (deduplicated by email). For autoresponders also skipped_count (subscribers who joined before its day offset and missed it) and the queue breakdown. Read-only.', {
244
+ campaign_id: z.number().describe('Campaign ID'),
245
+ }, async ({ campaign_id }) => {
246
+ try {
247
+ const res = await api.request('get', `/messages/${campaign_id}/recipients-count`);
248
+ return ok(res.data);
249
+ }
250
+ catch (error) {
251
+ return fail(error);
252
+ }
253
+ });
254
+ server.tool('resend_campaign_failed', 'Re-queue every recipient whose delivery of this campaign FAILED (e.g. provider quota hit). Real emails are sent: call once without confirm to see failed_count, ask the user, then repeat with confirm=true.', {
255
+ campaign_id: z.number().describe('Campaign ID'),
256
+ confirm: z.boolean().optional().describe('Must be true to actually re-queue'),
257
+ }, async ({ campaign_id, confirm }) => {
258
+ try {
259
+ const res = await api.request('post', `/messages/${campaign_id}/resend-failed`, {
260
+ data: compact({ confirm }),
261
+ });
262
+ return ok({ success: true, message: res.message, ...res.data });
263
+ }
264
+ catch (error) {
265
+ return fail(error, 'Nothing was sent. Tell the user how many failed recipients would be re-sent and, once they approve, repeat with confirm=true.');
266
+ }
267
+ });
268
+ server.tool('send_campaign_to_missed', 'For an ACTIVE autoresponder: send it now to the subscribers who missed it (they were already on the list longer than its day offset when it was created/activated). Real emails are sent: call once without confirm to see missed_count, ask the user, then repeat with confirm=true.', {
269
+ campaign_id: z.number().describe('Autoresponder campaign ID'),
270
+ confirm: z.boolean().optional().describe('Must be true to actually send'),
271
+ }, async ({ campaign_id, confirm }) => {
272
+ try {
273
+ const res = await api.request('post', `/messages/${campaign_id}/send-to-missed`, {
274
+ data: compact({ confirm }),
275
+ });
276
+ return ok({ success: true, message: res.message, ...res.data });
277
+ }
278
+ catch (error) {
279
+ return fail(error, 'Nothing was sent. Tell the user how many missed subscribers would receive it and, once they approve, repeat with confirm=true.');
280
+ }
281
+ });
282
+ }
283
+ //# sourceMappingURL=campaign-extras.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"campaign-extras.js","sourceRoot":"","sources":["../../src/tools/campaign-extras.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIjD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,QAAQ;IACR,aAAa;IACb,UAAU;IACV,YAAY;IACZ,YAAY;IACZ,QAAQ;IACR,oBAAoB;IACpB,gBAAgB;IAChB,oBAAoB;CACZ,CAAC;AAEX,MAAM,sBAAsB,GAAG;IAC7B,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW;IAC3E,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS;CACjD,CAAC;AAEX,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;IAC5E,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC;IACxC,MAAM,EAAE,CAAC;SACN,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,EAAE;SACV,QAAQ,CAAC,0EAA0E,CAAC;CACxF,CAAC,CAA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AE,CAAC;YACf,OAAO,IAAI,CAAC,KAAK,EAAE,gIAAgI,CAAC,CAAC;QACvJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"campaigns.d.ts","sourceRoot":"","sources":["../../src/tools/campaigns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,iBAAiB,QAuuBvB"}
1
+ {"version":3,"file":"campaigns.d.ts","sourceRoot":"","sources":["../../src/tools/campaigns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAI1D,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,iBAAiB,QA6tBvB"}
@@ -4,6 +4,8 @@
4
4
  * Tools for managing email/SMS campaigns (Messages)
5
5
  */
6
6
  import { z } from "zod";
7
+ import { campaignEditorShape, summarizeCampaign } from "./campaign-extras.js";
8
+ import { compact, fail } from "./helpers.js";
7
9
  export function registerCampaignTools(server, api) {
8
10
  // List Campaigns
9
11
  server.tool("list_campaigns", `List all campaigns (email/SMS messages) with optional filtering.
@@ -74,56 +76,26 @@ Returns campaign details including:
74
76
  }
75
77
  });
76
78
  // Get Campaign Details
77
- server.tool("get_campaign", "Get detailed information about a specific campaign including contact lists, exclusions, and configuration.", {
79
+ server.tool("get_campaign", `Get everything needed to review or edit a campaign: subject, preheader, content (truncated unless content_chars=0), mailbox, template_id, lists/exclusions, CRM contacts, custom-field filters, day/time/timezone, status/is_active, trigger (trigger_type, trigger_config and the automation_rule it created), tag_ids, translations, tracked_links and ab_test_config — the same field names update_campaign accepts.`, {
78
80
  campaign_id: z.number().describe("Campaign ID"),
79
- }, async ({ campaign_id }) => {
81
+ content_chars: z
82
+ .number()
83
+ .optional()
84
+ .describe("Return at most this many characters of content (default 2000, 0 = full content)"),
85
+ }, async ({ campaign_id, content_chars }) => {
80
86
  try {
81
- const campaign = await api.getMessage(campaign_id);
87
+ const res = await api.request("get", `/messages/${campaign_id}`);
82
88
  return {
83
89
  content: [
84
90
  {
85
91
  type: "text",
86
- text: JSON.stringify({
87
- id: campaign.id,
88
- subject: campaign.subject,
89
- preheader: campaign.preheader,
90
- channel: campaign.channel,
91
- type: campaign.type,
92
- status: campaign.status,
93
- mailbox: campaign.mailbox,
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
- })),
105
- scheduled_at: campaign.scheduled_at,
106
- day: campaign.day,
107
- time_of_day: campaign.time_of_day,
108
- sent_count: campaign.sent_count,
109
- planned_recipients: campaign.planned_recipients_count,
110
- is_active: campaign.is_active,
111
- created_at: campaign.created_at,
112
- }, null, 2),
92
+ text: JSON.stringify(summarizeCampaign(res.data, content_chars ?? 2000), null, 2),
113
93
  },
114
94
  ],
115
95
  };
116
96
  }
117
97
  catch (error) {
118
- return {
119
- content: [
120
- {
121
- type: "text",
122
- text: `Error: ${error.message}`,
123
- },
124
- ],
125
- isError: true,
126
- };
98
+ return fail(error);
127
99
  }
128
100
  });
129
101
  // Create Campaign
@@ -142,8 +114,12 @@ OPTIONAL PARAMETERS:
142
114
  - mailbox_id: Sender mailbox ID - required for email campaigns (use list_mailboxes to get IDs)
143
115
  - contact_list_ids: Array of recipient list IDs (use list_contact_lists to get IDs)
144
116
  - excluded_list_ids: Array of list IDs to exclude from sending
145
- - scheduled_at: ISO datetime to schedule sending (e.g., 2024-12-25T10:00:00Z)
117
+ - scheduled_at: ISO datetime to schedule sending (e.g., 2024-12-25T10:00:00Z) — needs contact_list_ids; the campaign is then scheduled right after creation
146
118
  - day, time_of_day, timezone: For autoresponders only
119
+ - template_id: reference only — sending uses \`content\`; copy the template's html (get_template) into content
120
+ - trigger_type + trigger_config, tag_ids, translations, tracked_links, crm_contact_ids, field filters, ab_test_config, send_in_subscriber_timezone (see each field)
121
+
122
+ AUTORESPONDER (= queue message): type "autoresponder" + day (days after the subscriber joined the list, 0 = right away) + optional time_of_day/timezone. Every list member gets it once, counted from their signup. It is created as an inactive draft: activate it with set_campaign_active (or send_campaign). Build a sequence by creating one autoresponder per step with day 0, 2, 5, ...
147
123
 
148
124
  🔑 MAILBOX SELECTION WORKFLOW (for email campaigns):
149
125
  Before creating an email campaign, determine the correct mailbox_id:
@@ -151,6 +127,7 @@ Before creating an email campaign, determine the correct mailbox_id:
151
127
  2. If list has default_mailbox: use that mailbox_id
152
128
  3. If no list default: call list_mailboxes and use default_mailbox_id from response
153
129
  4. If no default: ask user which mailbox to use
130
+ Gmail mailboxes never send campaigns. A list whose default mailbox is Gmail sends its campaigns from its broadcast_mailbox_id (set it with update_contact_list to a mailbox that allows broadcasts); the send_campaign/schedule_campaign response names the actual sender in "sender". Without one, send_campaign answers 422 — do not swap the list's default mailbox for that.
154
131
 
155
132
  AUTO-SELECTION (if mailbox_id not provided):
156
133
  The system will try to auto-select in this order:
@@ -160,9 +137,10 @@ The system will try to auto-select in this order:
160
137
 
161
138
  WORKFLOW OPTIONS:
162
139
  1. DRAFT: create_campaign → edit later in UI
163
- 2. SEND NOW: create_campaign → set_campaign_lists → send_campaign
140
+ 2. SEND NOW: create_campaign → preview_campaign / send_campaign_test → send_campaign
164
141
  3. SCHEDULE: create_campaign → set_campaign_lists → schedule_campaign
165
142
  4. ONE-STEP SCHEDULE: create_campaign with scheduled_at + contact_list_ids
143
+ 5. AUTORESPONDER: create_campaign (type autoresponder, day N) → set_campaign_active
166
144
 
167
145
  PERSONALIZATION (use list_placeholders for full list):
168
146
  - [[first_name]], [[last_name]], [[email]], [[phone]]
@@ -234,7 +212,8 @@ EXAMPLE SMS CAMPAIGN:
234
212
  .string()
235
213
  .optional()
236
214
  .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, }) => {
215
+ ...campaignEditorShape,
216
+ }, async ({ subject, channel, type, content, preheader, mailbox_id, contact_list_ids, excluded_list_ids, scheduled_at, day, time_of_day, timezone, ...editorFields }) => {
238
217
  try {
239
218
  // Additional validation with clear error messages
240
219
  if (!channel) {
@@ -262,20 +241,34 @@ EXAMPLE SMS CAMPAIGN:
262
241
  if (channel === "email" && !mailbox_id) {
263
242
  console.error("[NetSendo MCP] Warning: Creating email campaign without mailbox_id. Campaign will need mailbox configured before sending.");
264
243
  }
265
- const campaign = await api.createMessage({
266
- subject,
267
- channel,
268
- type,
269
- content,
270
- preheader,
271
- mailbox_id,
272
- contact_list_ids,
273
- excluded_list_ids,
274
- scheduled_at,
275
- day,
276
- time_of_day,
277
- timezone,
244
+ const created = await api.request("post", "/messages", {
245
+ data: compact({
246
+ subject,
247
+ channel,
248
+ type,
249
+ content,
250
+ preheader,
251
+ mailbox_id,
252
+ contact_list_ids,
253
+ excluded_list_ids,
254
+ day,
255
+ time_of_day,
256
+ timezone,
257
+ ...editorFields,
258
+ }),
278
259
  });
260
+ let campaign = created.data;
261
+ // The create endpoint always makes a draft; scheduling is its own step
262
+ let scheduleError;
263
+ if (scheduled_at) {
264
+ try {
265
+ const scheduled = await api.scheduleMessage(campaign.id, scheduled_at, timezone);
266
+ campaign = { ...campaign, status: scheduled.status, scheduled_at: scheduled.scheduled_at };
267
+ }
268
+ catch (error) {
269
+ scheduleError = `Created as a draft but scheduling failed: ${error.message}. Fix it, then call schedule_campaign.`;
270
+ }
271
+ }
279
272
  return {
280
273
  content: [
281
274
  {
@@ -283,15 +276,15 @@ EXAMPLE SMS CAMPAIGN:
283
276
  text: JSON.stringify({
284
277
  success: true,
285
278
  message: "Campaign created successfully",
286
- campaign: {
287
- id: campaign.id,
288
- subject: campaign.subject,
289
- channel: campaign.channel,
290
- type: campaign.type,
291
- status: campaign.status,
292
- },
279
+ campaign: summarizeCampaign(campaign, 0),
280
+ warnings: [
281
+ ...(created.warnings ?? []),
282
+ ...(scheduleError ? [scheduleError] : []),
283
+ ],
293
284
  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."
285
+ ? type === "autoresponder"
286
+ ? "Autoresponder is an inactive DRAFT. Check it with preview_campaign / send_campaign_test, then activate it with set_campaign_active."
287
+ : "Campaign is in DRAFT status. Check it with preview_campaign / send_campaign_test, make sure it has lists (set_campaign_lists), then send_campaign or schedule_campaign."
295
288
  : undefined,
296
289
  }, null, 2),
297
290
  },
@@ -311,38 +304,45 @@ EXAMPLE SMS CAMPAIGN:
311
304
  }
312
305
  });
313
306
  // Update Campaign
314
- server.tool("update_campaign", `Update an existing campaign (draft or scheduled only).
307
+ server.tool("update_campaign", `Update an existing campaign (draft or scheduled; sent/sending campaigns are locked). Only the fields you pass change; for array fields an empty array clears them.
315
308
 
316
309
  UPDATABLE FIELDS:
317
- - subject, content, preheader, mailbox_id
318
- - For autoresponders: day, time_of_day, is_active
310
+ - subject, content, preheader, mailbox_id, template_id (reference only — sending uses content)
311
+ - contact_list_ids / excluded_list_ids (replace the lists; planned recipient count is recalculated)
312
+ - day, time_of_day, timezone, send_in_subscriber_timezone
313
+ - is_active (autoresponders: true activates a draft, like set_campaign_active)
314
+ - trigger_type / trigger_config (synced to the trigger's automation rule; trigger_type null removes it)
315
+ - tag_ids, translations, tracked_links, crm_contact_ids, excluded_crm_contact_ids
316
+ - include/exclude_field_filters (+ _match), ab_test_config
319
317
 
320
- NOTE: Sent campaigns cannot be modified.`, {
318
+ Call get_campaign first to see the current values.`, {
321
319
  campaign_id: z.number().describe("Campaign ID to update"),
322
320
  subject: z.string().optional().describe("New subject line"),
323
- content: z.string().optional().describe("New content"),
321
+ content: z.string().optional().describe("New content (full HTML for email)"),
324
322
  preheader: z.string().optional().describe("New preheader"),
325
323
  mailbox_id: z.number().optional().describe("New mailbox ID"),
324
+ contact_list_ids: z
325
+ .array(z.number())
326
+ .optional()
327
+ .describe("Replace the recipient lists"),
328
+ excluded_list_ids: z
329
+ .array(z.number())
330
+ .optional()
331
+ .describe("Replace the excluded lists"),
326
332
  day: z.number().optional().describe("New day offset (autoresponders)"),
327
333
  time_of_day: z
328
334
  .string()
329
335
  .optional()
330
- .describe("New time of day (autoresponders)"),
336
+ .describe('New time of day, HH:MM (autoresponders)'),
337
+ timezone: z.string().optional().describe("Timezone, e.g. Europe/Warsaw"),
331
338
  is_active: z
332
339
  .boolean()
333
340
  .optional()
334
341
  .describe("Activate/deactivate autoresponder"),
335
- }, async ({ campaign_id, subject, content, preheader, mailbox_id, day, time_of_day, is_active, }) => {
342
+ ...campaignEditorShape,
343
+ }, async ({ campaign_id, ...fields }) => {
336
344
  try {
337
- const campaign = await api.updateMessage(campaign_id, {
338
- subject,
339
- content,
340
- preheader,
341
- mailbox_id,
342
- day,
343
- time_of_day,
344
- is_active,
345
- });
345
+ const res = await api.request("put", `/messages/${campaign_id}`, { data: compact(fields) });
346
346
  return {
347
347
  content: [
348
348
  {
@@ -350,26 +350,15 @@ NOTE: Sent campaigns cannot be modified.`, {
350
350
  text: JSON.stringify({
351
351
  success: true,
352
352
  message: "Campaign updated successfully",
353
- campaign: {
354
- id: campaign.id,
355
- subject: campaign.subject,
356
- status: campaign.status,
357
- },
353
+ campaign: summarizeCampaign(res.data, 0),
354
+ warnings: res.warnings,
358
355
  }, null, 2),
359
356
  },
360
357
  ],
361
358
  };
362
359
  }
363
360
  catch (error) {
364
- return {
365
- content: [
366
- {
367
- type: "text",
368
- text: `Error: ${error.message}`,
369
- },
370
- ],
371
- isError: true,
372
- };
361
+ return fail(error);
373
362
  }
374
363
  });
375
364
  // Set Campaign Lists