@gnidreve/classic-imap-smtp-mcp 0.3.0 → 0.3.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.
- package/dist/main.js +67 -39
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -665,11 +665,15 @@ var download_attachment_default = defineTool({
|
|
|
665
665
|
const client = await ctx.imap.acquire(accountName);
|
|
666
666
|
const mb = await client.mailboxOpen(input.mailbox);
|
|
667
667
|
if (!mb) throw new MailboxNotFoundError(input.mailbox);
|
|
668
|
-
const msg = await client.fetchOne(
|
|
669
|
-
uid
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
668
|
+
const msg = await client.fetchOne(
|
|
669
|
+
input.uid,
|
|
670
|
+
{
|
|
671
|
+
uid: true,
|
|
672
|
+
bodyParts: [input.partId],
|
|
673
|
+
bodyStructure: true
|
|
674
|
+
},
|
|
675
|
+
{ uid: true }
|
|
676
|
+
);
|
|
673
677
|
if (!msg) throw new UidNotFoundError(input.uid, input.mailbox);
|
|
674
678
|
const part = msg.bodyParts?.get(input.partId);
|
|
675
679
|
if (!part) throw new AttachmentNotFoundError(`Part ${input.partId}`);
|
|
@@ -711,10 +715,14 @@ var get_message_headers_default = defineTool({
|
|
|
711
715
|
const client = await ctx.imap.acquire(accountName);
|
|
712
716
|
const mailbox = await client.mailboxOpen(input.mailbox);
|
|
713
717
|
if (!mailbox) throw new MailboxNotFoundError(input.mailbox);
|
|
714
|
-
const msg = await client.fetchOne(
|
|
715
|
-
uid
|
|
716
|
-
|
|
717
|
-
|
|
718
|
+
const msg = await client.fetchOne(
|
|
719
|
+
input.uid,
|
|
720
|
+
{
|
|
721
|
+
uid: true,
|
|
722
|
+
headers: true
|
|
723
|
+
},
|
|
724
|
+
{ uid: true }
|
|
725
|
+
);
|
|
718
726
|
if (!msg) throw new UidNotFoundError(input.uid, input.mailbox);
|
|
719
727
|
const rawHeaders = msg.headers?.toString() ?? "";
|
|
720
728
|
const headers = {};
|
|
@@ -784,10 +792,14 @@ var get_message_raw_default = defineTool({
|
|
|
784
792
|
const client = await ctx.imap.acquire(accountName);
|
|
785
793
|
const mailbox = await client.mailboxOpen(input.mailbox);
|
|
786
794
|
if (!mailbox) throw new MailboxNotFoundError(input.mailbox);
|
|
787
|
-
const msg = await client.fetchOne(
|
|
788
|
-
uid
|
|
789
|
-
|
|
790
|
-
|
|
795
|
+
const msg = await client.fetchOne(
|
|
796
|
+
input.uid,
|
|
797
|
+
{
|
|
798
|
+
uid: true,
|
|
799
|
+
source: true
|
|
800
|
+
},
|
|
801
|
+
{ uid: true }
|
|
802
|
+
);
|
|
791
803
|
if (!msg) throw new UidNotFoundError(input.uid, input.mailbox);
|
|
792
804
|
return {
|
|
793
805
|
uid: msg.uid,
|
|
@@ -870,13 +882,17 @@ var get_message_default = defineTool({
|
|
|
870
882
|
const client = await ctx.imap.acquire(accountName);
|
|
871
883
|
const mailbox = await client.mailboxOpen(input.mailbox);
|
|
872
884
|
if (!mailbox) throw new MailboxNotFoundError(input.mailbox);
|
|
873
|
-
const msg = await client.fetchOne(
|
|
874
|
-
uid
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
885
|
+
const msg = await client.fetchOne(
|
|
886
|
+
input.uid,
|
|
887
|
+
{
|
|
888
|
+
uid: true,
|
|
889
|
+
envelope: true,
|
|
890
|
+
flags: true,
|
|
891
|
+
size: true,
|
|
892
|
+
source: true
|
|
893
|
+
},
|
|
894
|
+
{ uid: true }
|
|
895
|
+
);
|
|
880
896
|
if (!msg) throw new UidNotFoundError(input.uid, input.mailbox);
|
|
881
897
|
const raw = msg.source?.toString() ?? "";
|
|
882
898
|
let parsed;
|
|
@@ -943,13 +959,17 @@ var get_messages_bulk_default = defineTool({
|
|
|
943
959
|
const messages = [];
|
|
944
960
|
const notFound = [];
|
|
945
961
|
const uidSet = new Set(input.uids);
|
|
946
|
-
for await (const msg of client.fetch(
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
962
|
+
for await (const msg of client.fetch(
|
|
963
|
+
input.uids,
|
|
964
|
+
{
|
|
965
|
+
uid: true,
|
|
966
|
+
envelope: true,
|
|
967
|
+
flags: true,
|
|
968
|
+
size: true,
|
|
969
|
+
source: true
|
|
970
|
+
},
|
|
971
|
+
{ uid: true }
|
|
972
|
+
)) {
|
|
953
973
|
uidSet.delete(msg.uid);
|
|
954
974
|
const raw = msg.source?.toString() ?? "";
|
|
955
975
|
let parsed;
|
|
@@ -1479,8 +1499,8 @@ var status_mailbox_default = defineTool({
|
|
|
1479
1499
|
messages: status.messages ?? 0,
|
|
1480
1500
|
unseen: status.unseen ?? 0,
|
|
1481
1501
|
recent: status.recent ?? 0,
|
|
1482
|
-
...status.uidNext !== void 0 ? { uidNext: status.uidNext } : {},
|
|
1483
|
-
...status.uidValidity !== void 0 ? { uidValidity: status.uidValidity } : {}
|
|
1502
|
+
...status.uidNext !== void 0 ? { uidNext: Number(status.uidNext) } : {},
|
|
1503
|
+
...status.uidValidity !== void 0 ? { uidValidity: Number(status.uidValidity) } : {}
|
|
1484
1504
|
};
|
|
1485
1505
|
} catch (err) {
|
|
1486
1506
|
throw new MailboxNotFoundError(input.mailbox);
|
|
@@ -1975,11 +1995,15 @@ var forward_default = defineTool({
|
|
|
1975
1995
|
const imapClient = await ctx.imap.acquire(accountName);
|
|
1976
1996
|
const mb = await imapClient.mailboxOpen(input.originalMailbox);
|
|
1977
1997
|
if (!mb) throw new MailboxNotFoundError(input.originalMailbox);
|
|
1978
|
-
const original = await imapClient.fetchOne(
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1998
|
+
const original = await imapClient.fetchOne(
|
|
1999
|
+
input.originalUid,
|
|
2000
|
+
{
|
|
2001
|
+
uid: true,
|
|
2002
|
+
envelope: true,
|
|
2003
|
+
source: true
|
|
2004
|
+
},
|
|
2005
|
+
{ uid: true }
|
|
2006
|
+
);
|
|
1983
2007
|
if (!original) throw new UidNotFoundError(input.originalUid, input.originalMailbox);
|
|
1984
2008
|
const enc = original.envelope;
|
|
1985
2009
|
if (!enc) throw new Error("Original message has no envelope");
|
|
@@ -2094,11 +2118,15 @@ var reply_default = defineTool({
|
|
|
2094
2118
|
const imapClient = await ctx.imap.acquire(accountName);
|
|
2095
2119
|
const mb = await imapClient.mailboxOpen(input.originalMailbox);
|
|
2096
2120
|
if (!mb) throw new MailboxNotFoundError(input.originalMailbox);
|
|
2097
|
-
const original = await imapClient.fetchOne(
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2121
|
+
const original = await imapClient.fetchOne(
|
|
2122
|
+
input.originalUid,
|
|
2123
|
+
{
|
|
2124
|
+
uid: true,
|
|
2125
|
+
envelope: true,
|
|
2126
|
+
headers: true
|
|
2127
|
+
},
|
|
2128
|
+
{ uid: true }
|
|
2129
|
+
);
|
|
2102
2130
|
if (!original) throw new UidNotFoundError(input.originalUid, input.originalMailbox);
|
|
2103
2131
|
const enc = original.envelope;
|
|
2104
2132
|
if (!enc) throw new Error("Original message has no envelope");
|