@eusend_dev/mcp 0.9.0 → 0.10.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.
|
@@ -5,12 +5,20 @@ import { createServer } from "node:http";
|
|
|
5
5
|
import { hostHeaderValidation, toNodeHandler } from "@modelcontextprotocol/node";
|
|
6
6
|
import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
7
7
|
//#region src/respond.ts
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Wrap a successful payload as structured content plus the same JSON as text, for clients
|
|
10
|
+
* that only read `content`. Structured content must be an object, so a bare list is returned
|
|
11
|
+
* as `{ data: [...] }` — the same envelope the paginated endpoints already use.
|
|
12
|
+
*/
|
|
9
13
|
function ok(data) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
const structured = Array.isArray(data) ? { data } : data ?? {};
|
|
15
|
+
return {
|
|
16
|
+
content: [{
|
|
17
|
+
type: "text",
|
|
18
|
+
text: JSON.stringify(structured, null, 2)
|
|
19
|
+
}],
|
|
20
|
+
structuredContent: structured
|
|
21
|
+
};
|
|
14
22
|
}
|
|
15
23
|
/**
|
|
16
24
|
* Surface an SDK error as an MCP tool error. `isError: true` tells the client
|
|
@@ -41,6 +49,210 @@ function respond(res) {
|
|
|
41
49
|
return res.error ? fail(res.error) : ok(res.data);
|
|
42
50
|
}
|
|
43
51
|
//#endregion
|
|
52
|
+
//#region src/annotations.ts
|
|
53
|
+
const READ = {
|
|
54
|
+
readOnlyHint: true,
|
|
55
|
+
destructiveHint: false,
|
|
56
|
+
idempotentHint: true,
|
|
57
|
+
openWorldHint: false
|
|
58
|
+
};
|
|
59
|
+
const CREATE = {
|
|
60
|
+
readOnlyHint: false,
|
|
61
|
+
destructiveHint: false,
|
|
62
|
+
idempotentHint: false,
|
|
63
|
+
openWorldHint: false
|
|
64
|
+
};
|
|
65
|
+
const UPDATE = {
|
|
66
|
+
readOnlyHint: false,
|
|
67
|
+
destructiveHint: false,
|
|
68
|
+
idempotentHint: true,
|
|
69
|
+
openWorldHint: false
|
|
70
|
+
};
|
|
71
|
+
const SENDS_MAIL = {
|
|
72
|
+
readOnlyHint: false,
|
|
73
|
+
destructiveHint: false,
|
|
74
|
+
idempotentHint: false,
|
|
75
|
+
openWorldHint: true
|
|
76
|
+
};
|
|
77
|
+
const IRREVERSIBLE = {
|
|
78
|
+
readOnlyHint: false,
|
|
79
|
+
destructiveHint: true,
|
|
80
|
+
idempotentHint: true,
|
|
81
|
+
openWorldHint: false
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/schemas.ts
|
|
85
|
+
const timestamp = z.string().describe("ISO 8601 timestamp.");
|
|
86
|
+
const id = z.string();
|
|
87
|
+
const list = (item, cursorKey) => z.looseObject({
|
|
88
|
+
data: z.array(item),
|
|
89
|
+
...cursorKey ? { [cursorKey]: z.string().nullish().describe("Pass as `cursor` to fetch the next page; null on the last page.") } : {}
|
|
90
|
+
});
|
|
91
|
+
const emailStatus$1 = z.string().describe("queued, scheduled, canceled, sending, sent, delivered, bounced, complained, suppressed or failed.");
|
|
92
|
+
const emailListItem = z.looseObject({
|
|
93
|
+
id,
|
|
94
|
+
from: z.string(),
|
|
95
|
+
to: z.array(z.string()),
|
|
96
|
+
subject: z.string(),
|
|
97
|
+
status: emailStatus$1,
|
|
98
|
+
tags: z.record(z.string(), z.string()).nullish(),
|
|
99
|
+
testMode: z.boolean().nullish(),
|
|
100
|
+
createdAt: timestamp
|
|
101
|
+
});
|
|
102
|
+
const sendEmailOutput = z.looseObject({ id: id.describe("Id of the queued email; pass to get_email to follow its delivery.") });
|
|
103
|
+
const listEmailsOutput = list(emailListItem, "nextCursor");
|
|
104
|
+
const emailOutput = emailListItem.extend({
|
|
105
|
+
cc: z.array(z.string()).nullish(),
|
|
106
|
+
bcc: z.array(z.string()).nullish(),
|
|
107
|
+
replyTo: z.array(z.string()).nullish(),
|
|
108
|
+
html: z.string().nullish(),
|
|
109
|
+
text: z.string().nullish(),
|
|
110
|
+
templateId: z.string().nullish(),
|
|
111
|
+
scheduledAt: timestamp.nullish(),
|
|
112
|
+
events: z.array(z.looseObject({
|
|
113
|
+
id,
|
|
114
|
+
type: z.string().describe("sent, delivered, opened, clicked, bounced or complained."),
|
|
115
|
+
metadata: z.record(z.string(), z.unknown()).nullish(),
|
|
116
|
+
createdAt: timestamp
|
|
117
|
+
})).describe("Delivery events, oldest first.")
|
|
118
|
+
});
|
|
119
|
+
const cancelEmailOutput = z.looseObject({
|
|
120
|
+
id,
|
|
121
|
+
status: z.string()
|
|
122
|
+
});
|
|
123
|
+
const domainStatus = z.string().describe("pending, verified or failed.");
|
|
124
|
+
const dnsRecord = z.looseObject({
|
|
125
|
+
type: z.string(),
|
|
126
|
+
name: z.string(),
|
|
127
|
+
value: z.string(),
|
|
128
|
+
priority: z.number().optional(),
|
|
129
|
+
purpose: z.string().optional(),
|
|
130
|
+
description: z.string().optional()
|
|
131
|
+
});
|
|
132
|
+
const domainListItem = z.looseObject({
|
|
133
|
+
id,
|
|
134
|
+
name: z.string(),
|
|
135
|
+
status: domainStatus,
|
|
136
|
+
createdAt: timestamp
|
|
137
|
+
});
|
|
138
|
+
const listDomainsOutput = list(domainListItem, null);
|
|
139
|
+
const domainOutput = domainListItem.extend({
|
|
140
|
+
dkimPublicKey: z.string().nullish(),
|
|
141
|
+
dkimSelector: z.string().nullish(),
|
|
142
|
+
verifiedAt: timestamp.nullish(),
|
|
143
|
+
returnPathAligned: z.boolean().optional().describe("Whether bounces return to send.<domain>, so SPF aligns with the From domain."),
|
|
144
|
+
records: z.array(dnsRecord).optional().describe("The DNS records this domain needs published."),
|
|
145
|
+
verification: z.looseObject({
|
|
146
|
+
running: z.boolean(),
|
|
147
|
+
startedAt: timestamp.nullish()
|
|
148
|
+
}).nullish().describe("Whether a DNS check is in progress."),
|
|
149
|
+
diagnostic: z.looseObject({ code: z.string() }).nullish().describe("Why verification is failing, when it is.")
|
|
150
|
+
});
|
|
151
|
+
const createDomainOutput = z.looseObject({
|
|
152
|
+
id,
|
|
153
|
+
name: z.string(),
|
|
154
|
+
records: z.array(dnsRecord).describe("Every DNS record to publish before the domain can send."),
|
|
155
|
+
dkim: dnsRecord.nullish(),
|
|
156
|
+
dmarc: dnsRecord.nullish()
|
|
157
|
+
});
|
|
158
|
+
const verifyDomainOutput = z.looseObject({ message: z.string() });
|
|
159
|
+
const listAudiencesOutput = list(z.looseObject({
|
|
160
|
+
id,
|
|
161
|
+
name: z.string(),
|
|
162
|
+
createdAt: timestamp,
|
|
163
|
+
contactCount: z.number()
|
|
164
|
+
}), null);
|
|
165
|
+
const audienceOutput = z.looseObject({
|
|
166
|
+
id,
|
|
167
|
+
name: z.string(),
|
|
168
|
+
contactCount: z.number().optional(),
|
|
169
|
+
createdAt: timestamp,
|
|
170
|
+
updatedAt: timestamp.nullish()
|
|
171
|
+
});
|
|
172
|
+
const contact = z.looseObject({
|
|
173
|
+
id,
|
|
174
|
+
audienceId: z.string(),
|
|
175
|
+
email: z.string(),
|
|
176
|
+
firstName: z.string().nullish(),
|
|
177
|
+
lastName: z.string().nullish(),
|
|
178
|
+
properties: z.record(z.string(), z.string()).nullish(),
|
|
179
|
+
status: z.string().describe("subscribed or unsubscribed."),
|
|
180
|
+
unsubscribedAt: timestamp.nullish(),
|
|
181
|
+
createdAt: timestamp,
|
|
182
|
+
updatedAt: timestamp.nullish()
|
|
183
|
+
});
|
|
184
|
+
const contactOutput = contact;
|
|
185
|
+
const listContactsOutput = list(contact, "nextCursor");
|
|
186
|
+
const contactProperty = z.looseObject({
|
|
187
|
+
id,
|
|
188
|
+
key: z.string(),
|
|
189
|
+
type: z.string().describe("string or number."),
|
|
190
|
+
fallbackValue: z.string().nullish(),
|
|
191
|
+
createdAt: timestamp,
|
|
192
|
+
updatedAt: timestamp.nullish()
|
|
193
|
+
});
|
|
194
|
+
const contactPropertyOutput = contactProperty;
|
|
195
|
+
const listContactPropertiesOutput = list(contactProperty, null);
|
|
196
|
+
const topic = z.looseObject({
|
|
197
|
+
id,
|
|
198
|
+
name: z.string(),
|
|
199
|
+
description: z.string().nullish(),
|
|
200
|
+
defaultSubscription: z.string().describe("opt_in or opt_out."),
|
|
201
|
+
visibility: z.string().describe("public or private."),
|
|
202
|
+
subscriberCount: z.number().optional(),
|
|
203
|
+
createdAt: timestamp,
|
|
204
|
+
updatedAt: timestamp.nullish()
|
|
205
|
+
});
|
|
206
|
+
const topicOutput = topic;
|
|
207
|
+
const listTopicsOutput = list(topic, null);
|
|
208
|
+
const broadcastStatus = z.string().describe("draft, scheduled, sending, sent, paused, held or cancelled.");
|
|
209
|
+
const broadcastBase = z.looseObject({
|
|
210
|
+
id,
|
|
211
|
+
name: z.string(),
|
|
212
|
+
status: broadcastStatus,
|
|
213
|
+
audienceId: z.string().nullish(),
|
|
214
|
+
topicId: z.string().nullish(),
|
|
215
|
+
fromAddress: z.string(),
|
|
216
|
+
subject: z.string(),
|
|
217
|
+
recipientCount: z.number().nullish(),
|
|
218
|
+
sentCount: z.number().nullish(),
|
|
219
|
+
scheduledAt: timestamp.nullish(),
|
|
220
|
+
startedAt: timestamp.nullish(),
|
|
221
|
+
completedAt: timestamp.nullish(),
|
|
222
|
+
createdAt: timestamp
|
|
223
|
+
});
|
|
224
|
+
const listBroadcastsOutput = list(broadcastBase.extend({
|
|
225
|
+
topicName: z.string().nullish(),
|
|
226
|
+
audienceName: z.string().nullish()
|
|
227
|
+
}), null);
|
|
228
|
+
const broadcastOutput = broadcastBase.extend({
|
|
229
|
+
replyTo: z.string().nullish(),
|
|
230
|
+
html: z.string().nullish(),
|
|
231
|
+
heldReason: z.string().nullish().describe("Why the broadcast is held for review, when it is."),
|
|
232
|
+
trackOpens: z.boolean().nullish(),
|
|
233
|
+
trackClicks: z.boolean().nullish(),
|
|
234
|
+
updatedAt: timestamp.nullish(),
|
|
235
|
+
stats: z.record(z.string(), z.number()).optional().describe("Recipient counts by delivery status. Present on get_broadcast.")
|
|
236
|
+
});
|
|
237
|
+
const sendBroadcastOutput = z.looseObject({
|
|
238
|
+
id,
|
|
239
|
+
status: z.string().describe("sending or scheduled."),
|
|
240
|
+
scheduledAt: timestamp.nullish()
|
|
241
|
+
});
|
|
242
|
+
const testBroadcastOutput = z.looseObject({
|
|
243
|
+
id,
|
|
244
|
+
sentTo: z.array(z.string()),
|
|
245
|
+
emailIds: z.array(z.string())
|
|
246
|
+
});
|
|
247
|
+
const suppression = z.looseObject({
|
|
248
|
+
id,
|
|
249
|
+
email: z.string(),
|
|
250
|
+
reason: z.string().describe("bounce, complaint or manual."),
|
|
251
|
+
created_at: timestamp
|
|
252
|
+
});
|
|
253
|
+
const suppressionOutput = suppression;
|
|
254
|
+
const listSuppressionsOutput = list(suppression, "next_cursor");
|
|
255
|
+
//#endregion
|
|
44
256
|
//#region src/tools/emails.ts
|
|
45
257
|
const emailStatus = z.enum([
|
|
46
258
|
"queued",
|
|
@@ -58,6 +270,11 @@ const recipients = z.union([z.string(), z.array(z.string())]);
|
|
|
58
270
|
function registerEmailTools(server, client, config) {
|
|
59
271
|
server.registerTool("send_email", {
|
|
60
272
|
title: "Send an email",
|
|
273
|
+
annotations: {
|
|
274
|
+
...SENDS_MAIL,
|
|
275
|
+
title: "Send an email"
|
|
276
|
+
},
|
|
277
|
+
outputSchema: sendEmailOutput,
|
|
61
278
|
description: "Send a transactional email through Eusend. Provide `html` or `text` (or both). The sender domain must be verified on the account — use list_domains to check. If `from` is omitted, the server-configured default sender is used.",
|
|
62
279
|
inputSchema: z.object({
|
|
63
280
|
from: z.string().optional().describe("Sender, e.g. \"Acme <hi@acme.com>\". Defaults to the configured sender."),
|
|
@@ -65,8 +282,8 @@ function registerEmailTools(server, client, config) {
|
|
|
65
282
|
subject: z.string().describe("Email subject line."),
|
|
66
283
|
text: z.string().optional().describe("Plain-text body."),
|
|
67
284
|
html: z.string().optional().describe("HTML body. Takes precedence over text for display."),
|
|
68
|
-
cc: recipients.optional(),
|
|
69
|
-
bcc: recipients.optional(),
|
|
285
|
+
cc: recipients.optional().describe("Carbon-copy address(es)."),
|
|
286
|
+
bcc: recipients.optional().describe("Blind carbon-copy address(es), hidden from other recipients."),
|
|
70
287
|
replyTo: recipients.optional().describe("Reply-To address(es)."),
|
|
71
288
|
tags: z.record(z.string(), z.string()).optional().describe("Labels for log filtering and webhook routing, e.g. {\"category\": \"password_reset\"}. Names and values allow ASCII letters, numbers, underscores and dashes; max 10 tags."),
|
|
72
289
|
scheduledAt: z.string().optional().describe("Future send time: ISO 8601 or natural language like \"in 1 hour\". Max 30 days out.")
|
|
@@ -90,6 +307,11 @@ function registerEmailTools(server, client, config) {
|
|
|
90
307
|
});
|
|
91
308
|
server.registerTool("list_emails", {
|
|
92
309
|
title: "List emails",
|
|
310
|
+
annotations: {
|
|
311
|
+
...READ,
|
|
312
|
+
title: "List emails"
|
|
313
|
+
},
|
|
314
|
+
outputSchema: listEmailsOutput,
|
|
93
315
|
description: "List recently sent emails, most recent first. Supports cursor pagination and filtering.",
|
|
94
316
|
inputSchema: z.object({
|
|
95
317
|
limit: z.number().int().min(1).max(100).optional().describe("Max results (1–100)."),
|
|
@@ -102,11 +324,21 @@ function registerEmailTools(server, client, config) {
|
|
|
102
324
|
}, async (args) => respond(await client.emails.list(args)));
|
|
103
325
|
server.registerTool("get_email", {
|
|
104
326
|
title: "Get an email",
|
|
327
|
+
annotations: {
|
|
328
|
+
...READ,
|
|
329
|
+
title: "Get an email"
|
|
330
|
+
},
|
|
331
|
+
outputSchema: emailOutput,
|
|
105
332
|
description: "Fetch a single email by id, including its full delivery event history.",
|
|
106
333
|
inputSchema: z.object({ id: z.string().describe("The email id returned by send_email or list_emails.") })
|
|
107
334
|
}, async ({ id }) => respond(await client.emails.get(id)));
|
|
108
335
|
server.registerTool("cancel_email", {
|
|
109
336
|
title: "Cancel a scheduled email",
|
|
337
|
+
annotations: {
|
|
338
|
+
...IRREVERSIBLE,
|
|
339
|
+
title: "Cancel a scheduled email"
|
|
340
|
+
},
|
|
341
|
+
outputSchema: cancelEmailOutput,
|
|
110
342
|
description: "Cancel a scheduled email before it sends. Fails once the email has started sending.",
|
|
111
343
|
inputSchema: z.object({ id: z.string().describe("The id of a scheduled email.") })
|
|
112
344
|
}, async ({ id }) => respond(await client.emails.cancel(id)));
|
|
@@ -116,21 +348,41 @@ function registerEmailTools(server, client, config) {
|
|
|
116
348
|
function registerDomainTools(server, client) {
|
|
117
349
|
server.registerTool("list_domains", {
|
|
118
350
|
title: "List domains",
|
|
351
|
+
annotations: {
|
|
352
|
+
...READ,
|
|
353
|
+
title: "List domains"
|
|
354
|
+
},
|
|
355
|
+
outputSchema: listDomainsOutput,
|
|
119
356
|
description: "List sending domains on the account and their verification status.",
|
|
120
357
|
inputSchema: z.object({})
|
|
121
358
|
}, async () => respond(await client.domains.list()));
|
|
122
359
|
server.registerTool("get_domain", {
|
|
123
360
|
title: "Get a domain",
|
|
361
|
+
annotations: {
|
|
362
|
+
...READ,
|
|
363
|
+
title: "Get a domain"
|
|
364
|
+
},
|
|
365
|
+
outputSchema: domainOutput,
|
|
124
366
|
description: "Fetch a single domain by id, including its DKIM selector and verification state.",
|
|
125
367
|
inputSchema: z.object({ id: z.string().describe("The domain id.") })
|
|
126
368
|
}, async ({ id }) => respond(await client.domains.get(id)));
|
|
127
369
|
server.registerTool("create_domain", {
|
|
128
370
|
title: "Add a sending domain",
|
|
371
|
+
annotations: {
|
|
372
|
+
...CREATE,
|
|
373
|
+
title: "Add a sending domain"
|
|
374
|
+
},
|
|
375
|
+
outputSchema: createDomainOutput,
|
|
129
376
|
description: "Register a new sending domain. Returns the DKIM, SPF, and DMARC DNS records that must be added at the domain's DNS provider before it can send. Present these records to the user.",
|
|
130
377
|
inputSchema: z.object({ name: z.string().describe("The domain to add, e.g. \"mail.acme.com\".") })
|
|
131
378
|
}, async ({ name }) => respond(await client.domains.create(name)));
|
|
132
379
|
server.registerTool("verify_domain", {
|
|
133
380
|
title: "Verify a sending domain",
|
|
381
|
+
annotations: {
|
|
382
|
+
...UPDATE,
|
|
383
|
+
title: "Verify a sending domain"
|
|
384
|
+
},
|
|
385
|
+
outputSchema: verifyDomainOutput,
|
|
134
386
|
description: "Re-check a domain's DNS records now. Adding a domain already starts this automatically, so use it when the records were published late or corrected — it starts a fresh check rather than waiting for the next scheduled one. Poll get_domain for the result.",
|
|
135
387
|
inputSchema: z.object({ id: z.string().describe("The domain id.") })
|
|
136
388
|
}, async ({ id }) => respond(await client.domains.verify(id)));
|
|
@@ -140,21 +392,41 @@ function registerDomainTools(server, client) {
|
|
|
140
392
|
function registerAudienceTools(server, client) {
|
|
141
393
|
server.registerTool("list_audiences", {
|
|
142
394
|
title: "List audiences",
|
|
395
|
+
annotations: {
|
|
396
|
+
...READ,
|
|
397
|
+
title: "List audiences"
|
|
398
|
+
},
|
|
399
|
+
outputSchema: listAudiencesOutput,
|
|
143
400
|
description: "List contact audiences (lists) on the account, with per-audience contact counts.",
|
|
144
401
|
inputSchema: z.object({})
|
|
145
402
|
}, async () => respond(await client.audiences.list()));
|
|
146
403
|
server.registerTool("create_audience", {
|
|
147
404
|
title: "Create an audience",
|
|
405
|
+
annotations: {
|
|
406
|
+
...CREATE,
|
|
407
|
+
title: "Create an audience"
|
|
408
|
+
},
|
|
409
|
+
outputSchema: audienceOutput,
|
|
148
410
|
description: "Create a new audience (contact list) to hold contacts for broadcasts.",
|
|
149
411
|
inputSchema: z.object({ name: z.string().describe("Human-readable name for the audience.") })
|
|
150
412
|
}, async ({ name }) => respond(await client.audiences.create(name)));
|
|
151
413
|
server.registerTool("get_audience", {
|
|
152
414
|
title: "Get an audience",
|
|
415
|
+
annotations: {
|
|
416
|
+
...READ,
|
|
417
|
+
title: "Get an audience"
|
|
418
|
+
},
|
|
419
|
+
outputSchema: audienceOutput,
|
|
153
420
|
description: "Get one audience by id, with its contact count.",
|
|
154
421
|
inputSchema: z.object({ audienceId: z.string().describe("The audience to retrieve.") })
|
|
155
422
|
}, async ({ audienceId }) => respond(await client.audiences.get(audienceId)));
|
|
156
423
|
server.registerTool("rename_audience", {
|
|
157
424
|
title: "Rename an audience",
|
|
425
|
+
annotations: {
|
|
426
|
+
...UPDATE,
|
|
427
|
+
title: "Rename an audience"
|
|
428
|
+
},
|
|
429
|
+
outputSchema: audienceOutput,
|
|
158
430
|
description: "Change the name of an audience. Its contacts and broadcasts are untouched.",
|
|
159
431
|
inputSchema: z.object({
|
|
160
432
|
audienceId: z.string().describe("The audience to rename."),
|
|
@@ -163,10 +435,15 @@ function registerAudienceTools(server, client) {
|
|
|
163
435
|
}, async ({ audienceId, name }) => respond(await client.audiences.update(audienceId, { name })));
|
|
164
436
|
server.registerTool("list_contacts", {
|
|
165
437
|
title: "List contacts",
|
|
438
|
+
annotations: {
|
|
439
|
+
...READ,
|
|
440
|
+
title: "List contacts"
|
|
441
|
+
},
|
|
442
|
+
outputSchema: listContactsOutput,
|
|
166
443
|
description: "List contacts in an audience. Supports search and subscription filtering.",
|
|
167
444
|
inputSchema: z.object({
|
|
168
445
|
audienceId: z.string().describe("The audience to list contacts from."),
|
|
169
|
-
limit: z.number().int().min(1).max(100).optional(),
|
|
446
|
+
limit: z.number().int().min(1).max(100).optional().describe("Max results (1–100)."),
|
|
170
447
|
cursor: z.string().optional().describe("Pagination cursor from a previous nextCursor."),
|
|
171
448
|
search: z.string().optional().describe("Filter by email or name substring."),
|
|
172
449
|
subscribed: z.boolean().optional().describe("true = only subscribed, false = only unsubscribed.")
|
|
@@ -174,12 +451,17 @@ function registerAudienceTools(server, client) {
|
|
|
174
451
|
}, async ({ audienceId, ...opts }) => respond(await client.audiences.listContacts(audienceId, opts)));
|
|
175
452
|
server.registerTool("create_contact", {
|
|
176
453
|
title: "Add a contact",
|
|
454
|
+
annotations: {
|
|
455
|
+
...CREATE,
|
|
456
|
+
title: "Add a contact"
|
|
457
|
+
},
|
|
458
|
+
outputSchema: contactOutput,
|
|
177
459
|
description: "Add a contact to an audience.",
|
|
178
460
|
inputSchema: z.object({
|
|
179
461
|
audienceId: z.string().describe("The audience to add the contact to."),
|
|
180
462
|
email: z.string().describe("Contact email address."),
|
|
181
|
-
firstName: z.string().optional(),
|
|
182
|
-
lastName: z.string().optional(),
|
|
463
|
+
firstName: z.string().optional().describe("First name, available as {{first_name}} in broadcasts."),
|
|
464
|
+
lastName: z.string().optional().describe("Last name, available as {{last_name}} in broadcasts."),
|
|
183
465
|
properties: z.record(z.string(), z.string()).optional().describe("Custom properties, usable as {{key}} in a broadcast body. Keys are lowercase letters, digits and underscores starting with a letter; values are strings. \"email\", \"name\", \"first_name\", \"last_name\" and \"full_name\" are built in and are rejected here.")
|
|
184
466
|
})
|
|
185
467
|
}, async ({ audienceId, email, firstName, lastName, properties }) => respond(await client.audiences.createContact(audienceId, {
|
|
@@ -190,11 +472,21 @@ function registerAudienceTools(server, client) {
|
|
|
190
472
|
})));
|
|
191
473
|
server.registerTool("list_contact_properties", {
|
|
192
474
|
title: "List contact properties",
|
|
475
|
+
annotations: {
|
|
476
|
+
...READ,
|
|
477
|
+
title: "List contact properties"
|
|
478
|
+
},
|
|
479
|
+
outputSchema: listContactPropertiesOutput,
|
|
193
480
|
description: "List the organization's declared custom contact properties — the {{variables}} available in a broadcast body beyond the built-in email, name, first_name, last_name and full_name. Read this before writing broadcast copy that personalizes on a custom field.",
|
|
194
481
|
inputSchema: z.object({})
|
|
195
482
|
}, async () => respond(await client.contactProperties.list()));
|
|
196
483
|
server.registerTool("create_contact_property", {
|
|
197
484
|
title: "Declare a contact property",
|
|
485
|
+
annotations: {
|
|
486
|
+
...CREATE,
|
|
487
|
+
title: "Declare a contact property"
|
|
488
|
+
},
|
|
489
|
+
outputSchema: contactPropertyOutput,
|
|
198
490
|
description: "Declare a custom contact property. Not required before setting one on a contact — an undeclared property registers itself as a string — but declaring it is what allows a type and a fallback value. The key and type cannot be changed afterwards.",
|
|
199
491
|
inputSchema: z.object({
|
|
200
492
|
key: z.string().describe("Lowercase letters, digits and underscores, starting with a letter; at most 40 characters. \"email\", \"name\", \"first_name\", \"last_name\" and \"full_name\" are built in and are rejected here."),
|
|
@@ -212,11 +504,21 @@ function registerAudienceTools(server, client) {
|
|
|
212
504
|
function registerTopicTools(server, client) {
|
|
213
505
|
server.registerTool("list_topics", {
|
|
214
506
|
title: "List topics",
|
|
507
|
+
annotations: {
|
|
508
|
+
...READ,
|
|
509
|
+
title: "List topics"
|
|
510
|
+
},
|
|
511
|
+
outputSchema: listTopicsOutput,
|
|
215
512
|
description: "List the subscription topics on the account — the kinds of email a contact can opt into or out of independently — with the number of contacts explicitly opted in to each. Read this before creating a broadcast, so it can be scoped to the people who asked for that kind of mail.",
|
|
216
513
|
inputSchema: z.object({})
|
|
217
514
|
}, async () => respond(await client.topics.list()));
|
|
218
515
|
server.registerTool("create_topic", {
|
|
219
516
|
title: "Create a topic",
|
|
517
|
+
annotations: {
|
|
518
|
+
...CREATE,
|
|
519
|
+
title: "Create a topic"
|
|
520
|
+
},
|
|
521
|
+
outputSchema: topicOutput,
|
|
220
522
|
description: "Create a subscription topic. Pass its id as topic_id when creating a broadcast to reach only the contacts subscribed to it. The default subscription is fixed at creation and cannot be changed afterwards, so confirm which one is wanted before calling this.",
|
|
221
523
|
inputSchema: z.object({
|
|
222
524
|
name: z.string().describe("What the recipient reads on the unsubscribe page. At most 50 characters, and unique within the account."),
|
|
@@ -236,16 +538,31 @@ function registerTopicTools(server, client) {
|
|
|
236
538
|
function registerBroadcastTools(server, client, config) {
|
|
237
539
|
server.registerTool("list_broadcasts", {
|
|
238
540
|
title: "List broadcasts",
|
|
541
|
+
annotations: {
|
|
542
|
+
...READ,
|
|
543
|
+
title: "List broadcasts"
|
|
544
|
+
},
|
|
545
|
+
outputSchema: listBroadcastsOutput,
|
|
239
546
|
description: "List broadcasts (bulk sends to an audience) with their status and send counts.",
|
|
240
547
|
inputSchema: z.object({})
|
|
241
548
|
}, async () => respond(await client.broadcasts.list()));
|
|
242
549
|
server.registerTool("get_broadcast", {
|
|
243
550
|
title: "Get a broadcast",
|
|
551
|
+
annotations: {
|
|
552
|
+
...READ,
|
|
553
|
+
title: "Get a broadcast"
|
|
554
|
+
},
|
|
555
|
+
outputSchema: broadcastOutput,
|
|
244
556
|
description: "Fetch a broadcast by id, including recipient/sent counts and current delivery-status stats.",
|
|
245
557
|
inputSchema: z.object({ id: z.string().describe("The broadcast id.") })
|
|
246
558
|
}, async ({ id }) => respond(await client.broadcasts.get(id)));
|
|
247
559
|
server.registerTool("create_broadcast", {
|
|
248
560
|
title: "Create a broadcast (draft)",
|
|
561
|
+
annotations: {
|
|
562
|
+
...CREATE,
|
|
563
|
+
title: "Create a broadcast (draft)"
|
|
564
|
+
},
|
|
565
|
+
outputSchema: broadcastOutput,
|
|
249
566
|
description: "Create a broadcast in draft state, targeting an audience. Does NOT send it — use send_broadcast to send or schedule after reviewing. If `from` is omitted the configured default sender is used.",
|
|
250
567
|
inputSchema: z.object({
|
|
251
568
|
name: z.string().describe("Internal name for the broadcast."),
|
|
@@ -269,6 +586,11 @@ function registerBroadcastTools(server, client, config) {
|
|
|
269
586
|
});
|
|
270
587
|
server.registerTool("send_broadcast", {
|
|
271
588
|
title: "Send or schedule a broadcast",
|
|
589
|
+
annotations: {
|
|
590
|
+
...SENDS_MAIL,
|
|
591
|
+
title: "Send or schedule a broadcast"
|
|
592
|
+
},
|
|
593
|
+
outputSchema: sendBroadcastOutput,
|
|
272
594
|
description: "Send a draft broadcast to its entire audience now, or schedule it for later. This is a bulk send — confirm with the user before calling. Omit `scheduledAt` to send immediately.",
|
|
273
595
|
inputSchema: z.object({
|
|
274
596
|
id: z.string().describe("The draft broadcast id."),
|
|
@@ -277,6 +599,11 @@ function registerBroadcastTools(server, client, config) {
|
|
|
277
599
|
}, async ({ id, scheduledAt }) => respond(await client.broadcasts.send(id, { scheduledAt })));
|
|
278
600
|
server.registerTool("test_broadcast", {
|
|
279
601
|
title: "Send a test copy of a broadcast",
|
|
602
|
+
annotations: {
|
|
603
|
+
...SENDS_MAIL,
|
|
604
|
+
title: "Send a test copy of a broadcast"
|
|
605
|
+
},
|
|
606
|
+
outputSchema: testBroadcastOutput,
|
|
280
607
|
description: "Send the broadcast to your own verified addresses to check how it renders, without mailing the audience. Prefer this before send_broadcast — it is reversible in the sense that nobody on the list receives anything, and it leaves the broadcast a draft. Recipients must be on a domain verified on the account; anything else is refused. Works on the free plan, unlike send_broadcast.",
|
|
281
608
|
inputSchema: z.object({
|
|
282
609
|
id: z.string().describe("The broadcast id."),
|
|
@@ -294,16 +621,26 @@ const reason = z.enum([
|
|
|
294
621
|
function registerSuppressionTools(server, client) {
|
|
295
622
|
server.registerTool("list_suppressions", {
|
|
296
623
|
title: "List suppressed addresses",
|
|
624
|
+
annotations: {
|
|
625
|
+
...READ,
|
|
626
|
+
title: "List suppressed addresses"
|
|
627
|
+
},
|
|
628
|
+
outputSchema: listSuppressionsOutput,
|
|
297
629
|
description: "List addresses the account will not send to. Hard bounces and spam complaints are suppressed automatically. Use this to explain why an email came back with status \"suppressed\" or an ALL_SUPPRESSED error.",
|
|
298
630
|
inputSchema: z.object({
|
|
299
631
|
email: z.string().optional().describe("Match addresses containing this substring. Pass a domain (\"@acme.com\") to see every suppressed address there."),
|
|
300
632
|
reason: reason.optional().describe("Filter by why the address was suppressed."),
|
|
301
|
-
limit: z.number().int().min(1).max(100).optional(),
|
|
633
|
+
limit: z.number().int().min(1).max(100).optional().describe("Max results (1–100)."),
|
|
302
634
|
cursor: z.string().optional().describe("Pagination cursor from a previous next_cursor.")
|
|
303
635
|
})
|
|
304
636
|
}, async (opts) => respond(await client.suppressions.list(opts)));
|
|
305
637
|
server.registerTool("create_suppression", {
|
|
306
638
|
title: "Suppress an address",
|
|
639
|
+
annotations: {
|
|
640
|
+
...UPDATE,
|
|
641
|
+
title: "Suppress an address"
|
|
642
|
+
},
|
|
643
|
+
outputSchema: suppressionOutput,
|
|
307
644
|
description: "Stop sending to an address. If it is already suppressed the existing entry is returned unchanged — this never overwrites the reason an address was suppressed for.",
|
|
308
645
|
inputSchema: z.object({
|
|
309
646
|
email: z.string().describe("The address to suppress."),
|
|
@@ -317,7 +654,7 @@ function registerSuppressionTools(server, client) {
|
|
|
317
654
|
//#endregion
|
|
318
655
|
//#region src/server.ts
|
|
319
656
|
const SERVER_NAME = "eusend";
|
|
320
|
-
const SERVER_VERSION = "0.
|
|
657
|
+
const SERVER_VERSION = "0.10.1";
|
|
321
658
|
/**
|
|
322
659
|
* Build a fully-wired MCP server for one Eusend account. This is
|
|
323
660
|
* transport-agnostic: the stdio entry (index.ts) and the HTTP entry (http.ts)
|
|
@@ -327,7 +664,18 @@ const SERVER_VERSION = "0.9.0";
|
|
|
327
664
|
function createServer$1(config) {
|
|
328
665
|
const server = new McpServer({
|
|
329
666
|
name: SERVER_NAME,
|
|
330
|
-
|
|
667
|
+
title: "eusend",
|
|
668
|
+
version: SERVER_VERSION,
|
|
669
|
+
description: "EU-native email API. Send transactional email, add and verify sending domains, manage audiences, contacts and topics, and draft, test and send broadcasts — all processed in the EU.",
|
|
670
|
+
websiteUrl: "https://eusend.dev/docs/mcp",
|
|
671
|
+
icons: [{
|
|
672
|
+
src: "https://eusend.dev/brand/eusend-mark-blue.svg",
|
|
673
|
+
mimeType: "image/svg+xml"
|
|
674
|
+
}, {
|
|
675
|
+
src: "https://eusend.dev/apple-icon",
|
|
676
|
+
mimeType: "image/png",
|
|
677
|
+
sizes: ["180x180"]
|
|
678
|
+
}]
|
|
331
679
|
});
|
|
332
680
|
const client = new Eusend(config.apiKey, { baseUrl: config.baseUrl });
|
|
333
681
|
registerEmailTools(server, client, config);
|
|
@@ -584,4 +932,4 @@ async function handle(req, res, nodeHandler, validateHost, oauth) {
|
|
|
584
932
|
//#endregion
|
|
585
933
|
export { createServer$1 as n, runHttp as t };
|
|
586
934
|
|
|
587
|
-
//# sourceMappingURL=http-
|
|
935
|
+
//# sourceMappingURL=http-BJIfmzt4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-BJIfmzt4.mjs","names":["emailStatus","createServer","createServer","createHttpServer"],"sources":["../src/respond.ts","../src/annotations.ts","../src/schemas.ts","../src/tools/emails.ts","../src/tools/domains.ts","../src/tools/audiences.ts","../src/tools/topics.ts","../src/tools/broadcasts.ts","../src/tools/suppressions.ts","../src/server.ts","../src/ratelimit.ts","../src/http.ts"],"sourcesContent":["import type { CallToolResult } from '@modelcontextprotocol/server'\nimport type { EusendError, EusendResponse } from '@eusend_dev/sdk'\n\n/** MCP tool return shape. */\nexport type ToolResult = CallToolResult\n\n/**\n * Wrap a successful payload as structured content plus the same JSON as text, for clients\n * that only read `content`. Structured content must be an object, so a bare list is returned\n * as `{ data: [...] }` — the same envelope the paginated endpoints already use.\n */\nexport function ok(data: unknown): ToolResult {\n const structured = (Array.isArray(data) ? { data } : (data ?? {})) as Record<string, unknown>\n return {\n content: [{ type: 'text', text: JSON.stringify(structured, null, 2) }],\n structuredContent: structured,\n }\n}\n\n/**\n * Surface an SDK error as an MCP tool error. `isError: true` tells the client\n * the call failed, and the error `name` (e.g. DOMAIN_NOT_VERIFIED) gives the\n * agent enough to self-correct — e.g. verify the domain, then retry.\n */\nexport function fail(error: EusendError): ToolResult {\n return {\n content: [{ type: 'text', text: `Error [${error.name}]: ${error.message}` }],\n isError: true,\n }\n}\n\n/** Plain text error for validation the tool does itself before hitting the API. */\nexport function failText(message: string): ToolResult {\n return { content: [{ type: 'text', text: message }], isError: true }\n}\n\n/** Turn any SDK `EusendResponse` into a tool result. */\nexport function respond<T>(res: EusendResponse<T>): ToolResult {\n return res.error ? fail(res.error) : ok(res.data)\n}\n","import type { ToolAnnotations } from '@modelcontextprotocol/server'\n\n// Hints for clients deciding what to confirm. \"Open world\" here means the call reaches\n// people outside the account — it puts mail in someone's inbox.\n\nexport const READ: ToolAnnotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n}\n\nexport const CREATE: ToolAnnotations = {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: false,\n}\n\nexport const UPDATE: ToolAnnotations = {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n}\n\nexport const SENDS_MAIL: ToolAnnotations = {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n}\n\nexport const IRREVERSIBLE: ToolAnnotations = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: false,\n}\n","import { z } from 'zod'\n\n// Output schemas for every tool, mirroring the SDK response types. Objects are loose and\n// enum-valued fields are plain strings on purpose: the server validates each result against\n// these, so an API that grows a field or a status must not turn a successful call into an error.\n\nconst timestamp = z.string().describe('ISO 8601 timestamp.')\nconst id = z.string()\n\nconst list = <T extends z.ZodType>(item: T, cursorKey: 'nextCursor' | 'next_cursor' | null) =>\n z.looseObject({\n data: z.array(item),\n ...(cursorKey\n ? {\n [cursorKey]: z\n .string()\n .nullish()\n .describe('Pass as `cursor` to fetch the next page; null on the last page.'),\n }\n : {}),\n })\n\nconst emailStatus = z\n .string()\n .describe(\n 'queued, scheduled, canceled, sending, sent, delivered, bounced, complained, suppressed or failed.',\n )\n\nconst emailListItem = z.looseObject({\n id,\n from: z.string(),\n to: z.array(z.string()),\n subject: z.string(),\n status: emailStatus,\n tags: z.record(z.string(), z.string()).nullish(),\n testMode: z.boolean().nullish(),\n createdAt: timestamp,\n})\n\nexport const sendEmailOutput = z.looseObject({\n id: id.describe('Id of the queued email; pass to get_email to follow its delivery.'),\n})\n\nexport const listEmailsOutput = list(emailListItem, 'nextCursor')\n\nexport const emailOutput = emailListItem.extend({\n cc: z.array(z.string()).nullish(),\n bcc: z.array(z.string()).nullish(),\n replyTo: z.array(z.string()).nullish(),\n html: z.string().nullish(),\n text: z.string().nullish(),\n templateId: z.string().nullish(),\n scheduledAt: timestamp.nullish(),\n events: z\n .array(\n z.looseObject({\n id,\n type: z.string().describe('sent, delivered, opened, clicked, bounced or complained.'),\n metadata: z.record(z.string(), z.unknown()).nullish(),\n createdAt: timestamp,\n }),\n )\n .describe('Delivery events, oldest first.'),\n})\n\nexport const cancelEmailOutput = z.looseObject({ id, status: z.string() })\n\nconst domainStatus = z.string().describe('pending, verified or failed.')\n\nconst dnsRecord = z.looseObject({\n type: z.string(),\n name: z.string(),\n value: z.string(),\n priority: z.number().optional(),\n purpose: z.string().optional(),\n description: z.string().optional(),\n})\n\nconst domainListItem = z.looseObject({\n id,\n name: z.string(),\n status: domainStatus,\n createdAt: timestamp,\n})\n\nexport const listDomainsOutput = list(domainListItem, null)\n\nexport const domainOutput = domainListItem.extend({\n dkimPublicKey: z.string().nullish(),\n dkimSelector: z.string().nullish(),\n verifiedAt: timestamp.nullish(),\n returnPathAligned: z\n .boolean()\n .optional()\n .describe('Whether bounces return to send.<domain>, so SPF aligns with the From domain.'),\n records: z.array(dnsRecord).optional().describe('The DNS records this domain needs published.'),\n verification: z\n .looseObject({ running: z.boolean(), startedAt: timestamp.nullish() })\n .nullish()\n .describe('Whether a DNS check is in progress.'),\n diagnostic: z\n .looseObject({ code: z.string() })\n .nullish()\n .describe('Why verification is failing, when it is.'),\n})\n\nexport const createDomainOutput = z.looseObject({\n id,\n name: z.string(),\n records: z.array(dnsRecord).describe('Every DNS record to publish before the domain can send.'),\n dkim: dnsRecord.nullish(),\n dmarc: dnsRecord.nullish(),\n})\n\nexport const verifyDomainOutput = z.looseObject({ message: z.string() })\n\nconst audienceListItem = z.looseObject({\n id,\n name: z.string(),\n createdAt: timestamp,\n contactCount: z.number(),\n})\n\nexport const listAudiencesOutput = list(audienceListItem, null)\n\nexport const audienceOutput = z.looseObject({\n id,\n name: z.string(),\n contactCount: z.number().optional(),\n createdAt: timestamp,\n updatedAt: timestamp.nullish(),\n})\n\nconst contact = z.looseObject({\n id,\n audienceId: z.string(),\n email: z.string(),\n firstName: z.string().nullish(),\n lastName: z.string().nullish(),\n properties: z.record(z.string(), z.string()).nullish(),\n status: z.string().describe('subscribed or unsubscribed.'),\n unsubscribedAt: timestamp.nullish(),\n createdAt: timestamp,\n updatedAt: timestamp.nullish(),\n})\n\nexport const contactOutput = contact\nexport const listContactsOutput = list(contact, 'nextCursor')\n\nconst contactProperty = z.looseObject({\n id,\n key: z.string(),\n type: z.string().describe('string or number.'),\n fallbackValue: z.string().nullish(),\n createdAt: timestamp,\n updatedAt: timestamp.nullish(),\n})\n\nexport const contactPropertyOutput = contactProperty\nexport const listContactPropertiesOutput = list(contactProperty, null)\n\nconst topic = z.looseObject({\n id,\n name: z.string(),\n description: z.string().nullish(),\n defaultSubscription: z.string().describe('opt_in or opt_out.'),\n visibility: z.string().describe('public or private.'),\n subscriberCount: z.number().optional(),\n createdAt: timestamp,\n updatedAt: timestamp.nullish(),\n})\n\nexport const topicOutput = topic\nexport const listTopicsOutput = list(topic, null)\n\nconst broadcastStatus = z\n .string()\n .describe('draft, scheduled, sending, sent, paused, held or cancelled.')\n\nconst broadcastBase = z.looseObject({\n id,\n name: z.string(),\n status: broadcastStatus,\n audienceId: z.string().nullish(),\n topicId: z.string().nullish(),\n fromAddress: z.string(),\n subject: z.string(),\n recipientCount: z.number().nullish(),\n sentCount: z.number().nullish(),\n scheduledAt: timestamp.nullish(),\n startedAt: timestamp.nullish(),\n completedAt: timestamp.nullish(),\n createdAt: timestamp,\n})\n\nexport const listBroadcastsOutput = list(\n broadcastBase.extend({\n topicName: z.string().nullish(),\n audienceName: z.string().nullish(),\n }),\n null,\n)\n\nexport const broadcastOutput = broadcastBase.extend({\n replyTo: z.string().nullish(),\n html: z.string().nullish(),\n heldReason: z.string().nullish().describe('Why the broadcast is held for review, when it is.'),\n trackOpens: z.boolean().nullish(),\n trackClicks: z.boolean().nullish(),\n updatedAt: timestamp.nullish(),\n stats: z\n .record(z.string(), z.number())\n .optional()\n .describe('Recipient counts by delivery status. Present on get_broadcast.'),\n})\n\nexport const sendBroadcastOutput = z.looseObject({\n id,\n status: z.string().describe('sending or scheduled.'),\n scheduledAt: timestamp.nullish(),\n})\n\nexport const testBroadcastOutput = z.looseObject({\n id,\n sentTo: z.array(z.string()),\n emailIds: z.array(z.string()),\n})\n\nconst suppression = z.looseObject({\n id,\n email: z.string(),\n reason: z.string().describe('bounce, complaint or manual.'),\n created_at: timestamp,\n})\n\nexport const suppressionOutput = suppression\nexport const listSuppressionsOutput = list(suppression, 'next_cursor')\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport type { McpConfig } from '../config.js'\nimport { respond, failText } from '../respond.js'\nimport { IRREVERSIBLE, READ, SENDS_MAIL } from '../annotations.js'\nimport { cancelEmailOutput, emailOutput, listEmailsOutput, sendEmailOutput } from '../schemas.js'\n\nconst emailStatus = z.enum([\n 'queued',\n 'scheduled',\n 'canceled',\n 'sending',\n 'sent',\n 'delivered',\n 'bounced',\n 'complained',\n 'suppressed',\n 'failed',\n])\n\nconst recipients = z.union([z.string(), z.array(z.string())])\n\nexport function registerEmailTools(server: McpServer, client: Eusend, config: McpConfig): void {\n server.registerTool(\n 'send_email',\n {\n title: 'Send an email',\n annotations: { ...SENDS_MAIL, title: 'Send an email' },\n outputSchema: sendEmailOutput,\n description:\n 'Send a transactional email through Eusend. Provide `html` or `text` (or both). ' +\n 'The sender domain must be verified on the account — use list_domains to check. ' +\n 'If `from` is omitted, the server-configured default sender is used.',\n inputSchema: z.object({\n from: z\n .string()\n .optional()\n .describe('Sender, e.g. \"Acme <hi@acme.com>\". Defaults to the configured sender.'),\n to: recipients.describe('Recipient address or list of addresses.'),\n subject: z.string().describe('Email subject line.'),\n text: z.string().optional().describe('Plain-text body.'),\n html: z.string().optional().describe('HTML body. Takes precedence over text for display.'),\n cc: recipients.optional().describe('Carbon-copy address(es).'),\n bcc: recipients\n .optional()\n .describe('Blind carbon-copy address(es), hidden from other recipients.'),\n replyTo: recipients.optional().describe('Reply-To address(es).'),\n tags: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Labels for log filtering and webhook routing, e.g. {\"category\": \"password_reset\"}. ' +\n 'Names and values allow ASCII letters, numbers, underscores and dashes; max 10 tags.',\n ),\n scheduledAt: z\n .string()\n .optional()\n .describe(\n 'Future send time: ISO 8601 or natural language like \"in 1 hour\". Max 30 days out.',\n ),\n }),\n },\n async (args) => {\n const from = args.from ?? config.defaultFrom\n if (!from) {\n return failText(\n 'No sender specified and no default sender configured. Pass `from`, or set EUSEND_FROM / --from on the server.',\n )\n }\n if (!args.html && !args.text) {\n return failText('Provide at least one of `html` or `text`.')\n }\n return respond(\n await client.emails.send({\n from,\n to: args.to,\n subject: args.subject,\n text: args.text,\n html: args.html,\n cc: args.cc,\n bcc: args.bcc,\n replyTo: args.replyTo ?? config.defaultReplyTo,\n tags: args.tags,\n scheduledAt: args.scheduledAt,\n }),\n )\n },\n )\n\n server.registerTool(\n 'list_emails',\n {\n title: 'List emails',\n annotations: { ...READ, title: 'List emails' },\n outputSchema: listEmailsOutput,\n description:\n 'List recently sent emails, most recent first. Supports cursor pagination and filtering.',\n inputSchema: z.object({\n limit: z.number().int().min(1).max(100).optional().describe('Max results (1–100).'),\n cursor: z.string().optional().describe('Pagination cursor from a previous nextCursor.'),\n status: emailStatus.optional().describe('Filter by delivery status.'),\n from: z.string().optional().describe('Filter by sender address.'),\n to: z.string().optional().describe('Filter by recipient address.'),\n tag: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe(\n 'Filter by tag: \"category:password_reset\" for an exact pair, or bare \"category\" ' +\n 'for any email carrying the tag. An array requires all of them.',\n ),\n }),\n },\n async (args) => respond(await client.emails.list(args)),\n )\n\n server.registerTool(\n 'get_email',\n {\n title: 'Get an email',\n annotations: { ...READ, title: 'Get an email' },\n outputSchema: emailOutput,\n description: 'Fetch a single email by id, including its full delivery event history.',\n inputSchema: z.object({\n id: z.string().describe('The email id returned by send_email or list_emails.'),\n }),\n },\n async ({ id }) => respond(await client.emails.get(id)),\n )\n\n server.registerTool(\n 'cancel_email',\n {\n title: 'Cancel a scheduled email',\n annotations: { ...IRREVERSIBLE, title: 'Cancel a scheduled email' },\n outputSchema: cancelEmailOutput,\n description:\n 'Cancel a scheduled email before it sends. Fails once the email has started sending.',\n inputSchema: z.object({\n id: z.string().describe('The id of a scheduled email.'),\n }),\n },\n async ({ id }) => respond(await client.emails.cancel(id)),\n )\n}\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport { respond } from '../respond.js'\nimport { CREATE, READ, UPDATE } from '../annotations.js'\nimport {\n createDomainOutput,\n domainOutput,\n listDomainsOutput,\n verifyDomainOutput,\n} from '../schemas.js'\n\nexport function registerDomainTools(server: McpServer, client: Eusend): void {\n server.registerTool(\n 'list_domains',\n {\n title: 'List domains',\n annotations: { ...READ, title: 'List domains' },\n outputSchema: listDomainsOutput,\n description: 'List sending domains on the account and their verification status.',\n inputSchema: z.object({}),\n },\n async () => respond(await client.domains.list()),\n )\n\n server.registerTool(\n 'get_domain',\n {\n title: 'Get a domain',\n annotations: { ...READ, title: 'Get a domain' },\n outputSchema: domainOutput,\n description:\n 'Fetch a single domain by id, including its DKIM selector and verification state.',\n inputSchema: z.object({\n id: z.string().describe('The domain id.'),\n }),\n },\n async ({ id }) => respond(await client.domains.get(id)),\n )\n\n server.registerTool(\n 'create_domain',\n {\n title: 'Add a sending domain',\n annotations: { ...CREATE, title: 'Add a sending domain' },\n outputSchema: createDomainOutput,\n description:\n 'Register a new sending domain. Returns the DKIM, SPF, and DMARC DNS records that must be ' +\n \"added at the domain's DNS provider before it can send. Present these records to the user.\",\n inputSchema: z.object({\n name: z.string().describe('The domain to add, e.g. \"mail.acme.com\".'),\n }),\n },\n async ({ name }) => respond(await client.domains.create(name)),\n )\n\n server.registerTool(\n 'verify_domain',\n {\n title: 'Verify a sending domain',\n annotations: { ...UPDATE, title: 'Verify a sending domain' },\n outputSchema: verifyDomainOutput,\n description:\n \"Re-check a domain's DNS records now. Adding a domain already starts this automatically, \" +\n 'so use it when the records were published late or corrected — it starts a fresh check ' +\n 'rather than waiting for the next scheduled one. Poll get_domain for the result.',\n inputSchema: z.object({\n id: z.string().describe('The domain id.'),\n }),\n },\n async ({ id }) => respond(await client.domains.verify(id)),\n )\n}\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport { respond } from '../respond.js'\nimport { CREATE, READ, UPDATE } from '../annotations.js'\nimport {\n audienceOutput,\n contactOutput,\n contactPropertyOutput,\n listAudiencesOutput,\n listContactPropertiesOutput,\n listContactsOutput,\n} from '../schemas.js'\n\nexport function registerAudienceTools(server: McpServer, client: Eusend): void {\n server.registerTool(\n 'list_audiences',\n {\n title: 'List audiences',\n annotations: { ...READ, title: 'List audiences' },\n outputSchema: listAudiencesOutput,\n description:\n 'List contact audiences (lists) on the account, with per-audience contact counts.',\n inputSchema: z.object({}),\n },\n async () => respond(await client.audiences.list()),\n )\n\n server.registerTool(\n 'create_audience',\n {\n title: 'Create an audience',\n annotations: { ...CREATE, title: 'Create an audience' },\n outputSchema: audienceOutput,\n description: 'Create a new audience (contact list) to hold contacts for broadcasts.',\n inputSchema: z.object({\n name: z.string().describe('Human-readable name for the audience.'),\n }),\n },\n async ({ name }) => respond(await client.audiences.create(name)),\n )\n\n server.registerTool(\n 'get_audience',\n {\n title: 'Get an audience',\n annotations: { ...READ, title: 'Get an audience' },\n outputSchema: audienceOutput,\n description: 'Get one audience by id, with its contact count.',\n inputSchema: z.object({\n audienceId: z.string().describe('The audience to retrieve.'),\n }),\n },\n async ({ audienceId }) => respond(await client.audiences.get(audienceId)),\n )\n\n server.registerTool(\n 'rename_audience',\n {\n title: 'Rename an audience',\n annotations: { ...UPDATE, title: 'Rename an audience' },\n outputSchema: audienceOutput,\n description: 'Change the name of an audience. Its contacts and broadcasts are untouched.',\n inputSchema: z.object({\n audienceId: z.string().describe('The audience to rename.'),\n name: z.string().describe('The new name.'),\n }),\n },\n async ({ audienceId, name }) => respond(await client.audiences.update(audienceId, { name })),\n )\n\n server.registerTool(\n 'list_contacts',\n {\n title: 'List contacts',\n annotations: { ...READ, title: 'List contacts' },\n outputSchema: listContactsOutput,\n description: 'List contacts in an audience. Supports search and subscription filtering.',\n inputSchema: z.object({\n audienceId: z.string().describe('The audience to list contacts from.'),\n limit: z.number().int().min(1).max(100).optional().describe('Max results (1–100).'),\n cursor: z.string().optional().describe('Pagination cursor from a previous nextCursor.'),\n search: z.string().optional().describe('Filter by email or name substring.'),\n subscribed: z\n .boolean()\n .optional()\n .describe('true = only subscribed, false = only unsubscribed.'),\n }),\n },\n async ({ audienceId, ...opts }) =>\n respond(await client.audiences.listContacts(audienceId, opts)),\n )\n\n server.registerTool(\n 'create_contact',\n {\n title: 'Add a contact',\n annotations: { ...CREATE, title: 'Add a contact' },\n outputSchema: contactOutput,\n description: 'Add a contact to an audience.',\n inputSchema: z.object({\n audienceId: z.string().describe('The audience to add the contact to.'),\n email: z.string().describe('Contact email address.'),\n firstName: z\n .string()\n .optional()\n .describe('First name, available as {{first_name}} in broadcasts.'),\n lastName: z\n .string()\n .optional()\n .describe('Last name, available as {{last_name}} in broadcasts.'),\n properties: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Custom properties, usable as {{key}} in a broadcast body. Keys are lowercase letters, digits and underscores starting with a letter; values are strings. \"email\", \"name\", \"first_name\", \"last_name\" and \"full_name\" are built in and are rejected here.',\n ),\n }),\n },\n async ({ audienceId, email, firstName, lastName, properties }) =>\n respond(\n await client.audiences.createContact(audienceId, {\n email,\n firstName,\n lastName,\n properties,\n }),\n ),\n )\n\n server.registerTool(\n 'list_contact_properties',\n {\n title: 'List contact properties',\n annotations: { ...READ, title: 'List contact properties' },\n outputSchema: listContactPropertiesOutput,\n description:\n \"List the organization's declared custom contact properties — the {{variables}} available in a broadcast body beyond the built-in email, name, first_name, last_name and full_name. Read this before writing broadcast copy that personalizes on a custom field.\",\n inputSchema: z.object({}),\n },\n async () => respond(await client.contactProperties.list()),\n )\n\n server.registerTool(\n 'create_contact_property',\n {\n title: 'Declare a contact property',\n annotations: { ...CREATE, title: 'Declare a contact property' },\n outputSchema: contactPropertyOutput,\n description:\n 'Declare a custom contact property. Not required before setting one on a contact — an undeclared property registers itself as a string — but declaring it is what allows a type and a fallback value. The key and type cannot be changed afterwards.',\n inputSchema: z.object({\n key: z\n .string()\n .describe(\n 'Lowercase letters, digits and underscores, starting with a letter; at most 40 characters. \"email\", \"name\", \"first_name\", \"last_name\" and \"full_name\" are built in and are rejected here.',\n ),\n type: z\n .enum(['string', 'number'])\n .optional()\n .describe(\n 'Defaults to string. Values render as strings either way — \"number\" is a write-time check, not formatting.',\n ),\n fallbackValue: z\n .string()\n .optional()\n .describe(\n 'Substituted into {{key}} for contacts carrying no value of their own. Must match the type.',\n ),\n }),\n },\n async ({ key, type, fallbackValue }) =>\n respond(await client.contactProperties.create({ key, type, fallbackValue })),\n )\n}\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport { respond } from '../respond.js'\nimport { CREATE, READ } from '../annotations.js'\nimport { listTopicsOutput, topicOutput } from '../schemas.js'\n\nexport function registerTopicTools(server: McpServer, client: Eusend): void {\n server.registerTool(\n 'list_topics',\n {\n title: 'List topics',\n annotations: { ...READ, title: 'List topics' },\n outputSchema: listTopicsOutput,\n description:\n 'List the subscription topics on the account — the kinds of email a contact can opt into or out of independently — with the number of contacts explicitly opted in to each. Read this before creating a broadcast, so it can be scoped to the people who asked for that kind of mail.',\n inputSchema: z.object({}),\n },\n async () => respond(await client.topics.list()),\n )\n\n server.registerTool(\n 'create_topic',\n {\n title: 'Create a topic',\n annotations: { ...CREATE, title: 'Create a topic' },\n outputSchema: topicOutput,\n description:\n 'Create a subscription topic. Pass its id as topic_id when creating a broadcast to reach only the contacts subscribed to it. The default subscription is fixed at creation and cannot be changed afterwards, so confirm which one is wanted before calling this.',\n inputSchema: z.object({\n name: z\n .string()\n .describe(\n 'What the recipient reads on the unsubscribe page. At most 50 characters, and unique within the account.',\n ),\n defaultSubscription: z\n .enum(['opt_in', 'opt_out'])\n .describe(\n 'What a contact who has never expressed a preference receives. \"opt_in\" reaches everyone until they unsubscribe — right for a newsletter the list signed up for. \"opt_out\" reaches nobody until they explicitly join — right for anything a contact has to ask for, like a beta programme or a high-frequency digest. CANNOT be changed later.',\n ),\n description: z\n .string()\n .optional()\n .describe(\n 'Shown under the name on the unsubscribe page. At most 200 characters. Worth writing: it is what tells a recipient whether to keep the box ticked.',\n ),\n visibility: z\n .enum(['public', 'private'])\n .optional()\n .describe(\n 'Defaults to \"private\", which lists the topic on the unsubscribe page only to contacts already opted in. Use \"public\" only for a topic you are happy for anyone to discover — an internal campaign name shown to someone not on it invites them to opt out of something they were never getting.',\n ),\n }),\n },\n async ({ name, defaultSubscription, description, visibility }) =>\n respond(await client.topics.create({ name, defaultSubscription, description, visibility })),\n )\n\n // Deliberately absent, in line with the server's rule that destructive actions stay out\n // of the assistant's reach: `delete_topic` drops every stored preference for it, and\n // `update_topic` can flip a topic from private to public, which exposes an internal\n // campaign name to every recipient who opens an unsubscribe page. Neither is something\n // to do in a single tool call, and both are one click away in the dashboard.\n //\n // Changing a CONTACT's subscription is out for the same reason on the other side: it is\n // a consent record, and an assistant writing one in bulk is exactly the pattern that\n // makes a preference centre worthless.\n}\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport type { McpConfig } from '../config.js'\nimport { respond, failText } from '../respond.js'\nimport { CREATE, READ, SENDS_MAIL } from '../annotations.js'\nimport {\n broadcastOutput,\n listBroadcastsOutput,\n sendBroadcastOutput,\n testBroadcastOutput,\n} from '../schemas.js'\n\nexport function registerBroadcastTools(server: McpServer, client: Eusend, config: McpConfig): void {\n server.registerTool(\n 'list_broadcasts',\n {\n title: 'List broadcasts',\n annotations: { ...READ, title: 'List broadcasts' },\n outputSchema: listBroadcastsOutput,\n description: 'List broadcasts (bulk sends to an audience) with their status and send counts.',\n inputSchema: z.object({}),\n },\n async () => respond(await client.broadcasts.list()),\n )\n\n server.registerTool(\n 'get_broadcast',\n {\n title: 'Get a broadcast',\n annotations: { ...READ, title: 'Get a broadcast' },\n outputSchema: broadcastOutput,\n description:\n 'Fetch a broadcast by id, including recipient/sent counts and current delivery-status stats.',\n inputSchema: z.object({\n id: z.string().describe('The broadcast id.'),\n }),\n },\n async ({ id }) => respond(await client.broadcasts.get(id)),\n )\n\n server.registerTool(\n 'create_broadcast',\n {\n title: 'Create a broadcast (draft)',\n annotations: { ...CREATE, title: 'Create a broadcast (draft)' },\n outputSchema: broadcastOutput,\n description:\n 'Create a broadcast in draft state, targeting an audience. Does NOT send it — use send_broadcast ' +\n 'to send or schedule after reviewing. If `from` is omitted the configured default sender is used.',\n inputSchema: z.object({\n name: z.string().describe('Internal name for the broadcast.'),\n audienceId: z.string().describe('The audience to send to.'),\n topicId: z\n .string()\n .optional()\n .describe(\n 'Narrows the audience to the contacts subscribed to this topic. Omit to send to the whole audience. Call list_topics first when the message is one kind of mail among several — sending a product announcement to everyone is what drives unsubscribes.',\n ),\n subject: z.string().describe('Email subject line.'),\n from: z.string().optional().describe('Sender. Defaults to the configured sender.'),\n html: z.string().optional().describe('HTML body of the broadcast.'),\n }),\n },\n async (args) => {\n const from = args.from ?? config.defaultFrom\n if (!from) {\n return failText(\n 'No sender specified and no default sender configured. Pass `from`, or set EUSEND_FROM / --from on the server.',\n )\n }\n return respond(\n await client.broadcasts.create({\n name: args.name,\n audienceId: args.audienceId,\n topicId: args.topicId,\n subject: args.subject,\n from,\n html: args.html,\n }),\n )\n },\n )\n\n server.registerTool(\n 'send_broadcast',\n {\n title: 'Send or schedule a broadcast',\n annotations: { ...SENDS_MAIL, title: 'Send or schedule a broadcast' },\n outputSchema: sendBroadcastOutput,\n description:\n 'Send a draft broadcast to its entire audience now, or schedule it for later. This is a bulk send — ' +\n 'confirm with the user before calling. Omit `scheduledAt` to send immediately.',\n inputSchema: z.object({\n id: z.string().describe('The draft broadcast id.'),\n scheduledAt: z\n .string()\n .optional()\n .describe('Optional future send time (ISO 8601). Omit to send immediately.'),\n }),\n },\n async ({ id, scheduledAt }) => respond(await client.broadcasts.send(id, { scheduledAt })),\n )\n\n server.registerTool(\n 'test_broadcast',\n {\n title: 'Send a test copy of a broadcast',\n annotations: { ...SENDS_MAIL, title: 'Send a test copy of a broadcast' },\n outputSchema: testBroadcastOutput,\n description:\n 'Send the broadcast to your own verified addresses to check how it renders, without mailing the ' +\n 'audience. Prefer this before send_broadcast — it is reversible in the sense that nobody on the ' +\n 'list receives anything, and it leaves the broadcast a draft. Recipients must be on a domain ' +\n 'verified on the account; anything else is refused. Works on the free plan, unlike send_broadcast.',\n inputSchema: z.object({\n id: z.string().describe('The broadcast id.'),\n to: z\n .array(z.string())\n .min(1)\n .max(5)\n .describe('1-5 addresses, each on a domain verified on this account.'),\n }),\n },\n async ({ id, to }) => respond(await client.broadcasts.test(id, { to })),\n )\n}\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport { respond } from '../respond.js'\nimport { READ, UPDATE } from '../annotations.js'\nimport { listSuppressionsOutput, suppressionOutput } from '../schemas.js'\n\nconst reason = z.enum(['bounce', 'complaint', 'manual'])\n\nexport function registerSuppressionTools(server: McpServer, client: Eusend): void {\n server.registerTool(\n 'list_suppressions',\n {\n title: 'List suppressed addresses',\n annotations: { ...READ, title: 'List suppressed addresses' },\n outputSchema: listSuppressionsOutput,\n description:\n 'List addresses the account will not send to. Hard bounces and spam complaints are suppressed automatically. Use this to explain why an email came back with status \"suppressed\" or an ALL_SUPPRESSED error.',\n inputSchema: z.object({\n email: z\n .string()\n .optional()\n .describe(\n 'Match addresses containing this substring. Pass a domain (\"@acme.com\") to see every suppressed address there.',\n ),\n reason: reason.optional().describe('Filter by why the address was suppressed.'),\n limit: z.number().int().min(1).max(100).optional().describe('Max results (1–100).'),\n cursor: z.string().optional().describe('Pagination cursor from a previous next_cursor.'),\n }),\n },\n async (opts) => respond(await client.suppressions.list(opts)),\n )\n\n server.registerTool(\n 'create_suppression',\n {\n title: 'Suppress an address',\n annotations: { ...UPDATE, title: 'Suppress an address' },\n outputSchema: suppressionOutput,\n description:\n 'Stop sending to an address. If it is already suppressed the existing entry is returned unchanged — this never overwrites the reason an address was suppressed for.',\n inputSchema: z.object({\n email: z.string().describe('The address to suppress.'),\n reason: reason.optional().describe('Defaults to \"manual\".'),\n }),\n },\n async ({ email, reason: why }) =>\n respond(await client.suppressions.create({ email, reason: why })),\n )\n\n // Un-suppressing is deliberately absent, in line with the server's rule that\n // destructive actions stay out of the assistant's reach. Suppressing stops mail, which\n // is the safe direction; removing an entry re-enables sending to an address that\n // bounced or complained, and doing that in bulk is precisely what wrecks a sender's\n // reputation. Bulk import/export are out for the same reason — neither belongs in a\n // single tool call.\n}\n","import { McpServer } from '@modelcontextprotocol/server'\nimport { Eusend } from '@eusend_dev/sdk'\nimport type { McpConfig } from './config.js'\nimport { registerEmailTools } from './tools/emails.js'\nimport { registerDomainTools } from './tools/domains.js'\nimport { registerAudienceTools } from './tools/audiences.js'\nimport { registerTopicTools } from './tools/topics.js'\nimport { registerBroadcastTools } from './tools/broadcasts.js'\nimport { registerSuppressionTools } from './tools/suppressions.js'\n\nexport const SERVER_NAME = 'eusend'\nexport const SERVER_VERSION = '0.10.1'\n\n/**\n * Build a fully-wired MCP server for one Eusend account. This is\n * transport-agnostic: the stdio entry (index.ts) and the HTTP entry (http.ts)\n * both call this and then attach their own transport. All tool definitions live\n * in ./tools and are registered here exactly once.\n */\nexport function createServer(config: McpConfig): McpServer {\n const server = new McpServer({\n name: SERVER_NAME,\n title: 'eusend',\n version: SERVER_VERSION,\n description:\n 'EU-native email API. Send transactional email, add and verify sending domains, manage ' +\n 'audiences, contacts and topics, and draft, test and send broadcasts — all processed in the EU.',\n websiteUrl: 'https://eusend.dev/docs/mcp',\n icons: [\n { src: 'https://eusend.dev/brand/eusend-mark-blue.svg', mimeType: 'image/svg+xml' },\n { src: 'https://eusend.dev/apple-icon', mimeType: 'image/png', sizes: ['180x180'] },\n ],\n })\n\n const client = new Eusend(config.apiKey, { baseUrl: config.baseUrl })\n\n registerEmailTools(server, client, config)\n registerDomainTools(server, client)\n registerAudienceTools(server, client)\n registerTopicTools(server, client)\n registerBroadcastTools(server, client, config)\n registerSuppressionTools(server, client)\n\n return server\n}\n","import type { IncomingMessage } from 'node:http'\n\n/**\n * Minimal in-memory fixed-window IP rate limiter for the public /mcp endpoint.\n *\n * The endpoint is unauthenticated at the transport layer (initialize/tools/list\n * work before any API key is validated), so it needs its own basic DoS ceiling\n * independent of the API's rate limiting. In-memory on purpose: it keeps the box\n * free of any external dependency or credential. Per-container state is fine here\n * — the limit is a coarse abuse ceiling, not an accounting mechanism.\n */\nexport interface RateLimiter {\n /** Returns true if the request is allowed, false if it should be rejected (429). */\n check(req: IncomingMessage): boolean\n}\n\n// Hard cap on distinct tracked IPs so a high-cardinality flood can't grow the map\n// unbounded within a window. When exceeded, new IPs are denied until the next sweep\n// (fail closed under abuse) rather than consuming memory.\nconst MAX_BUCKETS = 50_000\n\n/**\n * Trusted client IP. Coolify's Traefik sits in front and OVERWRITES X-Real-Ip with the\n * real connection address, so it can't be spoofed by a client-sent header. We deliberately\n * do NOT trust X-Forwarded-For here: Traefik appends the real IP to any client-supplied\n * XFF, so its leftmost entry is attacker-controlled and would let a caller mint a fresh\n * bucket per request. Falls back to the socket address when there's no proxy (local runs).\n */\nfunction clientIp(req: IncomingMessage): string {\n const realIp = req.headers['x-real-ip']\n if (typeof realIp === 'string' && realIp.length > 0) {\n return realIp.trim()\n }\n return req.socket.remoteAddress ?? 'unknown'\n}\n\nexport function createRateLimiter(limit: number, windowMs: number): RateLimiter {\n const buckets = new Map<string, { count: number; resetAt: number }>()\n\n // Evict stale buckets so the map can't grow unbounded under a churn of IPs.\n const sweep = setInterval(() => {\n const now = Date.now()\n for (const [key, b] of buckets) {\n if (now > b.resetAt) buckets.delete(key)\n }\n }, windowMs)\n sweep.unref()\n\n return {\n check(req) {\n const key = clientIp(req)\n const now = Date.now()\n const bucket = buckets.get(key)\n if (!bucket || now > bucket.resetAt) {\n if (!bucket && buckets.size >= MAX_BUCKETS) {\n // Try to reclaim expired buckets before refusing.\n for (const [k, b] of buckets) if (now > b.resetAt) buckets.delete(k)\n if (buckets.size >= MAX_BUCKETS) return false\n }\n buckets.set(key, { count: 1, resetAt: now + windowMs })\n return true\n }\n bucket.count += 1\n return bucket.count <= limit\n },\n }\n}\n","import {\n createServer as createHttpServer,\n type IncomingMessage,\n type ServerResponse,\n} from 'node:http'\nimport { createMcpHandler, type AuthInfo } from '@modelcontextprotocol/server'\nimport { hostHeaderValidation, toNodeHandler } from '@modelcontextprotocol/node'\nimport { createRemoteJWKSet, jwtVerify } from 'jose'\nimport type { McpDefaults, McpOAuthConfig } from './config.js'\nimport { createServer } from './server.js'\nimport { createRateLimiter } from './ratelimit.js'\n\nexport interface RunHttpOptions {\n /** Account-agnostic defaults; the API key comes per-request from the caller. */\n defaults: McpDefaults\n port: number\n host: string\n /** Hostnames allowed in the Host header (DNS-rebinding protection). */\n allowedHosts: string[]\n /** Accept OAuth access tokens alongside API keys. Omit for API-key only. */\n oauth?: McpOAuthConfig\n}\n\nconst MCP_PATH = '/mcp'\n\n// RFC 9728: where a client that was just refused looks up which authorization server to\n// use. Served at the bare well-known path and at the one suffixed with the resource's own\n// path, because clients disagree on which to ask for.\nconst PROTECTED_RESOURCE_PATH = '/.well-known/oauth-protected-resource'\n\nconst OAUTH_SCOPES = ['offline_access', 'eusend:send', 'eusend:manage', 'eusend:live']\n\nfunction isApiKey(token: string): boolean {\n return token.startsWith('eu_live_') || token.startsWith('eu_test_')\n}\n\ninterface OAuthGuard {\n metadataPaths: string[]\n metadata: Record<string, unknown>\n /** The `WWW-Authenticate` value that sends a client off to authorize. */\n challenge: (error?: string) => string\n verify: (token: string) => Promise<boolean>\n}\n\nfunction createOAuthGuard(oauth: McpOAuthConfig): OAuthGuard {\n const resource = new URL(oauth.resource)\n const resourcePath = resource.pathname === '/' ? '' : resource.pathname\n const metadataUrl = `${resource.origin}${PROTECTED_RESOURCE_PATH}${resourcePath}`\n const jwks = createRemoteJWKSet(new URL(oauth.jwksUrl))\n\n return {\n metadataPaths: [PROTECTED_RESOURCE_PATH, `${PROTECTED_RESOURCE_PATH}${resourcePath}`],\n metadata: {\n resource: oauth.resource,\n authorization_servers: [oauth.issuer],\n scopes_supported: OAUTH_SCOPES,\n bearer_methods_supported: ['header'],\n },\n challenge: (error) =>\n `Bearer ${error ? `error=\"${error}\", ` : ''}resource_metadata=\"${metadataUrl}\"`,\n // Signature, expiry, issuer and audience only. Whether the grant behind the token still\n // stands is the API's call, made on every request the tools go on to make; the check\n // here exists so an expired token is answered with a 401 the client can act on by\n // refreshing, rather than surfacing later as a failed tool call.\n verify: async (token) => {\n try {\n await jwtVerify(token, jwks, { issuer: oauth.issuer, audience: oauth.resource })\n return true\n } catch {\n return false\n }\n },\n }\n}\n\n// Cap the request body before buffering it. node:http imposes no default limit, so without\n// this an unauthenticated caller (only a *present* bearer is required to reach readBody, not a\n// valid one) could stream an arbitrarily large body straight into memory. An MCP JSON-RPC\n// envelope is tiny, so 1 MB is generous. Mirrors the API tier's bodyLimit.\nconst MAX_BODY_BYTES = Number(process.env.MCP_MAX_BODY_BYTES ?? String(1024 * 1024))\n\n/** Thrown by readBody when the request body exceeds MAX_BODY_BYTES; mapped to 413. */\nclass BodyTooLargeError extends Error {}\n\n// Coarse per-IP DoS ceiling for the public endpoint. Each JSON-RPC call over an\n// MCP session is one request, so this is generous for a real agent while still\n// capping an anonymous flood. Tune via RATE_LIMIT_PER_MIN if needed.\nconst RATE_LIMIT_PER_MIN = Number(process.env.RATE_LIMIT_PER_MIN ?? '120')\nconst rateLimiter = createRateLimiter(RATE_LIMIT_PER_MIN, 60_000)\n\n/**\n * `toNodeHandler` reads the caller's identity off `req.auth` and hands it to the\n * factory as `authInfo`. `IncomingMessage` has no such field, so widen it here.\n */\ntype AuthenticatedRequest = IncomingMessage & { auth?: AuthInfo }\n\nfunction json(res: ServerResponse, status: number, body: unknown): void {\n res.writeHead(status, { 'Content-Type': 'application/json' })\n res.end(JSON.stringify(body))\n}\n\n/** Pull the API key out of `Authorization: Bearer <key>`. */\nfunction bearerKey(req: IncomingMessage): string | undefined {\n const header = req.headers.authorization\n if (!header) return undefined\n const [scheme, value] = header.split(' ')\n return scheme?.toLowerCase() === 'bearer' && value ? value : undefined\n}\n\n/**\n * Buffer the request body, refusing anything over MAX_BODY_BYTES.\n *\n * Deliberately event-based rather than `for await`: async iteration destroys the\n * stream when the loop exits early, which tears down the socket before the 413\n * can flush and leaves the caller with a connection reset instead of an answer.\n * Here we stop consuming and leave the socket up for `handle` to reply on.\n */\nfunction readBody(req: IncomingMessage): Promise<unknown> {\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = []\n let size = 0\n let settled = false\n\n req.on('data', (chunk: Buffer) => {\n if (settled) return\n size += chunk.length\n if (size > MAX_BODY_BYTES) {\n settled = true\n req.pause()\n reject(new BodyTooLargeError(`Request body exceeds the ${MAX_BODY_BYTES}-byte limit`))\n return\n }\n chunks.push(chunk)\n })\n\n req.on('end', () => {\n if (settled) return\n settled = true\n if (chunks.length === 0) return resolve(undefined)\n try {\n resolve(JSON.parse(Buffer.concat(chunks).toString('utf8')))\n } catch (err) {\n reject(err)\n }\n })\n\n req.on('error', (err) => {\n if (settled) return\n settled = true\n reject(err)\n })\n })\n}\n\n/**\n * Run the Eusend MCP server over Streamable HTTP — the hosted/remote transport.\n *\n * `createMcpHandler` serves both protocol eras from the one endpoint: 2026-07-28\n * traffic natively, and 2025-era traffic through its stateless legacy fallback\n * (the default). The factory runs once per request, so every request still gets a\n * fresh server bound to that caller's API key and one endpoint safely serves many\n * accounts. Mount this behind TLS at, e.g., https://mcp.eusend.dev/mcp.\n */\nexport async function runHttp(options: RunHttpOptions): Promise<void> {\n const handler = createMcpHandler(\n ({ authInfo }) => {\n if (!authInfo) {\n // Unreachable: handle() answers 401 before the handler is ever invoked.\n throw new Error('MCP request reached the server factory without an API key.')\n }\n return createServer({ apiKey: authInfo.token, ...options.defaults })\n },\n { onerror: (err) => console.error('MCP handler error:', err) },\n )\n\n const nodeHandler = toNodeHandler(handler, {\n onerror: (err) => console.error('MCP adapter error:', err),\n })\n const validateHost = hostHeaderValidation(options.allowedHosts)\n const oauth = options.oauth ? createOAuthGuard(options.oauth) : undefined\n\n const httpServer = createHttpServer((req, res) => {\n void handle(req, res, nodeHandler, validateHost, oauth)\n })\n\n await new Promise<void>((resolve) => {\n httpServer.listen(options.port, options.host, resolve)\n })\n console.error(\n `Eusend MCP server (HTTP) listening on http://${options.host}:${options.port}${MCP_PATH}`,\n )\n}\n\ntype NodeHandler = (\n req: IncomingMessage,\n res: ServerResponse,\n parsedBody?: unknown,\n) => Promise<void>\ntype HostGuard = (req: IncomingMessage, res: ServerResponse) => boolean\n\nasync function handle(\n req: IncomingMessage,\n res: ServerResponse,\n nodeHandler: NodeHandler,\n validateHost: HostGuard,\n oauth: OAuthGuard | undefined,\n): Promise<void> {\n const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`)\n\n if (url.pathname === '/health') {\n return json(res, 200, { status: 'ok' })\n }\n\n if (oauth?.metadataPaths.includes(url.pathname)) {\n // Public discovery document, fetched cross-origin by browser-based clients.\n res.writeHead(200, { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' })\n res.end(JSON.stringify(oauth.metadata))\n return\n }\n\n if (url.pathname !== MCP_PATH) {\n return json(res, 404, { error: 'Not found' })\n }\n\n // DNS-rebinding protection. The guard answers 403 itself when it rejects; the\n // 2025 session verbs GET and DELETE are answered 405 by the handler's stateless\n // legacy fallback, and the 2026 era has no server-push channel to open.\n if (!validateHost(req, res)) return\n\n if (!rateLimiter.check(req)) {\n return json(res, 429, {\n jsonrpc: '2.0',\n error: { code: -32029, message: 'Too many requests. Slow down.' },\n id: null,\n })\n }\n\n const apiKey = bearerKey(req)\n if (!apiKey) {\n // With OAuth on, this challenge is what starts a client's sign-in flow.\n if (oauth) res.setHeader('WWW-Authenticate', oauth.challenge())\n return json(res, 401, {\n jsonrpc: '2.0',\n error: {\n code: -32001,\n message: 'Missing or malformed Authorization: Bearer <api-key> header.',\n },\n id: null,\n })\n }\n\n if (oauth && !isApiKey(apiKey) && !(await oauth.verify(apiKey))) {\n res.setHeader('WWW-Authenticate', oauth.challenge('invalid_token'))\n return json(res, 401, {\n jsonrpc: '2.0',\n error: { code: -32001, message: 'Invalid or expired access token.' },\n id: null,\n })\n }\n\n // Carried to the factory from here — an API key or an OAuth access token, sent on to the\n // API as the same bearer credential either way. The API validates it on the first call\n // the constructed server makes.\n ;(req as AuthenticatedRequest).auth = { token: apiKey, clientId: 'eusend-api-key', scopes: [] }\n\n try {\n // Read the body here to keep the size cap, then pass it pre-parsed so the\n // adapter never re-reads the stream.\n const body = await readBody(req)\n await nodeHandler(req, res, body)\n } catch (err) {\n if (err instanceof BodyTooLargeError) {\n if (!res.headersSent) {\n // The caller is still uploading. Answer early, close the connection rather\n // than draining the rest, and only tear the socket down once the 413 has\n // actually flushed — destroying sooner is what turns this into a reset.\n res.writeHead(413, { 'Content-Type': 'application/json', Connection: 'close' })\n res.end(\n JSON.stringify({\n jsonrpc: '2.0',\n error: { code: -32600, message: 'Request body too large.' },\n id: null,\n }),\n () => req.destroy(),\n )\n }\n return\n }\n console.error('Error handling MCP request:', err)\n if (!res.headersSent) {\n json(res, 500, {\n jsonrpc: '2.0',\n error: { code: -32603, message: 'Internal server error' },\n id: null,\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,GAAG,MAA2B;CAC5C,MAAM,aAAc,MAAM,QAAQ,IAAI,IAAI,EAAE,KAAK,IAAK,QAAQ,CAAC;CAC/D,OAAO;EACL,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM,KAAK,UAA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ClC,SAAS,KAAK;EACZ,IAAI,eAAe,mBAAmB;GACpC,IAAI,CAAC,IAAI,aAAa;IAIpB,IAAI,UAAU,KAAK;KAAE,gBAAgB;KAAoB,YAAY;IAAQ,CAAC;IAC9E,IAAI,IACF,KAAK,UAAU;KACb,SAAS;KACT,OAAO;MAAE,MAAM;MAAQ,SAAS;KAA0B;KAC1D,IAAI;IACN,CAAC,SACK,IAAI,QAAQ,CACpB;GACF;GACA;EACF;EACA,QAAQ,MAAM,+BAA+B,GAAG;EAChD,IAAI,CAAC,IAAI,aACP,KAAK,KAAK,KAAK;GACb,SAAS;GACT,OAAO;IAAE,MAAM;IAAQ,SAAS;GAAwB;GACxD,IAAI;EACN,CAAC;CAEL;AACF"}
|
package/dist/http.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as runHttp } from "./http-
|
|
1
|
+
import { t as runHttp } from "./http-BJIfmzt4.mjs";
|
|
2
2
|
export { runHttp };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as createServer, t as runHttp } from "./http-
|
|
2
|
+
import { n as createServer, t as runHttp } from "./http-BJIfmzt4.mjs";
|
|
3
3
|
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
4
4
|
//#region src/config.ts
|
|
5
5
|
function readEnv(name) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eusend_dev/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"mcpName": "dev.eusend/eusend",
|
|
5
5
|
"description": "Model Context Protocol server for the Eusend API — send email and manage domains, audiences, and broadcasts from any MCP client.",
|
|
6
6
|
"author": "Eusend",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-Cco99z5y.mjs","names":["createServer","createServer","createHttpServer"],"sources":["../src/respond.ts","../src/tools/emails.ts","../src/tools/domains.ts","../src/tools/audiences.ts","../src/tools/topics.ts","../src/tools/broadcasts.ts","../src/tools/suppressions.ts","../src/server.ts","../src/ratelimit.ts","../src/http.ts"],"sourcesContent":["import type { CallToolResult } from '@modelcontextprotocol/server'\nimport type { EusendError, EusendResponse } from '@eusend_dev/sdk'\n\n/** MCP tool return shape. */\nexport type ToolResult = CallToolResult\n\n/** Wrap a successful payload as pretty-printed JSON text content. */\nexport function ok(data: unknown): ToolResult {\n return {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n }\n}\n\n/**\n * Surface an SDK error as an MCP tool error. `isError: true` tells the client\n * the call failed, and the error `name` (e.g. DOMAIN_NOT_VERIFIED) gives the\n * agent enough to self-correct — e.g. verify the domain, then retry.\n */\nexport function fail(error: EusendError): ToolResult {\n return {\n content: [{ type: 'text', text: `Error [${error.name}]: ${error.message}` }],\n isError: true,\n }\n}\n\n/** Plain text error for validation the tool does itself before hitting the API. */\nexport function failText(message: string): ToolResult {\n return { content: [{ type: 'text', text: message }], isError: true }\n}\n\n/** Turn any SDK `EusendResponse` into a tool result. */\nexport function respond<T>(res: EusendResponse<T>): ToolResult {\n return res.error ? fail(res.error) : ok(res.data)\n}\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport type { McpConfig } from '../config.js'\nimport { respond, failText } from '../respond.js'\n\nconst emailStatus = z.enum([\n 'queued',\n 'scheduled',\n 'canceled',\n 'sending',\n 'sent',\n 'delivered',\n 'bounced',\n 'complained',\n 'suppressed',\n 'failed',\n])\n\nconst recipients = z.union([z.string(), z.array(z.string())])\n\nexport function registerEmailTools(server: McpServer, client: Eusend, config: McpConfig): void {\n server.registerTool(\n 'send_email',\n {\n title: 'Send an email',\n description:\n 'Send a transactional email through Eusend. Provide `html` or `text` (or both). ' +\n 'The sender domain must be verified on the account — use list_domains to check. ' +\n 'If `from` is omitted, the server-configured default sender is used.',\n inputSchema: z.object({\n from: z\n .string()\n .optional()\n .describe('Sender, e.g. \"Acme <hi@acme.com>\". Defaults to the configured sender.'),\n to: recipients.describe('Recipient address or list of addresses.'),\n subject: z.string().describe('Email subject line.'),\n text: z.string().optional().describe('Plain-text body.'),\n html: z.string().optional().describe('HTML body. Takes precedence over text for display.'),\n cc: recipients.optional(),\n bcc: recipients.optional(),\n replyTo: recipients.optional().describe('Reply-To address(es).'),\n tags: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Labels for log filtering and webhook routing, e.g. {\"category\": \"password_reset\"}. ' +\n 'Names and values allow ASCII letters, numbers, underscores and dashes; max 10 tags.',\n ),\n scheduledAt: z\n .string()\n .optional()\n .describe(\n 'Future send time: ISO 8601 or natural language like \"in 1 hour\". Max 30 days out.',\n ),\n }),\n },\n async (args) => {\n const from = args.from ?? config.defaultFrom\n if (!from) {\n return failText(\n 'No sender specified and no default sender configured. Pass `from`, or set EUSEND_FROM / --from on the server.',\n )\n }\n if (!args.html && !args.text) {\n return failText('Provide at least one of `html` or `text`.')\n }\n return respond(\n await client.emails.send({\n from,\n to: args.to,\n subject: args.subject,\n text: args.text,\n html: args.html,\n cc: args.cc,\n bcc: args.bcc,\n replyTo: args.replyTo ?? config.defaultReplyTo,\n tags: args.tags,\n scheduledAt: args.scheduledAt,\n }),\n )\n },\n )\n\n server.registerTool(\n 'list_emails',\n {\n title: 'List emails',\n description:\n 'List recently sent emails, most recent first. Supports cursor pagination and filtering.',\n inputSchema: z.object({\n limit: z.number().int().min(1).max(100).optional().describe('Max results (1–100).'),\n cursor: z.string().optional().describe('Pagination cursor from a previous nextCursor.'),\n status: emailStatus.optional().describe('Filter by delivery status.'),\n from: z.string().optional().describe('Filter by sender address.'),\n to: z.string().optional().describe('Filter by recipient address.'),\n tag: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe(\n 'Filter by tag: \"category:password_reset\" for an exact pair, or bare \"category\" ' +\n 'for any email carrying the tag. An array requires all of them.',\n ),\n }),\n },\n async (args) => respond(await client.emails.list(args)),\n )\n\n server.registerTool(\n 'get_email',\n {\n title: 'Get an email',\n description: 'Fetch a single email by id, including its full delivery event history.',\n inputSchema: z.object({\n id: z.string().describe('The email id returned by send_email or list_emails.'),\n }),\n },\n async ({ id }) => respond(await client.emails.get(id)),\n )\n\n server.registerTool(\n 'cancel_email',\n {\n title: 'Cancel a scheduled email',\n description:\n 'Cancel a scheduled email before it sends. Fails once the email has started sending.',\n inputSchema: z.object({\n id: z.string().describe('The id of a scheduled email.'),\n }),\n },\n async ({ id }) => respond(await client.emails.cancel(id)),\n )\n}\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport { respond } from '../respond.js'\n\nexport function registerDomainTools(server: McpServer, client: Eusend): void {\n server.registerTool(\n 'list_domains',\n {\n title: 'List domains',\n description: 'List sending domains on the account and their verification status.',\n inputSchema: z.object({}),\n },\n async () => respond(await client.domains.list()),\n )\n\n server.registerTool(\n 'get_domain',\n {\n title: 'Get a domain',\n description:\n 'Fetch a single domain by id, including its DKIM selector and verification state.',\n inputSchema: z.object({\n id: z.string().describe('The domain id.'),\n }),\n },\n async ({ id }) => respond(await client.domains.get(id)),\n )\n\n server.registerTool(\n 'create_domain',\n {\n title: 'Add a sending domain',\n description:\n 'Register a new sending domain. Returns the DKIM, SPF, and DMARC DNS records that must be ' +\n \"added at the domain's DNS provider before it can send. Present these records to the user.\",\n inputSchema: z.object({\n name: z.string().describe('The domain to add, e.g. \"mail.acme.com\".'),\n }),\n },\n async ({ name }) => respond(await client.domains.create(name)),\n )\n\n server.registerTool(\n 'verify_domain',\n {\n title: 'Verify a sending domain',\n description:\n 'Re-check a domain\\'s DNS records now. Adding a domain already starts this automatically, ' +\n 'so use it when the records were published late or corrected — it starts a fresh check ' +\n 'rather than waiting for the next scheduled one. Poll get_domain for the result.',\n inputSchema: z.object({\n id: z.string().describe('The domain id.'),\n }),\n },\n async ({ id }) => respond(await client.domains.verify(id)),\n )\n}\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport { respond } from '../respond.js'\n\nexport function registerAudienceTools(server: McpServer, client: Eusend): void {\n server.registerTool(\n 'list_audiences',\n {\n title: 'List audiences',\n description:\n 'List contact audiences (lists) on the account, with per-audience contact counts.',\n inputSchema: z.object({}),\n },\n async () => respond(await client.audiences.list()),\n )\n\n server.registerTool(\n 'create_audience',\n {\n title: 'Create an audience',\n description: 'Create a new audience (contact list) to hold contacts for broadcasts.',\n inputSchema: z.object({\n name: z.string().describe('Human-readable name for the audience.'),\n }),\n },\n async ({ name }) => respond(await client.audiences.create(name)),\n )\n\n server.registerTool(\n 'get_audience',\n {\n title: 'Get an audience',\n description: 'Get one audience by id, with its contact count.',\n inputSchema: z.object({\n audienceId: z.string().describe('The audience to retrieve.'),\n }),\n },\n async ({ audienceId }) => respond(await client.audiences.get(audienceId)),\n )\n\n server.registerTool(\n 'rename_audience',\n {\n title: 'Rename an audience',\n description: 'Change the name of an audience. Its contacts and broadcasts are untouched.',\n inputSchema: z.object({\n audienceId: z.string().describe('The audience to rename.'),\n name: z.string().describe('The new name.'),\n }),\n },\n async ({ audienceId, name }) => respond(await client.audiences.update(audienceId, { name })),\n )\n\n server.registerTool(\n 'list_contacts',\n {\n title: 'List contacts',\n description: 'List contacts in an audience. Supports search and subscription filtering.',\n inputSchema: z.object({\n audienceId: z.string().describe('The audience to list contacts from.'),\n limit: z.number().int().min(1).max(100).optional(),\n cursor: z.string().optional().describe('Pagination cursor from a previous nextCursor.'),\n search: z.string().optional().describe('Filter by email or name substring.'),\n subscribed: z\n .boolean()\n .optional()\n .describe('true = only subscribed, false = only unsubscribed.'),\n }),\n },\n async ({ audienceId, ...opts }) =>\n respond(await client.audiences.listContacts(audienceId, opts)),\n )\n\n server.registerTool(\n 'create_contact',\n {\n title: 'Add a contact',\n description: 'Add a contact to an audience.',\n inputSchema: z.object({\n audienceId: z.string().describe('The audience to add the contact to.'),\n email: z.string().describe('Contact email address.'),\n firstName: z.string().optional(),\n lastName: z.string().optional(),\n properties: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Custom properties, usable as {{key}} in a broadcast body. Keys are lowercase letters, digits and underscores starting with a letter; values are strings. \"email\", \"name\", \"first_name\", \"last_name\" and \"full_name\" are built in and are rejected here.',\n ),\n }),\n },\n async ({ audienceId, email, firstName, lastName, properties }) =>\n respond(\n await client.audiences.createContact(audienceId, {\n email,\n firstName,\n lastName,\n properties,\n }),\n ),\n )\n\n server.registerTool(\n 'list_contact_properties',\n {\n title: 'List contact properties',\n description:\n \"List the organization's declared custom contact properties — the {{variables}} available in a broadcast body beyond the built-in email, name, first_name, last_name and full_name. Read this before writing broadcast copy that personalizes on a custom field.\",\n inputSchema: z.object({}),\n },\n async () => respond(await client.contactProperties.list()),\n )\n\n server.registerTool(\n 'create_contact_property',\n {\n title: 'Declare a contact property',\n description:\n 'Declare a custom contact property. Not required before setting one on a contact — an undeclared property registers itself as a string — but declaring it is what allows a type and a fallback value. The key and type cannot be changed afterwards.',\n inputSchema: z.object({\n key: z\n .string()\n .describe(\n 'Lowercase letters, digits and underscores, starting with a letter; at most 40 characters. \"email\", \"name\", \"first_name\", \"last_name\" and \"full_name\" are built in and are rejected here.',\n ),\n type: z\n .enum(['string', 'number'])\n .optional()\n .describe(\n 'Defaults to string. Values render as strings either way — \"number\" is a write-time check, not formatting.',\n ),\n fallbackValue: z\n .string()\n .optional()\n .describe(\n 'Substituted into {{key}} for contacts carrying no value of their own. Must match the type.',\n ),\n }),\n },\n async ({ key, type, fallbackValue }) =>\n respond(await client.contactProperties.create({ key, type, fallbackValue })),\n )\n}\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport { respond } from '../respond.js'\n\nexport function registerTopicTools(server: McpServer, client: Eusend): void {\n server.registerTool(\n 'list_topics',\n {\n title: 'List topics',\n description:\n 'List the subscription topics on the account — the kinds of email a contact can opt into or out of independently — with the number of contacts explicitly opted in to each. Read this before creating a broadcast, so it can be scoped to the people who asked for that kind of mail.',\n inputSchema: z.object({}),\n },\n async () => respond(await client.topics.list()),\n )\n\n server.registerTool(\n 'create_topic',\n {\n title: 'Create a topic',\n description:\n 'Create a subscription topic. Pass its id as topic_id when creating a broadcast to reach only the contacts subscribed to it. The default subscription is fixed at creation and cannot be changed afterwards, so confirm which one is wanted before calling this.',\n inputSchema: z.object({\n name: z\n .string()\n .describe(\n 'What the recipient reads on the unsubscribe page. At most 50 characters, and unique within the account.',\n ),\n defaultSubscription: z\n .enum(['opt_in', 'opt_out'])\n .describe(\n 'What a contact who has never expressed a preference receives. \"opt_in\" reaches everyone until they unsubscribe — right for a newsletter the list signed up for. \"opt_out\" reaches nobody until they explicitly join — right for anything a contact has to ask for, like a beta programme or a high-frequency digest. CANNOT be changed later.',\n ),\n description: z\n .string()\n .optional()\n .describe(\n 'Shown under the name on the unsubscribe page. At most 200 characters. Worth writing: it is what tells a recipient whether to keep the box ticked.',\n ),\n visibility: z\n .enum(['public', 'private'])\n .optional()\n .describe(\n 'Defaults to \"private\", which lists the topic on the unsubscribe page only to contacts already opted in. Use \"public\" only for a topic you are happy for anyone to discover — an internal campaign name shown to someone not on it invites them to opt out of something they were never getting.',\n ),\n }),\n },\n async ({ name, defaultSubscription, description, visibility }) =>\n respond(await client.topics.create({ name, defaultSubscription, description, visibility })),\n )\n\n // Deliberately absent, in line with the server's rule that destructive actions stay out\n // of the assistant's reach: `delete_topic` drops every stored preference for it, and\n // `update_topic` can flip a topic from private to public, which exposes an internal\n // campaign name to every recipient who opens an unsubscribe page. Neither is something\n // to do in a single tool call, and both are one click away in the dashboard.\n //\n // Changing a CONTACT's subscription is out for the same reason on the other side: it is\n // a consent record, and an assistant writing one in bulk is exactly the pattern that\n // makes a preference centre worthless.\n}\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport type { McpConfig } from '../config.js'\nimport { respond, failText } from '../respond.js'\n\nexport function registerBroadcastTools(server: McpServer, client: Eusend, config: McpConfig): void {\n server.registerTool(\n 'list_broadcasts',\n {\n title: 'List broadcasts',\n description: 'List broadcasts (bulk sends to an audience) with their status and send counts.',\n inputSchema: z.object({}),\n },\n async () => respond(await client.broadcasts.list()),\n )\n\n server.registerTool(\n 'get_broadcast',\n {\n title: 'Get a broadcast',\n description:\n 'Fetch a broadcast by id, including recipient/sent counts and current delivery-status stats.',\n inputSchema: z.object({\n id: z.string().describe('The broadcast id.'),\n }),\n },\n async ({ id }) => respond(await client.broadcasts.get(id)),\n )\n\n server.registerTool(\n 'create_broadcast',\n {\n title: 'Create a broadcast (draft)',\n description:\n 'Create a broadcast in draft state, targeting an audience. Does NOT send it — use send_broadcast ' +\n 'to send or schedule after reviewing. If `from` is omitted the configured default sender is used.',\n inputSchema: z.object({\n name: z.string().describe('Internal name for the broadcast.'),\n audienceId: z.string().describe('The audience to send to.'),\n topicId: z\n .string()\n .optional()\n .describe(\n 'Narrows the audience to the contacts subscribed to this topic. Omit to send to the whole audience. Call list_topics first when the message is one kind of mail among several — sending a product announcement to everyone is what drives unsubscribes.',\n ),\n subject: z.string().describe('Email subject line.'),\n from: z.string().optional().describe('Sender. Defaults to the configured sender.'),\n html: z.string().optional().describe('HTML body of the broadcast.'),\n }),\n },\n async (args) => {\n const from = args.from ?? config.defaultFrom\n if (!from) {\n return failText(\n 'No sender specified and no default sender configured. Pass `from`, or set EUSEND_FROM / --from on the server.',\n )\n }\n return respond(\n await client.broadcasts.create({\n name: args.name,\n audienceId: args.audienceId,\n topicId: args.topicId,\n subject: args.subject,\n from,\n html: args.html,\n }),\n )\n },\n )\n\n server.registerTool(\n 'send_broadcast',\n {\n title: 'Send or schedule a broadcast',\n description:\n 'Send a draft broadcast to its entire audience now, or schedule it for later. This is a bulk send — ' +\n 'confirm with the user before calling. Omit `scheduledAt` to send immediately.',\n inputSchema: z.object({\n id: z.string().describe('The draft broadcast id.'),\n scheduledAt: z\n .string()\n .optional()\n .describe('Optional future send time (ISO 8601). Omit to send immediately.'),\n }),\n },\n async ({ id, scheduledAt }) => respond(await client.broadcasts.send(id, { scheduledAt })),\n )\n\n server.registerTool(\n 'test_broadcast',\n {\n title: 'Send a test copy of a broadcast',\n description:\n 'Send the broadcast to your own verified addresses to check how it renders, without mailing the ' +\n 'audience. Prefer this before send_broadcast — it is reversible in the sense that nobody on the ' +\n 'list receives anything, and it leaves the broadcast a draft. Recipients must be on a domain ' +\n 'verified on the account; anything else is refused. Works on the free plan, unlike send_broadcast.',\n inputSchema: z.object({\n id: z.string().describe('The broadcast id.'),\n to: z\n .array(z.string())\n .min(1)\n .max(5)\n .describe('1-5 addresses, each on a domain verified on this account.'),\n }),\n },\n async ({ id, to }) => respond(await client.broadcasts.test(id, { to })),\n )\n}\n","import type { McpServer } from '@modelcontextprotocol/server'\nimport type { Eusend } from '@eusend_dev/sdk'\nimport { z } from 'zod'\nimport { respond } from '../respond.js'\n\nconst reason = z.enum(['bounce', 'complaint', 'manual'])\n\nexport function registerSuppressionTools(server: McpServer, client: Eusend): void {\n server.registerTool(\n 'list_suppressions',\n {\n title: 'List suppressed addresses',\n description:\n 'List addresses the account will not send to. Hard bounces and spam complaints are suppressed automatically. Use this to explain why an email came back with status \"suppressed\" or an ALL_SUPPRESSED error.',\n inputSchema: z.object({\n email: z\n .string()\n .optional()\n .describe(\n 'Match addresses containing this substring. Pass a domain (\"@acme.com\") to see every suppressed address there.',\n ),\n reason: reason.optional().describe('Filter by why the address was suppressed.'),\n limit: z.number().int().min(1).max(100).optional(),\n cursor: z.string().optional().describe('Pagination cursor from a previous next_cursor.'),\n }),\n },\n async (opts) => respond(await client.suppressions.list(opts)),\n )\n\n server.registerTool(\n 'create_suppression',\n {\n title: 'Suppress an address',\n description:\n 'Stop sending to an address. If it is already suppressed the existing entry is returned unchanged — this never overwrites the reason an address was suppressed for.',\n inputSchema: z.object({\n email: z.string().describe('The address to suppress.'),\n reason: reason.optional().describe('Defaults to \"manual\".'),\n }),\n },\n async ({ email, reason: why }) =>\n respond(await client.suppressions.create({ email, reason: why })),\n )\n\n // Un-suppressing is deliberately absent, in line with the server's rule that\n // destructive actions stay out of the assistant's reach. Suppressing stops mail, which\n // is the safe direction; removing an entry re-enables sending to an address that\n // bounced or complained, and doing that in bulk is precisely what wrecks a sender's\n // reputation. Bulk import/export are out for the same reason — neither belongs in a\n // single tool call.\n}\n","import { McpServer } from '@modelcontextprotocol/server'\nimport { Eusend } from '@eusend_dev/sdk'\nimport type { McpConfig } from './config.js'\nimport { registerEmailTools } from './tools/emails.js'\nimport { registerDomainTools } from './tools/domains.js'\nimport { registerAudienceTools } from './tools/audiences.js'\nimport { registerTopicTools } from './tools/topics.js'\nimport { registerBroadcastTools } from './tools/broadcasts.js'\nimport { registerSuppressionTools } from './tools/suppressions.js'\n\nexport const SERVER_NAME = 'eusend'\nexport const SERVER_VERSION = '0.9.0'\n\n/**\n * Build a fully-wired MCP server for one Eusend account. This is\n * transport-agnostic: the stdio entry (index.ts) and the HTTP entry (http.ts)\n * both call this and then attach their own transport. All tool definitions live\n * in ./tools and are registered here exactly once.\n */\nexport function createServer(config: McpConfig): McpServer {\n const server = new McpServer({\n name: SERVER_NAME,\n version: SERVER_VERSION,\n })\n\n const client = new Eusend(config.apiKey, { baseUrl: config.baseUrl })\n\n registerEmailTools(server, client, config)\n registerDomainTools(server, client)\n registerAudienceTools(server, client)\n registerTopicTools(server, client)\n registerBroadcastTools(server, client, config)\n registerSuppressionTools(server, client)\n\n return server\n}\n","import type { IncomingMessage } from 'node:http'\n\n/**\n * Minimal in-memory fixed-window IP rate limiter for the public /mcp endpoint.\n *\n * The endpoint is unauthenticated at the transport layer (initialize/tools/list\n * work before any API key is validated), so it needs its own basic DoS ceiling\n * independent of the API's rate limiting. In-memory on purpose: it keeps the box\n * free of any external dependency or credential. Per-container state is fine here\n * — the limit is a coarse abuse ceiling, not an accounting mechanism.\n */\nexport interface RateLimiter {\n /** Returns true if the request is allowed, false if it should be rejected (429). */\n check(req: IncomingMessage): boolean\n}\n\n// Hard cap on distinct tracked IPs so a high-cardinality flood can't grow the map\n// unbounded within a window. When exceeded, new IPs are denied until the next sweep\n// (fail closed under abuse) rather than consuming memory.\nconst MAX_BUCKETS = 50_000\n\n/**\n * Trusted client IP. Coolify's Traefik sits in front and OVERWRITES X-Real-Ip with the\n * real connection address, so it can't be spoofed by a client-sent header. We deliberately\n * do NOT trust X-Forwarded-For here: Traefik appends the real IP to any client-supplied\n * XFF, so its leftmost entry is attacker-controlled and would let a caller mint a fresh\n * bucket per request. Falls back to the socket address when there's no proxy (local runs).\n */\nfunction clientIp(req: IncomingMessage): string {\n const realIp = req.headers['x-real-ip']\n if (typeof realIp === 'string' && realIp.length > 0) {\n return realIp.trim()\n }\n return req.socket.remoteAddress ?? 'unknown'\n}\n\nexport function createRateLimiter(limit: number, windowMs: number): RateLimiter {\n const buckets = new Map<string, { count: number; resetAt: number }>()\n\n // Evict stale buckets so the map can't grow unbounded under a churn of IPs.\n const sweep = setInterval(() => {\n const now = Date.now()\n for (const [key, b] of buckets) {\n if (now > b.resetAt) buckets.delete(key)\n }\n }, windowMs)\n sweep.unref()\n\n return {\n check(req) {\n const key = clientIp(req)\n const now = Date.now()\n const bucket = buckets.get(key)\n if (!bucket || now > bucket.resetAt) {\n if (!bucket && buckets.size >= MAX_BUCKETS) {\n // Try to reclaim expired buckets before refusing.\n for (const [k, b] of buckets) if (now > b.resetAt) buckets.delete(k)\n if (buckets.size >= MAX_BUCKETS) return false\n }\n buckets.set(key, { count: 1, resetAt: now + windowMs })\n return true\n }\n bucket.count += 1\n return bucket.count <= limit\n },\n }\n}\n","import {\n createServer as createHttpServer,\n type IncomingMessage,\n type ServerResponse,\n} from 'node:http'\nimport { createMcpHandler, type AuthInfo } from '@modelcontextprotocol/server'\nimport { hostHeaderValidation, toNodeHandler } from '@modelcontextprotocol/node'\nimport { createRemoteJWKSet, jwtVerify } from 'jose'\nimport type { McpDefaults, McpOAuthConfig } from './config.js'\nimport { createServer } from './server.js'\nimport { createRateLimiter } from './ratelimit.js'\n\nexport interface RunHttpOptions {\n /** Account-agnostic defaults; the API key comes per-request from the caller. */\n defaults: McpDefaults\n port: number\n host: string\n /** Hostnames allowed in the Host header (DNS-rebinding protection). */\n allowedHosts: string[]\n /** Accept OAuth access tokens alongside API keys. Omit for API-key only. */\n oauth?: McpOAuthConfig\n}\n\nconst MCP_PATH = '/mcp'\n\n// RFC 9728: where a client that was just refused looks up which authorization server to\n// use. Served at the bare well-known path and at the one suffixed with the resource's own\n// path, because clients disagree on which to ask for.\nconst PROTECTED_RESOURCE_PATH = '/.well-known/oauth-protected-resource'\n\nconst OAUTH_SCOPES = ['offline_access', 'eusend:send', 'eusend:manage', 'eusend:live']\n\nfunction isApiKey(token: string): boolean {\n return token.startsWith('eu_live_') || token.startsWith('eu_test_')\n}\n\ninterface OAuthGuard {\n metadataPaths: string[]\n metadata: Record<string, unknown>\n /** The `WWW-Authenticate` value that sends a client off to authorize. */\n challenge: (error?: string) => string\n verify: (token: string) => Promise<boolean>\n}\n\nfunction createOAuthGuard(oauth: McpOAuthConfig): OAuthGuard {\n const resource = new URL(oauth.resource)\n const resourcePath = resource.pathname === '/' ? '' : resource.pathname\n const metadataUrl = `${resource.origin}${PROTECTED_RESOURCE_PATH}${resourcePath}`\n const jwks = createRemoteJWKSet(new URL(oauth.jwksUrl))\n\n return {\n metadataPaths: [PROTECTED_RESOURCE_PATH, `${PROTECTED_RESOURCE_PATH}${resourcePath}`],\n metadata: {\n resource: oauth.resource,\n authorization_servers: [oauth.issuer],\n scopes_supported: OAUTH_SCOPES,\n bearer_methods_supported: ['header'],\n },\n challenge: (error) =>\n `Bearer ${error ? `error=\"${error}\", ` : ''}resource_metadata=\"${metadataUrl}\"`,\n // Signature, expiry, issuer and audience only. Whether the grant behind the token still\n // stands is the API's call, made on every request the tools go on to make; the check\n // here exists so an expired token is answered with a 401 the client can act on by\n // refreshing, rather than surfacing later as a failed tool call.\n verify: async (token) => {\n try {\n await jwtVerify(token, jwks, { issuer: oauth.issuer, audience: oauth.resource })\n return true\n } catch {\n return false\n }\n },\n }\n}\n\n// Cap the request body before buffering it. node:http imposes no default limit, so without\n// this an unauthenticated caller (only a *present* bearer is required to reach readBody, not a\n// valid one) could stream an arbitrarily large body straight into memory. An MCP JSON-RPC\n// envelope is tiny, so 1 MB is generous. Mirrors the API tier's bodyLimit.\nconst MAX_BODY_BYTES = Number(process.env.MCP_MAX_BODY_BYTES ?? String(1024 * 1024))\n\n/** Thrown by readBody when the request body exceeds MAX_BODY_BYTES; mapped to 413. */\nclass BodyTooLargeError extends Error {}\n\n// Coarse per-IP DoS ceiling for the public endpoint. Each JSON-RPC call over an\n// MCP session is one request, so this is generous for a real agent while still\n// capping an anonymous flood. Tune via RATE_LIMIT_PER_MIN if needed.\nconst RATE_LIMIT_PER_MIN = Number(process.env.RATE_LIMIT_PER_MIN ?? '120')\nconst rateLimiter = createRateLimiter(RATE_LIMIT_PER_MIN, 60_000)\n\n/**\n * `toNodeHandler` reads the caller's identity off `req.auth` and hands it to the\n * factory as `authInfo`. `IncomingMessage` has no such field, so widen it here.\n */\ntype AuthenticatedRequest = IncomingMessage & { auth?: AuthInfo }\n\nfunction json(res: ServerResponse, status: number, body: unknown): void {\n res.writeHead(status, { 'Content-Type': 'application/json' })\n res.end(JSON.stringify(body))\n}\n\n/** Pull the API key out of `Authorization: Bearer <key>`. */\nfunction bearerKey(req: IncomingMessage): string | undefined {\n const header = req.headers.authorization\n if (!header) return undefined\n const [scheme, value] = header.split(' ')\n return scheme?.toLowerCase() === 'bearer' && value ? value : undefined\n}\n\n/**\n * Buffer the request body, refusing anything over MAX_BODY_BYTES.\n *\n * Deliberately event-based rather than `for await`: async iteration destroys the\n * stream when the loop exits early, which tears down the socket before the 413\n * can flush and leaves the caller with a connection reset instead of an answer.\n * Here we stop consuming and leave the socket up for `handle` to reply on.\n */\nfunction readBody(req: IncomingMessage): Promise<unknown> {\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = []\n let size = 0\n let settled = false\n\n req.on('data', (chunk: Buffer) => {\n if (settled) return\n size += chunk.length\n if (size > MAX_BODY_BYTES) {\n settled = true\n req.pause()\n reject(new BodyTooLargeError(`Request body exceeds the ${MAX_BODY_BYTES}-byte limit`))\n return\n }\n chunks.push(chunk)\n })\n\n req.on('end', () => {\n if (settled) return\n settled = true\n if (chunks.length === 0) return resolve(undefined)\n try {\n resolve(JSON.parse(Buffer.concat(chunks).toString('utf8')))\n } catch (err) {\n reject(err)\n }\n })\n\n req.on('error', (err) => {\n if (settled) return\n settled = true\n reject(err)\n })\n })\n}\n\n/**\n * Run the Eusend MCP server over Streamable HTTP — the hosted/remote transport.\n *\n * `createMcpHandler` serves both protocol eras from the one endpoint: 2026-07-28\n * traffic natively, and 2025-era traffic through its stateless legacy fallback\n * (the default). The factory runs once per request, so every request still gets a\n * fresh server bound to that caller's API key and one endpoint safely serves many\n * accounts. Mount this behind TLS at, e.g., https://mcp.eusend.dev/mcp.\n */\nexport async function runHttp(options: RunHttpOptions): Promise<void> {\n const handler = createMcpHandler(\n ({ authInfo }) => {\n if (!authInfo) {\n // Unreachable: handle() answers 401 before the handler is ever invoked.\n throw new Error('MCP request reached the server factory without an API key.')\n }\n return createServer({ apiKey: authInfo.token, ...options.defaults })\n },\n { onerror: (err) => console.error('MCP handler error:', err) },\n )\n\n const nodeHandler = toNodeHandler(handler, {\n onerror: (err) => console.error('MCP adapter error:', err),\n })\n const validateHost = hostHeaderValidation(options.allowedHosts)\n const oauth = options.oauth ? createOAuthGuard(options.oauth) : undefined\n\n const httpServer = createHttpServer((req, res) => {\n void handle(req, res, nodeHandler, validateHost, oauth)\n })\n\n await new Promise<void>((resolve) => {\n httpServer.listen(options.port, options.host, resolve)\n })\n console.error(\n `Eusend MCP server (HTTP) listening on http://${options.host}:${options.port}${MCP_PATH}`,\n )\n}\n\ntype NodeHandler = (\n req: IncomingMessage,\n res: ServerResponse,\n parsedBody?: unknown,\n) => Promise<void>\ntype HostGuard = (req: IncomingMessage, res: ServerResponse) => boolean\n\nasync function handle(\n req: IncomingMessage,\n res: ServerResponse,\n nodeHandler: NodeHandler,\n validateHost: HostGuard,\n oauth: OAuthGuard | undefined,\n): Promise<void> {\n const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`)\n\n if (url.pathname === '/health') {\n return json(res, 200, { status: 'ok' })\n }\n\n if (oauth?.metadataPaths.includes(url.pathname)) {\n // Public discovery document, fetched cross-origin by browser-based clients.\n res.writeHead(200, { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' })\n res.end(JSON.stringify(oauth.metadata))\n return\n }\n\n if (url.pathname !== MCP_PATH) {\n return json(res, 404, { error: 'Not found' })\n }\n\n // DNS-rebinding protection. The guard answers 403 itself when it rejects; the\n // 2025 session verbs GET and DELETE are answered 405 by the handler's stateless\n // legacy fallback, and the 2026 era has no server-push channel to open.\n if (!validateHost(req, res)) return\n\n if (!rateLimiter.check(req)) {\n return json(res, 429, {\n jsonrpc: '2.0',\n error: { code: -32029, message: 'Too many requests. Slow down.' },\n id: null,\n })\n }\n\n const apiKey = bearerKey(req)\n if (!apiKey) {\n // With OAuth on, this challenge is what starts a client's sign-in flow.\n if (oauth) res.setHeader('WWW-Authenticate', oauth.challenge())\n return json(res, 401, {\n jsonrpc: '2.0',\n error: {\n code: -32001,\n message: 'Missing or malformed Authorization: Bearer <api-key> header.',\n },\n id: null,\n })\n }\n\n if (oauth && !isApiKey(apiKey) && !(await oauth.verify(apiKey))) {\n res.setHeader('WWW-Authenticate', oauth.challenge('invalid_token'))\n return json(res, 401, {\n jsonrpc: '2.0',\n error: { code: -32001, message: 'Invalid or expired access token.' },\n id: null,\n })\n }\n\n // Carried to the factory from here — an API key or an OAuth access token, sent on to the\n // API as the same bearer credential either way. The API validates it on the first call\n // the constructed server makes.\n ;(req as AuthenticatedRequest).auth = { token: apiKey, clientId: 'eusend-api-key', scopes: [] }\n\n try {\n // Read the body here to keep the size cap, then pass it pre-parsed so the\n // adapter never re-reads the stream.\n const body = await readBody(req)\n await nodeHandler(req, res, body)\n } catch (err) {\n if (err instanceof BodyTooLargeError) {\n if (!res.headersSent) {\n // The caller is still uploading. Answer early, close the connection rather\n // than draining the rest, and only tear the socket down once the 413 has\n // actually flushed — destroying sooner is what turns this into a reset.\n res.writeHead(413, { 'Content-Type': 'application/json', Connection: 'close' })\n res.end(\n JSON.stringify({\n jsonrpc: '2.0',\n error: { code: -32600, message: 'Request body too large.' },\n id: null,\n }),\n () => req.destroy(),\n )\n }\n return\n }\n console.error('Error handling MCP request:', err)\n if (!res.headersSent) {\n json(res, 500, {\n jsonrpc: '2.0',\n error: { code: -32603, message: 'Internal server error' },\n id: null,\n })\n }\n }\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,GAAG,MAA2B;CAC5C,OAAO,EACL,SAAS,CAAC;EAAE,MAAM;EAAQ,MAAM,KAAK,UAAU,MAAM,MAAM,CAAC;CAAE,CAAC,EACjE;AACF;;;;;;AAOA,SAAgB,KAAK,OAAgC;CACnD,OAAO;EACL,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM,UAAU,MAAM,KAAK,KAAK,MAAM;EAAU,CAAC;EAC3E,SAAS;CACX;AACF;;AAGA,SAAgB,SAAS,SAA6B;CACpD,OAAO;EAAE,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM;EAAQ,CAAC;EAAG,SAAS;CAAK;AACrE;;AAGA,SAAgB,QAAW,KAAoC;CAC7D,OAAO,IAAI,QAAQ,KAAK,IAAI,KAAK,IAAI,GAAG,IAAI,IAAI;AAClD;;;AC3BA,MAAM,cAAc,EAAE,KAAK;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,aAAa,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,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