@kbzowski/mcp-inbox 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist/cache/db.d.ts +11 -0
- package/dist/cache/queries.d.ts +10 -0
- package/dist/imap/search.d.ts +28 -14
- package/dist/index.js +418 -99
- package/dist/index.js.map +4 -4
- package/dist/tools/emails/delete-multiple.d.ts +6 -0
- package/dist/tools/emails/mark-read-multiple.d.ts +9 -0
- package/dist/tools/emails/move-multiple.d.ts +6 -0
- package/dist/tools/emails/search-emails.d.ts +5 -0
- package/package.json +10 -9
package/dist/index.js
CHANGED
|
@@ -256,17 +256,17 @@ var DEFAULT_MIGRATIONS_FOLDER = fileURLToPath(new URL("./migrations", import.met
|
|
|
256
256
|
var log = createLogger("mcp-inbox:cache");
|
|
257
257
|
function openCache(path, migrationsFolder) {
|
|
258
258
|
if (path !== ":memory:") {
|
|
259
|
-
|
|
259
|
+
try {
|
|
260
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
261
|
+
} catch (err) {
|
|
262
|
+
throw new CacheError("CACHE_IO_FAILED", diagnoseOpenError(path, err), err);
|
|
263
|
+
}
|
|
260
264
|
}
|
|
261
265
|
let sqlite;
|
|
262
266
|
try {
|
|
263
267
|
sqlite = new Database(path);
|
|
264
268
|
} catch (err) {
|
|
265
|
-
throw new CacheError(
|
|
266
|
-
"CACHE_IO_FAILED",
|
|
267
|
-
`Could not open cache database at ${path}. Check IMAP_CACHE_DIR permissions.`,
|
|
268
|
-
err
|
|
269
|
-
);
|
|
269
|
+
throw new CacheError("CACHE_IO_FAILED", diagnoseOpenError(path, err), err);
|
|
270
270
|
}
|
|
271
271
|
sqlite.pragma("journal_mode = WAL");
|
|
272
272
|
sqlite.pragma("foreign_keys = ON");
|
|
@@ -298,6 +298,25 @@ function openCache(path, migrationsFolder) {
|
|
|
298
298
|
}
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
|
+
function diagnoseOpenError(path, err) {
|
|
302
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
303
|
+
const code = err && typeof err === "object" && "code" in err ? String(err.code) : void 0;
|
|
304
|
+
let hint;
|
|
305
|
+
if (/cannot find module|invalid elf|was compiled against|node_modules[\\/]better-sqlite3/i.test(msg)) {
|
|
306
|
+
hint = "The better-sqlite3 native binding failed to load. Try:\n npm rebuild better-sqlite3\nor reinstall: npm install -g @kbzowski/mcp-inbox --force";
|
|
307
|
+
} else if (code === "EACCES" || code === "EPERM" || /permission denied|operation not permitted/i.test(msg)) {
|
|
308
|
+
hint = "Permission denied. Check that IMAP_CACHE_DIR is writable by the current user.";
|
|
309
|
+
} else if (code === "EBUSY" || /database is locked|SQLITE_BUSY|locked/i.test(msg)) {
|
|
310
|
+
hint = "The cache file is locked, probably by another mcp-inbox instance (Claude Desktop + Claude Code both launching the server, for example). Close the other client or point this one at a different IMAP_CACHE_DIR.";
|
|
311
|
+
} else if (code === "ENOENT") {
|
|
312
|
+
hint = "Path not found. IMAP_CACHE_DIR or one of its parents may not exist and could not be created.";
|
|
313
|
+
} else if (/disk i\/o|disk full|ENOSPC/i.test(msg) || code === "ENOSPC") {
|
|
314
|
+
hint = "Disk I/O error (out of space, or the volume was disconnected).";
|
|
315
|
+
} else {
|
|
316
|
+
hint = `Underlying error: ${msg}`;
|
|
317
|
+
}
|
|
318
|
+
return `Could not open cache database at ${path}. ${hint}`;
|
|
319
|
+
}
|
|
301
320
|
|
|
302
321
|
// src/imap/client.ts
|
|
303
322
|
import { ImapFlow } from "imapflow";
|
|
@@ -545,12 +564,33 @@ function countEmailsInFolder(db, folder) {
|
|
|
545
564
|
function setEmailFlags(db, folder, uid, flags) {
|
|
546
565
|
db.update(emails).set({ flags }).where(and(eq(emails.folder, folder), eq(emails.uid, uid))).run();
|
|
547
566
|
}
|
|
567
|
+
function mutateEmailFlagsForUids(db, folder, uids, mutate) {
|
|
568
|
+
if (uids.length === 0) return;
|
|
569
|
+
db.transaction((tx) => {
|
|
570
|
+
const rows = tx.select({ uid: emails.uid, flags: emails.flags }).from(emails).where(and(eq(emails.folder, folder), inArray(emails.uid, uids))).all();
|
|
571
|
+
for (const row of rows) {
|
|
572
|
+
const next = mutate(row.flags);
|
|
573
|
+
if (flagsEqual(row.flags, next)) continue;
|
|
574
|
+
tx.update(emails).set({ flags: next }).where(and(eq(emails.folder, folder), eq(emails.uid, row.uid))).run();
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
function flagsEqual(a, b) {
|
|
579
|
+
if (a.length !== b.length) return false;
|
|
580
|
+
const setB = new Set(b);
|
|
581
|
+
for (const f of a) if (!setB.has(f)) return false;
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
548
584
|
function deleteEmailsByFolder(db, folder) {
|
|
549
585
|
db.delete(emails).where(eq(emails.folder, folder)).run();
|
|
550
586
|
}
|
|
551
587
|
function deleteEmail(db, folder, uid) {
|
|
552
588
|
db.delete(emails).where(and(eq(emails.folder, folder), eq(emails.uid, uid))).run();
|
|
553
589
|
}
|
|
590
|
+
function deleteEmailsByUids(db, folder, uids) {
|
|
591
|
+
if (uids.length === 0) return;
|
|
592
|
+
db.delete(emails).where(and(eq(emails.folder, folder), inArray(emails.uid, uids))).run();
|
|
593
|
+
}
|
|
554
594
|
function getEmailBody(db, folder, uid) {
|
|
555
595
|
const row = db.select({
|
|
556
596
|
bodyText: emails.bodyText,
|
|
@@ -845,7 +885,7 @@ import {
|
|
|
845
885
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
846
886
|
|
|
847
887
|
// src/tools/registry.ts
|
|
848
|
-
import { z as
|
|
888
|
+
import { z as z21 } from "zod";
|
|
849
889
|
|
|
850
890
|
// src/tools/folders/list-folders.ts
|
|
851
891
|
import { z as z2 } from "zod";
|
|
@@ -1208,6 +1248,10 @@ function buildImapSearch(c) {
|
|
|
1208
1248
|
if (c.since) q.since = c.since;
|
|
1209
1249
|
if (c.before) q.before = c.before;
|
|
1210
1250
|
if (c.unseen === true) q.seen = false;
|
|
1251
|
+
if (c.larger_than_bytes !== void 0) q.larger = c.larger_than_bytes;
|
|
1252
|
+
if (c.smaller_than_bytes !== void 0) q.smaller = c.smaller_than_bytes;
|
|
1253
|
+
if (c.or !== void 0 && c.or.length > 0) q.or = c.or.map(buildImapSearch);
|
|
1254
|
+
if (c.not !== void 0) q.not = buildImapSearch(c.not);
|
|
1211
1255
|
if (Object.keys(q).length === 0) {
|
|
1212
1256
|
q.all = true;
|
|
1213
1257
|
}
|
|
@@ -1215,6 +1259,21 @@ function buildImapSearch(c) {
|
|
|
1215
1259
|
}
|
|
1216
1260
|
|
|
1217
1261
|
// src/tools/emails/search-emails.ts
|
|
1262
|
+
var Criteria = z5.lazy(
|
|
1263
|
+
() => z5.object({
|
|
1264
|
+
subject: z5.string().min(1).optional(),
|
|
1265
|
+
from: z5.string().min(1).optional(),
|
|
1266
|
+
to: z5.string().min(1).optional(),
|
|
1267
|
+
body: z5.string().min(1).optional(),
|
|
1268
|
+
unseen: z5.boolean().optional(),
|
|
1269
|
+
since: z5.coerce.date().optional(),
|
|
1270
|
+
before: z5.coerce.date().optional(),
|
|
1271
|
+
larger_than_bytes: z5.number().int().positive().optional(),
|
|
1272
|
+
smaller_than_bytes: z5.number().int().positive().optional(),
|
|
1273
|
+
or: z5.array(Criteria).min(2).optional(),
|
|
1274
|
+
not: Criteria.optional()
|
|
1275
|
+
})
|
|
1276
|
+
);
|
|
1218
1277
|
var Input4 = z5.object({
|
|
1219
1278
|
folder: z5.string().min(1).default("INBOX"),
|
|
1220
1279
|
subject: z5.string().min(1).optional(),
|
|
@@ -1224,16 +1283,24 @@ var Input4 = z5.object({
|
|
|
1224
1283
|
unseen: z5.boolean().optional(),
|
|
1225
1284
|
since_date: z5.string().date().optional(),
|
|
1226
1285
|
before_date: z5.string().date().optional(),
|
|
1286
|
+
larger_than_bytes: z5.number().int().positive().optional().describe("Only match messages larger than this many bytes."),
|
|
1287
|
+
smaller_than_bytes: z5.number().int().positive().optional().describe("Only match messages smaller than this many bytes."),
|
|
1288
|
+
or: z5.array(Criteria).min(2).optional().describe(
|
|
1289
|
+
'Array of >=2 sub-criteria; at least one must match. Combines as AND with top-level fields: `{subject: "X", or: [{from: "a"}, {from: "b"}]}` means `subject=X AND (from=a OR from=b)`.'
|
|
1290
|
+
),
|
|
1291
|
+
not: Criteria.optional().describe(
|
|
1292
|
+
'Sub-criteria that must NOT match. Useful for excluding auto-generated mail, e.g. `{not: {from: "noreply"}}`.'
|
|
1293
|
+
),
|
|
1227
1294
|
limit: z5.number().int().min(1).max(100).default(20),
|
|
1228
1295
|
max_staleness_seconds: z5.number().int().min(0).default(60),
|
|
1229
1296
|
response_format: z5.enum(["markdown", "json"]).default("markdown")
|
|
1230
1297
|
}).refine(
|
|
1231
|
-
(v) => v.subject ?? v.from ?? v.to ?? v.body ?? v.unseen ?? v.since_date ?? v.before_date,
|
|
1298
|
+
(v) => v.subject ?? v.from ?? v.to ?? v.body ?? v.unseen ?? v.since_date ?? v.before_date ?? v.larger_than_bytes ?? v.smaller_than_bytes ?? v.or ?? v.not,
|
|
1232
1299
|
{ message: "At least one search criterion must be provided." }
|
|
1233
1300
|
);
|
|
1234
1301
|
var searchEmailsTool = defineTool({
|
|
1235
1302
|
name: "imap_search_emails",
|
|
1236
|
-
description:
|
|
1303
|
+
description: 'Search a folder for messages matching subject/from/to/body text, flag, date window, or size. Supports boolean combinators: `or: [...]` for "any of these match", `not: {...}` for exclusion. Runs IMAP SEARCH on the server (body text search is server-side), then returns cached envelopes for the matching UIDs. Results are newest-first.',
|
|
1237
1304
|
annotations: {
|
|
1238
1305
|
readOnlyHint: true,
|
|
1239
1306
|
destructiveHint: false,
|
|
@@ -1250,7 +1317,13 @@ var searchEmailsTool = defineTool({
|
|
|
1250
1317
|
...args.body !== void 0 && { body: args.body },
|
|
1251
1318
|
...args.unseen !== void 0 && { unseen: args.unseen },
|
|
1252
1319
|
...args.since_date !== void 0 && { since: new Date(args.since_date) },
|
|
1253
|
-
...args.before_date !== void 0 && { before: new Date(args.before_date) }
|
|
1320
|
+
...args.before_date !== void 0 && { before: new Date(args.before_date) },
|
|
1321
|
+
...args.larger_than_bytes !== void 0 && { larger_than_bytes: args.larger_than_bytes },
|
|
1322
|
+
...args.smaller_than_bytes !== void 0 && {
|
|
1323
|
+
smaller_than_bytes: args.smaller_than_bytes
|
|
1324
|
+
},
|
|
1325
|
+
...args.or !== void 0 && { or: args.or },
|
|
1326
|
+
...args.not !== void 0 && { not: args.not }
|
|
1254
1327
|
});
|
|
1255
1328
|
let matchingUids;
|
|
1256
1329
|
const imap = await ctx.imap.connection();
|
|
@@ -1366,12 +1439,98 @@ var markUnreadTool = defineTool({
|
|
|
1366
1439
|
}
|
|
1367
1440
|
});
|
|
1368
1441
|
|
|
1369
|
-
// src/tools/emails/
|
|
1442
|
+
// src/tools/emails/mark-read-multiple.ts
|
|
1370
1443
|
import { z as z7 } from "zod";
|
|
1371
1444
|
var Input6 = z7.object({
|
|
1372
|
-
folder: z7.string().min(1).describe("
|
|
1373
|
-
|
|
1374
|
-
|
|
1445
|
+
folder: z7.string().min(1).describe("Folder containing the messages."),
|
|
1446
|
+
uids: z7.array(z7.number().int().positive()).min(1).max(500).describe(
|
|
1447
|
+
"UIDs of messages to flip. Max 500 per call - chunk your own list for larger batches."
|
|
1448
|
+
)
|
|
1449
|
+
});
|
|
1450
|
+
async function updateSeenFlagBulk(ctx, folder, uids, want) {
|
|
1451
|
+
const imap = await ctx.imap.connection();
|
|
1452
|
+
const lock = await imap.getMailboxLock(folder);
|
|
1453
|
+
try {
|
|
1454
|
+
if (want === "add") {
|
|
1455
|
+
await imap.messageFlagsAdd(uids, ["\\Seen"], { uid: true });
|
|
1456
|
+
} else {
|
|
1457
|
+
await imap.messageFlagsRemove(uids, ["\\Seen"], { uid: true });
|
|
1458
|
+
}
|
|
1459
|
+
} catch (err) {
|
|
1460
|
+
throw mapImapError(err);
|
|
1461
|
+
} finally {
|
|
1462
|
+
lock.release();
|
|
1463
|
+
}
|
|
1464
|
+
mutateEmailFlagsForUids(
|
|
1465
|
+
ctx.db,
|
|
1466
|
+
folder,
|
|
1467
|
+
uids,
|
|
1468
|
+
(flags) => want === "add" ? flags.includes("\\Seen") ? flags : [...flags, "\\Seen"] : flags.filter((f) => f !== "\\Seen")
|
|
1469
|
+
);
|
|
1470
|
+
}
|
|
1471
|
+
var markReadMultipleTool = defineTool({
|
|
1472
|
+
name: "imap_mark_read_multiple",
|
|
1473
|
+
description: "Mark multiple messages as read in a single IMAP round-trip. Idempotent - already-read UIDs are unchanged. Use this when you have a concrete list of UIDs (e.g. from a search) instead of calling imap_mark_read N times.",
|
|
1474
|
+
annotations: {
|
|
1475
|
+
readOnlyHint: false,
|
|
1476
|
+
destructiveHint: false,
|
|
1477
|
+
idempotentHint: true,
|
|
1478
|
+
openWorldHint: true
|
|
1479
|
+
},
|
|
1480
|
+
inputSchema: Input6,
|
|
1481
|
+
handler: async (args, ctx) => {
|
|
1482
|
+
await updateSeenFlagBulk(ctx, args.folder, args.uids, "add");
|
|
1483
|
+
return {
|
|
1484
|
+
content: [
|
|
1485
|
+
{
|
|
1486
|
+
type: "text",
|
|
1487
|
+
text: `Marked ${String(args.uids.length)} message(s) as read in ${args.folder}.`
|
|
1488
|
+
}
|
|
1489
|
+
],
|
|
1490
|
+
structuredContent: {
|
|
1491
|
+
folder: args.folder,
|
|
1492
|
+
uids: args.uids,
|
|
1493
|
+
count: args.uids.length,
|
|
1494
|
+
seen: true
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
var markUnreadMultipleTool = defineTool({
|
|
1500
|
+
name: "imap_mark_unread_multiple",
|
|
1501
|
+
description: "Mark multiple messages as unread in a single IMAP round-trip. Idempotent.",
|
|
1502
|
+
annotations: {
|
|
1503
|
+
readOnlyHint: false,
|
|
1504
|
+
destructiveHint: false,
|
|
1505
|
+
idempotentHint: true,
|
|
1506
|
+
openWorldHint: true
|
|
1507
|
+
},
|
|
1508
|
+
inputSchema: Input6,
|
|
1509
|
+
handler: async (args, ctx) => {
|
|
1510
|
+
await updateSeenFlagBulk(ctx, args.folder, args.uids, "remove");
|
|
1511
|
+
return {
|
|
1512
|
+
content: [
|
|
1513
|
+
{
|
|
1514
|
+
type: "text",
|
|
1515
|
+
text: `Marked ${String(args.uids.length)} message(s) as unread in ${args.folder}.`
|
|
1516
|
+
}
|
|
1517
|
+
],
|
|
1518
|
+
structuredContent: {
|
|
1519
|
+
folder: args.folder,
|
|
1520
|
+
uids: args.uids,
|
|
1521
|
+
count: args.uids.length,
|
|
1522
|
+
seen: false
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1527
|
+
|
|
1528
|
+
// src/tools/emails/move-to-folder.ts
|
|
1529
|
+
import { z as z8 } from "zod";
|
|
1530
|
+
var Input7 = z8.object({
|
|
1531
|
+
folder: z8.string().min(1).describe("Current folder of the message."),
|
|
1532
|
+
uid: z8.number().int().positive().describe("IMAP UID of the message to move."),
|
|
1533
|
+
destination: z8.string().min(1).describe(
|
|
1375
1534
|
"Target folder path. Use imap_list_folders to discover valid destinations. Must exist on the server."
|
|
1376
1535
|
)
|
|
1377
1536
|
});
|
|
@@ -1385,7 +1544,7 @@ var moveToFolderTool = defineTool({
|
|
|
1385
1544
|
idempotentHint: false,
|
|
1386
1545
|
openWorldHint: true
|
|
1387
1546
|
},
|
|
1388
|
-
inputSchema:
|
|
1547
|
+
inputSchema: Input7,
|
|
1389
1548
|
handler: async (args, ctx) => {
|
|
1390
1549
|
const imap = await ctx.imap.connection();
|
|
1391
1550
|
const lock = await imap.getMailboxLock(args.folder);
|
|
@@ -1422,12 +1581,64 @@ var moveToFolderTool = defineTool({
|
|
|
1422
1581
|
}
|
|
1423
1582
|
});
|
|
1424
1583
|
|
|
1584
|
+
// src/tools/emails/move-multiple.ts
|
|
1585
|
+
import { z as z9 } from "zod";
|
|
1586
|
+
var Input8 = z9.object({
|
|
1587
|
+
folder: z9.string().min(1).describe("Current folder of the messages."),
|
|
1588
|
+
uids: z9.array(z9.number().int().positive()).min(1).max(500).describe("UIDs to move. Max 500 per call."),
|
|
1589
|
+
destination: z9.string().min(1).describe("Target folder. Must exist on the server.")
|
|
1590
|
+
});
|
|
1591
|
+
var moveMultipleTool = defineTool({
|
|
1592
|
+
name: "imap_move_multiple",
|
|
1593
|
+
description: "Move multiple messages to another folder in a single IMAP round-trip. Uses IMAP MOVE when the server supports it, otherwise ImapFlow falls back to COPY + EXPUNGE transparently.",
|
|
1594
|
+
annotations: {
|
|
1595
|
+
readOnlyHint: false,
|
|
1596
|
+
destructiveHint: true,
|
|
1597
|
+
idempotentHint: false,
|
|
1598
|
+
openWorldHint: true
|
|
1599
|
+
},
|
|
1600
|
+
inputSchema: Input8,
|
|
1601
|
+
handler: async (args, ctx) => {
|
|
1602
|
+
const imap = await ctx.imap.connection();
|
|
1603
|
+
const lock = await imap.getMailboxLock(args.folder);
|
|
1604
|
+
try {
|
|
1605
|
+
const ok = await imap.messageMove(args.uids, args.destination, { uid: true });
|
|
1606
|
+
if (!ok) {
|
|
1607
|
+
throw new ImapError(
|
|
1608
|
+
"IMAP_UNKNOWN",
|
|
1609
|
+
`Server rejected the move from ${args.folder} to ${args.destination}. Verify the destination folder exists.`
|
|
1610
|
+
);
|
|
1611
|
+
}
|
|
1612
|
+
} catch (err) {
|
|
1613
|
+
if (err instanceof ImapError) throw err;
|
|
1614
|
+
throw mapImapError(err);
|
|
1615
|
+
} finally {
|
|
1616
|
+
lock.release();
|
|
1617
|
+
}
|
|
1618
|
+
deleteEmailsByUids(ctx.db, args.folder, args.uids);
|
|
1619
|
+
return {
|
|
1620
|
+
content: [
|
|
1621
|
+
{
|
|
1622
|
+
type: "text",
|
|
1623
|
+
text: `Moved ${String(args.uids.length)} message(s) from ${args.folder} to ${args.destination}.`
|
|
1624
|
+
}
|
|
1625
|
+
],
|
|
1626
|
+
structuredContent: {
|
|
1627
|
+
folder: args.folder,
|
|
1628
|
+
uids: args.uids,
|
|
1629
|
+
count: args.uids.length,
|
|
1630
|
+
destination: args.destination
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1635
|
+
|
|
1425
1636
|
// src/tools/emails/delete-email.ts
|
|
1426
|
-
import { z as
|
|
1427
|
-
var
|
|
1428
|
-
folder:
|
|
1429
|
-
uid:
|
|
1430
|
-
hard_delete:
|
|
1637
|
+
import { z as z10 } from "zod";
|
|
1638
|
+
var Input9 = z10.object({
|
|
1639
|
+
folder: z10.string().min(1).describe("Folder containing the message to delete."),
|
|
1640
|
+
uid: z10.number().int().positive().describe("IMAP UID of the message to delete."),
|
|
1641
|
+
hard_delete: z10.boolean().default(false).describe(
|
|
1431
1642
|
"When false (default), the message is moved to the Trash folder and can be recovered by the user. When true, the message is permanently expunged from the server."
|
|
1432
1643
|
)
|
|
1433
1644
|
});
|
|
@@ -1440,7 +1651,7 @@ var deleteEmailTool = defineTool({
|
|
|
1440
1651
|
idempotentHint: false,
|
|
1441
1652
|
openWorldHint: true
|
|
1442
1653
|
},
|
|
1443
|
-
inputSchema:
|
|
1654
|
+
inputSchema: Input9,
|
|
1444
1655
|
handler: async (args, ctx) => {
|
|
1445
1656
|
const imap = await ctx.imap.connection();
|
|
1446
1657
|
if (args.hard_delete) {
|
|
@@ -1507,16 +1718,103 @@ var deleteEmailTool = defineTool({
|
|
|
1507
1718
|
}
|
|
1508
1719
|
});
|
|
1509
1720
|
|
|
1721
|
+
// src/tools/emails/delete-multiple.ts
|
|
1722
|
+
import { z as z11 } from "zod";
|
|
1723
|
+
var Input10 = z11.object({
|
|
1724
|
+
folder: z11.string().min(1).describe("Folder containing the messages to delete."),
|
|
1725
|
+
uids: z11.array(z11.number().int().positive()).min(1).max(500).describe("UIDs to delete. Max 500 per call."),
|
|
1726
|
+
hard_delete: z11.boolean().default(false).describe(
|
|
1727
|
+
"When false (default), messages move to the server Trash and can be recovered. When true, they are permanently expunged."
|
|
1728
|
+
)
|
|
1729
|
+
});
|
|
1730
|
+
var deleteMultipleTool = defineTool({
|
|
1731
|
+
name: "imap_delete_multiple",
|
|
1732
|
+
description: "Delete multiple messages in a single IMAP round-trip. Default soft-deletes (moves to \\Trash); `hard_delete=true` permanently expunges. Mirrors imap_delete_email's per-UID semantics but handles a whole batch at once.",
|
|
1733
|
+
annotations: {
|
|
1734
|
+
readOnlyHint: false,
|
|
1735
|
+
destructiveHint: true,
|
|
1736
|
+
idempotentHint: false,
|
|
1737
|
+
openWorldHint: true
|
|
1738
|
+
},
|
|
1739
|
+
inputSchema: Input10,
|
|
1740
|
+
handler: async (args, ctx) => {
|
|
1741
|
+
const imap = await ctx.imap.connection();
|
|
1742
|
+
if (args.hard_delete) {
|
|
1743
|
+
const lock2 = await imap.getMailboxLock(args.folder);
|
|
1744
|
+
try {
|
|
1745
|
+
await imap.messageDelete(args.uids, { uid: true });
|
|
1746
|
+
} catch (err) {
|
|
1747
|
+
throw mapImapError(err);
|
|
1748
|
+
} finally {
|
|
1749
|
+
lock2.release();
|
|
1750
|
+
}
|
|
1751
|
+
deleteEmailsByUids(ctx.db, args.folder, args.uids);
|
|
1752
|
+
return {
|
|
1753
|
+
content: [
|
|
1754
|
+
{
|
|
1755
|
+
type: "text",
|
|
1756
|
+
text: `Permanently deleted ${String(args.uids.length)} message(s) from ${args.folder}.`
|
|
1757
|
+
}
|
|
1758
|
+
],
|
|
1759
|
+
structuredContent: {
|
|
1760
|
+
folder: args.folder,
|
|
1761
|
+
uids: args.uids,
|
|
1762
|
+
count: args.uids.length,
|
|
1763
|
+
action: "hard_delete"
|
|
1764
|
+
}
|
|
1765
|
+
};
|
|
1766
|
+
}
|
|
1767
|
+
const trashFolder = await resolveSpecialFolder(ctx, "\\Trash");
|
|
1768
|
+
if (trashFolder === args.folder) {
|
|
1769
|
+
throw new ImapError(
|
|
1770
|
+
"IMAP_UNKNOWN",
|
|
1771
|
+
`Messages are already in the Trash folder (${args.folder}). Use hard_delete=true to permanently expunge.`
|
|
1772
|
+
);
|
|
1773
|
+
}
|
|
1774
|
+
const lock = await imap.getMailboxLock(args.folder);
|
|
1775
|
+
try {
|
|
1776
|
+
const ok = await imap.messageMove(args.uids, trashFolder, { uid: true });
|
|
1777
|
+
if (!ok) {
|
|
1778
|
+
throw new ImapError(
|
|
1779
|
+
"IMAP_UNKNOWN",
|
|
1780
|
+
`Server rejected the move from ${args.folder} to ${trashFolder}.`
|
|
1781
|
+
);
|
|
1782
|
+
}
|
|
1783
|
+
} catch (err) {
|
|
1784
|
+
if (err instanceof ImapError) throw err;
|
|
1785
|
+
throw mapImapError(err);
|
|
1786
|
+
} finally {
|
|
1787
|
+
lock.release();
|
|
1788
|
+
}
|
|
1789
|
+
deleteEmailsByUids(ctx.db, args.folder, args.uids);
|
|
1790
|
+
return {
|
|
1791
|
+
content: [
|
|
1792
|
+
{
|
|
1793
|
+
type: "text",
|
|
1794
|
+
text: `Moved ${String(args.uids.length)} message(s) from ${args.folder} to ${trashFolder} (Trash).`
|
|
1795
|
+
}
|
|
1796
|
+
],
|
|
1797
|
+
structuredContent: {
|
|
1798
|
+
folder: args.folder,
|
|
1799
|
+
uids: args.uids,
|
|
1800
|
+
count: args.uids.length,
|
|
1801
|
+
action: "moved_to_trash",
|
|
1802
|
+
trash_folder: trashFolder
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
});
|
|
1807
|
+
|
|
1510
1808
|
// src/tools/drafts/list-drafts.ts
|
|
1511
|
-
import { z as
|
|
1512
|
-
var
|
|
1513
|
-
folder:
|
|
1809
|
+
import { z as z12 } from "zod";
|
|
1810
|
+
var Input11 = z12.object({
|
|
1811
|
+
folder: z12.string().min(1).optional().describe(
|
|
1514
1812
|
"Optional explicit Drafts folder path. If omitted, mcp-inbox auto-detects via RFC 6154 SPECIAL-USE."
|
|
1515
1813
|
),
|
|
1516
|
-
limit:
|
|
1517
|
-
offset:
|
|
1518
|
-
max_staleness_seconds:
|
|
1519
|
-
response_format:
|
|
1814
|
+
limit: z12.number().int().min(1).max(100).default(20),
|
|
1815
|
+
offset: z12.number().int().min(0).default(0),
|
|
1816
|
+
max_staleness_seconds: z12.number().int().min(0).default(60),
|
|
1817
|
+
response_format: z12.enum(["markdown", "json"]).default("markdown")
|
|
1520
1818
|
});
|
|
1521
1819
|
var listDraftsTool = defineTool({
|
|
1522
1820
|
name: "imap_list_drafts",
|
|
@@ -1527,7 +1825,7 @@ var listDraftsTool = defineTool({
|
|
|
1527
1825
|
idempotentHint: true,
|
|
1528
1826
|
openWorldHint: true
|
|
1529
1827
|
},
|
|
1530
|
-
inputSchema:
|
|
1828
|
+
inputSchema: Input11,
|
|
1531
1829
|
handler: async (args, ctx) => {
|
|
1532
1830
|
const folder = await resolveSpecialFolder(ctx, "\\Drafts", args.folder);
|
|
1533
1831
|
const didSync = await syncIfStale(ctx, folder, args.max_staleness_seconds);
|
|
@@ -1554,12 +1852,12 @@ ${formatEmailListMarkdown(rows)}`;
|
|
|
1554
1852
|
});
|
|
1555
1853
|
|
|
1556
1854
|
// src/tools/drafts/get-draft.ts
|
|
1557
|
-
import { z as
|
|
1558
|
-
var
|
|
1559
|
-
uid:
|
|
1560
|
-
folder:
|
|
1561
|
-
max_staleness_seconds:
|
|
1562
|
-
response_format:
|
|
1855
|
+
import { z as z13 } from "zod";
|
|
1856
|
+
var Input12 = z13.object({
|
|
1857
|
+
uid: z13.number().int().positive().describe("IMAP UID of the draft in the Drafts folder. Use imap_list_drafts to discover UIDs."),
|
|
1858
|
+
folder: z13.string().min(1).optional().describe("Optional explicit Drafts folder path. Auto-detected from SPECIAL-USE when omitted."),
|
|
1859
|
+
max_staleness_seconds: z13.number().int().min(0).default(60),
|
|
1860
|
+
response_format: z13.enum(["markdown", "json"]).default("markdown")
|
|
1563
1861
|
});
|
|
1564
1862
|
var getDraftTool = defineTool({
|
|
1565
1863
|
name: "imap_get_draft",
|
|
@@ -1570,7 +1868,7 @@ var getDraftTool = defineTool({
|
|
|
1570
1868
|
idempotentHint: true,
|
|
1571
1869
|
openWorldHint: true
|
|
1572
1870
|
},
|
|
1573
|
-
inputSchema:
|
|
1871
|
+
inputSchema: Input12,
|
|
1574
1872
|
handler: async (args, ctx) => {
|
|
1575
1873
|
const folder = await resolveSpecialFolder(ctx, "\\Drafts", args.folder);
|
|
1576
1874
|
const envelope = await ensureEnvelopeCached(ctx, folder, args.uid, args.max_staleness_seconds);
|
|
@@ -1605,7 +1903,7 @@ function formatDraftMarkdown(d) {
|
|
|
1605
1903
|
}
|
|
1606
1904
|
|
|
1607
1905
|
// src/tools/drafts/create-draft.ts
|
|
1608
|
-
import { z as
|
|
1906
|
+
import { z as z14 } from "zod";
|
|
1609
1907
|
|
|
1610
1908
|
// src/imap/mime-builder.ts
|
|
1611
1909
|
import MailComposer from "nodemailer/lib/mail-composer/index.js";
|
|
@@ -1628,18 +1926,18 @@ async function buildRawMessage(input) {
|
|
|
1628
1926
|
}
|
|
1629
1927
|
|
|
1630
1928
|
// src/tools/drafts/create-draft.ts
|
|
1631
|
-
var AddressList =
|
|
1632
|
-
var
|
|
1929
|
+
var AddressList = z14.union([z14.string().min(1), z14.array(z14.string().min(1)).min(1)]);
|
|
1930
|
+
var Input13 = z14.object({
|
|
1633
1931
|
to: AddressList.describe("Recipient email address or array of addresses."),
|
|
1634
|
-
subject:
|
|
1635
|
-
body:
|
|
1636
|
-
html:
|
|
1932
|
+
subject: z14.string(),
|
|
1933
|
+
body: z14.string().optional().describe("Plain-text body."),
|
|
1934
|
+
html: z14.string().optional().describe("HTML body (combined with text via multipart/alternative)."),
|
|
1637
1935
|
cc: AddressList.optional(),
|
|
1638
1936
|
bcc: AddressList.optional(),
|
|
1639
|
-
from:
|
|
1937
|
+
from: z14.string().min(1).optional().describe(
|
|
1640
1938
|
"Sender address. Defaults to IMAP_USER. Some providers reject mismatched From headers."
|
|
1641
1939
|
),
|
|
1642
|
-
folder:
|
|
1940
|
+
folder: z14.string().min(1).optional().describe("Explicit Drafts folder. Auto-resolves via SPECIAL-USE when omitted.")
|
|
1643
1941
|
});
|
|
1644
1942
|
var createDraftTool = defineTool({
|
|
1645
1943
|
name: "imap_create_draft",
|
|
@@ -1650,7 +1948,7 @@ var createDraftTool = defineTool({
|
|
|
1650
1948
|
idempotentHint: false,
|
|
1651
1949
|
openWorldHint: true
|
|
1652
1950
|
},
|
|
1653
|
-
inputSchema:
|
|
1951
|
+
inputSchema: Input13,
|
|
1654
1952
|
handler: async (args, ctx) => {
|
|
1655
1953
|
const folder = await resolveSpecialFolder(ctx, "\\Drafts", args.folder);
|
|
1656
1954
|
const raw = await buildRawMessage({
|
|
@@ -1690,18 +1988,18 @@ var createDraftTool = defineTool({
|
|
|
1690
1988
|
});
|
|
1691
1989
|
|
|
1692
1990
|
// src/tools/drafts/update-draft.ts
|
|
1693
|
-
import { z as
|
|
1694
|
-
var AddressList2 =
|
|
1695
|
-
var
|
|
1696
|
-
uid:
|
|
1991
|
+
import { z as z15 } from "zod";
|
|
1992
|
+
var AddressList2 = z15.union([z15.string().min(1), z15.array(z15.string().min(1)).min(1)]);
|
|
1993
|
+
var Input14 = z15.object({
|
|
1994
|
+
uid: z15.number().int().positive().describe("UID of the existing draft to replace. Use imap_list_drafts to find it."),
|
|
1697
1995
|
to: AddressList2,
|
|
1698
|
-
subject:
|
|
1699
|
-
body:
|
|
1700
|
-
html:
|
|
1996
|
+
subject: z15.string(),
|
|
1997
|
+
body: z15.string().optional(),
|
|
1998
|
+
html: z15.string().optional(),
|
|
1701
1999
|
cc: AddressList2.optional(),
|
|
1702
2000
|
bcc: AddressList2.optional(),
|
|
1703
|
-
from:
|
|
1704
|
-
folder:
|
|
2001
|
+
from: z15.string().min(1).optional(),
|
|
2002
|
+
folder: z15.string().min(1).optional()
|
|
1705
2003
|
});
|
|
1706
2004
|
var updateDraftTool = defineTool({
|
|
1707
2005
|
name: "imap_update_draft",
|
|
@@ -1713,7 +2011,7 @@ var updateDraftTool = defineTool({
|
|
|
1713
2011
|
idempotentHint: false,
|
|
1714
2012
|
openWorldHint: true
|
|
1715
2013
|
},
|
|
1716
|
-
inputSchema:
|
|
2014
|
+
inputSchema: Input14,
|
|
1717
2015
|
handler: async (args, ctx) => {
|
|
1718
2016
|
const folder = await resolveSpecialFolder(ctx, "\\Drafts", args.folder);
|
|
1719
2017
|
const raw = await buildRawMessage({
|
|
@@ -1785,7 +2083,7 @@ var updateDraftTool = defineTool({
|
|
|
1785
2083
|
});
|
|
1786
2084
|
|
|
1787
2085
|
// src/tools/send/send-email.ts
|
|
1788
|
-
import { z as
|
|
2086
|
+
import { z as z16 } from "zod";
|
|
1789
2087
|
|
|
1790
2088
|
// src/tools/send/shared.ts
|
|
1791
2089
|
function normalizeAddrs(value) {
|
|
@@ -1827,15 +2125,15 @@ function flattenCompose(args) {
|
|
|
1827
2125
|
}
|
|
1828
2126
|
|
|
1829
2127
|
// src/tools/send/send-email.ts
|
|
1830
|
-
var AddressList3 =
|
|
1831
|
-
var
|
|
2128
|
+
var AddressList3 = z16.union([z16.string().min(1), z16.array(z16.string().min(1)).min(1)]);
|
|
2129
|
+
var Input15 = z16.object({
|
|
1832
2130
|
to: AddressList3.describe("Recipient email address or array of addresses."),
|
|
1833
|
-
subject:
|
|
1834
|
-
body:
|
|
1835
|
-
html:
|
|
2131
|
+
subject: z16.string(),
|
|
2132
|
+
body: z16.string().optional().describe("Plain-text body."),
|
|
2133
|
+
html: z16.string().optional().describe("HTML body (sent as multipart/alternative with text)."),
|
|
1836
2134
|
cc: AddressList3.optional(),
|
|
1837
2135
|
bcc: AddressList3.optional(),
|
|
1838
|
-
from:
|
|
2136
|
+
from: z16.string().min(1).optional().describe(
|
|
1839
2137
|
"Sender address. Defaults to IMAP_USER. Providers like Gmail and Fastmail reject mismatched From unless the address is a verified alias."
|
|
1840
2138
|
)
|
|
1841
2139
|
});
|
|
@@ -1848,7 +2146,7 @@ var sendEmailTool = defineTool({
|
|
|
1848
2146
|
idempotentHint: false,
|
|
1849
2147
|
openWorldHint: true
|
|
1850
2148
|
},
|
|
1851
|
-
inputSchema:
|
|
2149
|
+
inputSchema: Input15,
|
|
1852
2150
|
handler: async (args, ctx) => {
|
|
1853
2151
|
const compose = flattenCompose({
|
|
1854
2152
|
...args.from !== void 0 && { from: args.from },
|
|
@@ -1895,11 +2193,11 @@ var sendEmailTool = defineTool({
|
|
|
1895
2193
|
});
|
|
1896
2194
|
|
|
1897
2195
|
// src/tools/send/send-draft.ts
|
|
1898
|
-
import { z as
|
|
2196
|
+
import { z as z17 } from "zod";
|
|
1899
2197
|
import { simpleParser as simpleParser2 } from "mailparser";
|
|
1900
|
-
var
|
|
1901
|
-
uid:
|
|
1902
|
-
folder:
|
|
2198
|
+
var Input16 = z17.object({
|
|
2199
|
+
uid: z17.number().int().positive().describe("UID of the draft to send."),
|
|
2200
|
+
folder: z17.string().min(1).optional().describe("Explicit Drafts folder. Auto-resolves via SPECIAL-USE when omitted.")
|
|
1903
2201
|
});
|
|
1904
2202
|
var sendDraftTool = defineTool({
|
|
1905
2203
|
name: "imap_send_draft",
|
|
@@ -1910,7 +2208,7 @@ var sendDraftTool = defineTool({
|
|
|
1910
2208
|
idempotentHint: false,
|
|
1911
2209
|
openWorldHint: true
|
|
1912
2210
|
},
|
|
1913
|
-
inputSchema:
|
|
2211
|
+
inputSchema: Input16,
|
|
1914
2212
|
handler: async (args, ctx) => {
|
|
1915
2213
|
const folder = await resolveSpecialFolder(ctx, "\\Drafts", args.folder);
|
|
1916
2214
|
const imap = await ctx.imap.connection();
|
|
@@ -2012,20 +2310,20 @@ function addressList(field) {
|
|
|
2012
2310
|
}
|
|
2013
2311
|
|
|
2014
2312
|
// src/tools/send/reply.ts
|
|
2015
|
-
import { z as
|
|
2016
|
-
var AddressList4 =
|
|
2017
|
-
var
|
|
2018
|
-
folder:
|
|
2019
|
-
uid:
|
|
2020
|
-
body:
|
|
2021
|
-
html:
|
|
2313
|
+
import { z as z18 } from "zod";
|
|
2314
|
+
var AddressList4 = z18.union([z18.string().min(1), z18.array(z18.string().min(1)).min(1)]);
|
|
2315
|
+
var Input17 = z18.object({
|
|
2316
|
+
folder: z18.string().min(1).describe("Folder of the original message."),
|
|
2317
|
+
uid: z18.number().int().positive().describe("UID of the message being replied to."),
|
|
2318
|
+
body: z18.string().optional(),
|
|
2319
|
+
html: z18.string().optional(),
|
|
2022
2320
|
cc: AddressList4.optional(),
|
|
2023
2321
|
bcc: AddressList4.optional(),
|
|
2024
|
-
reply_all:
|
|
2322
|
+
reply_all: z18.boolean().default(false).describe(
|
|
2025
2323
|
"When true, CC the original To + Cc recipients (minus the sender). When false, reply only to the original From."
|
|
2026
2324
|
),
|
|
2027
|
-
from:
|
|
2028
|
-
max_staleness_seconds:
|
|
2325
|
+
from: z18.string().min(1).optional(),
|
|
2326
|
+
max_staleness_seconds: z18.number().int().min(0).default(60)
|
|
2029
2327
|
});
|
|
2030
2328
|
var replyTool = defineTool({
|
|
2031
2329
|
name: "imap_reply",
|
|
@@ -2036,7 +2334,7 @@ var replyTool = defineTool({
|
|
|
2036
2334
|
idempotentHint: false,
|
|
2037
2335
|
openWorldHint: true
|
|
2038
2336
|
},
|
|
2039
|
-
inputSchema:
|
|
2337
|
+
inputSchema: Input17,
|
|
2040
2338
|
handler: async (args, ctx) => {
|
|
2041
2339
|
const original = await ensureEnvelopeCached(
|
|
2042
2340
|
ctx,
|
|
@@ -2128,19 +2426,19 @@ function dedupeAddrs(addrs, exclude) {
|
|
|
2128
2426
|
}
|
|
2129
2427
|
|
|
2130
2428
|
// src/tools/send/forward.ts
|
|
2131
|
-
import { z as
|
|
2132
|
-
var AddressList5 =
|
|
2133
|
-
var
|
|
2134
|
-
folder:
|
|
2135
|
-
uid:
|
|
2429
|
+
import { z as z19 } from "zod";
|
|
2430
|
+
var AddressList5 = z19.union([z19.string().min(1), z19.array(z19.string().min(1)).min(1)]);
|
|
2431
|
+
var Input18 = z19.object({
|
|
2432
|
+
folder: z19.string().min(1).describe("Folder of the original message."),
|
|
2433
|
+
uid: z19.number().int().positive().describe("UID of the message to forward."),
|
|
2136
2434
|
to: AddressList5.describe("Recipient(s) to forward to."),
|
|
2137
|
-
body:
|
|
2435
|
+
body: z19.string().optional().describe(
|
|
2138
2436
|
'Optional prefix body (e.g. "FYI, thought you should see this."). Quoted original follows.'
|
|
2139
2437
|
),
|
|
2140
2438
|
cc: AddressList5.optional(),
|
|
2141
2439
|
bcc: AddressList5.optional(),
|
|
2142
|
-
from:
|
|
2143
|
-
max_staleness_seconds:
|
|
2440
|
+
from: z19.string().min(1).optional(),
|
|
2441
|
+
max_staleness_seconds: z19.number().int().min(0).default(60)
|
|
2144
2442
|
});
|
|
2145
2443
|
var forwardTool = defineTool({
|
|
2146
2444
|
name: "imap_forward",
|
|
@@ -2151,7 +2449,7 @@ var forwardTool = defineTool({
|
|
|
2151
2449
|
idempotentHint: false,
|
|
2152
2450
|
openWorldHint: true
|
|
2153
2451
|
},
|
|
2154
|
-
inputSchema:
|
|
2452
|
+
inputSchema: Input18,
|
|
2155
2453
|
handler: async (args, ctx) => {
|
|
2156
2454
|
const original = await ensureEnvelopeCached(
|
|
2157
2455
|
ctx,
|
|
@@ -2229,16 +2527,16 @@ function escapeHtml(s) {
|
|
|
2229
2527
|
}
|
|
2230
2528
|
|
|
2231
2529
|
// src/tools/attachments/get-attachment.ts
|
|
2232
|
-
import { z as
|
|
2530
|
+
import { z as z20 } from "zod";
|
|
2233
2531
|
import { simpleParser as simpleParser3 } from "mailparser";
|
|
2234
|
-
var
|
|
2235
|
-
folder:
|
|
2236
|
-
uid:
|
|
2237
|
-
filename:
|
|
2532
|
+
var Input19 = z20.object({
|
|
2533
|
+
folder: z20.string().min(1).describe("Folder containing the message."),
|
|
2534
|
+
uid: z20.number().int().positive().describe("IMAP UID of the message."),
|
|
2535
|
+
filename: z20.string().min(1).optional().describe(
|
|
2238
2536
|
"Filename of the attachment to fetch. First match wins if the message has multiple attachments with the same name - use part_id to disambiguate."
|
|
2239
2537
|
),
|
|
2240
|
-
part_id:
|
|
2241
|
-
max_inline_mb:
|
|
2538
|
+
part_id: z20.string().min(1).optional().describe('MIME part ID (e.g. "1.2"). Use when multiple parts share a filename.'),
|
|
2539
|
+
max_inline_mb: z20.number().int().min(1).max(50).default(5).describe(
|
|
2242
2540
|
"Maximum attachment size to return inline, in MB. Attachments larger than this are rejected with a clear error. Cap exists to avoid blowing up MCP response size."
|
|
2243
2541
|
)
|
|
2244
2542
|
}).refine((v) => v.filename !== void 0 || v.part_id !== void 0, {
|
|
@@ -2253,7 +2551,7 @@ var getAttachmentTool = defineTool({
|
|
|
2253
2551
|
idempotentHint: true,
|
|
2254
2552
|
openWorldHint: true
|
|
2255
2553
|
},
|
|
2256
|
-
inputSchema:
|
|
2554
|
+
inputSchema: Input19,
|
|
2257
2555
|
handler: async (args, ctx) => {
|
|
2258
2556
|
const imap = await ctx.imap.connection();
|
|
2259
2557
|
const lock = await imap.getMailboxLock(args.folder);
|
|
@@ -2393,6 +2691,11 @@ var tools = [
|
|
|
2393
2691
|
markUnreadTool,
|
|
2394
2692
|
moveToFolderTool,
|
|
2395
2693
|
deleteEmailTool,
|
|
2694
|
+
// Bulk variants of the same (one IMAP round-trip for N UIDs)
|
|
2695
|
+
markReadMultipleTool,
|
|
2696
|
+
markUnreadMultipleTool,
|
|
2697
|
+
moveMultipleTool,
|
|
2698
|
+
deleteMultipleTool,
|
|
2396
2699
|
// Drafts (compose)
|
|
2397
2700
|
createDraftTool,
|
|
2398
2701
|
updateDraftTool,
|
|
@@ -2411,7 +2714,15 @@ function listToolEntries() {
|
|
|
2411
2714
|
return tools.map((t) => ({
|
|
2412
2715
|
name: t.name,
|
|
2413
2716
|
description: t.description,
|
|
2414
|
-
|
|
2717
|
+
// `unrepresentable: 'any'` is needed because some schemas use
|
|
2718
|
+
// `z.coerce.date()` (which has no JSON Schema equivalent). With
|
|
2719
|
+
// this setting, such types become `{}` (matches anything) in the
|
|
2720
|
+
// exposed inputSchema, and the real validation still happens on
|
|
2721
|
+
// the Zod side inside the CallTool dispatcher.
|
|
2722
|
+
inputSchema: z21.toJSONSchema(t.inputSchema, {
|
|
2723
|
+
target: "draft-7",
|
|
2724
|
+
unrepresentable: "any"
|
|
2725
|
+
}),
|
|
2415
2726
|
annotations: t.annotations
|
|
2416
2727
|
}));
|
|
2417
2728
|
}
|
|
@@ -2564,9 +2875,17 @@ try {
|
|
|
2564
2875
|
await server.connect(transport);
|
|
2565
2876
|
rootLogger.info("mcp-inbox ready");
|
|
2566
2877
|
} catch (err) {
|
|
2567
|
-
const
|
|
2568
|
-
process.stderr.write(`fatal: ${
|
|
2878
|
+
const top = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
2879
|
+
process.stderr.write(`fatal: ${top}
|
|
2880
|
+
`);
|
|
2881
|
+
let cause = err instanceof Error ? err.cause : void 0;
|
|
2882
|
+
let depth = 0;
|
|
2883
|
+
while (cause instanceof Error && depth < 5) {
|
|
2884
|
+
process.stderr.write(`caused by: ${cause.stack ?? cause.message}
|
|
2569
2885
|
`);
|
|
2886
|
+
cause = cause.cause;
|
|
2887
|
+
depth++;
|
|
2888
|
+
}
|
|
2570
2889
|
process.exit(1);
|
|
2571
2890
|
}
|
|
2572
2891
|
//# sourceMappingURL=index.js.map
|