@diskd-ai/email-mcp 0.3.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.
Files changed (295) hide show
  1. package/LICENSE +155 -0
  2. package/README.md +820 -0
  3. package/dist/cli/account-commands.d.ts +10 -0
  4. package/dist/cli/account-commands.d.ts.map +1 -0
  5. package/dist/cli/account-commands.js +703 -0
  6. package/dist/cli/account-commands.js.map +1 -0
  7. package/dist/cli/config-commands.d.ts +9 -0
  8. package/dist/cli/config-commands.d.ts.map +1 -0
  9. package/dist/cli/config-commands.js +156 -0
  10. package/dist/cli/config-commands.js.map +1 -0
  11. package/dist/cli/guard.d.ts +11 -0
  12. package/dist/cli/guard.d.ts.map +1 -0
  13. package/dist/cli/guard.js +18 -0
  14. package/dist/cli/guard.js.map +1 -0
  15. package/dist/cli/install-commands.d.ts +12 -0
  16. package/dist/cli/install-commands.d.ts.map +1 -0
  17. package/dist/cli/install-commands.js +320 -0
  18. package/dist/cli/install-commands.js.map +1 -0
  19. package/dist/cli/notify.d.ts +8 -0
  20. package/dist/cli/notify.d.ts.map +1 -0
  21. package/dist/cli/notify.js +143 -0
  22. package/dist/cli/notify.js.map +1 -0
  23. package/dist/cli/providers.d.ts +13 -0
  24. package/dist/cli/providers.d.ts.map +1 -0
  25. package/dist/cli/providers.js +180 -0
  26. package/dist/cli/providers.js.map +1 -0
  27. package/dist/cli/scheduler.d.ts +8 -0
  28. package/dist/cli/scheduler.d.ts.map +1 -0
  29. package/dist/cli/scheduler.js +268 -0
  30. package/dist/cli/scheduler.js.map +1 -0
  31. package/dist/cli/setup.d.ts +12 -0
  32. package/dist/cli/setup.d.ts.map +1 -0
  33. package/dist/cli/setup.js +15 -0
  34. package/dist/cli/setup.js.map +1 -0
  35. package/dist/cli/test.d.ts +7 -0
  36. package/dist/cli/test.d.ts.map +1 -0
  37. package/dist/cli/test.js +67 -0
  38. package/dist/cli/test.js.map +1 -0
  39. package/dist/config/loader.d.ts +34 -0
  40. package/dist/config/loader.d.ts.map +1 -0
  41. package/dist/config/loader.js +339 -0
  42. package/dist/config/loader.js.map +1 -0
  43. package/dist/config/schema.d.ts +351 -0
  44. package/dist/config/schema.d.ts.map +1 -0
  45. package/dist/config/schema.js +165 -0
  46. package/dist/config/schema.js.map +1 -0
  47. package/dist/config/xdg.d.ts +27 -0
  48. package/dist/config/xdg.d.ts.map +1 -0
  49. package/dist/config/xdg.js +30 -0
  50. package/dist/config/xdg.js.map +1 -0
  51. package/dist/connections/manager.d.ts +42 -0
  52. package/dist/connections/manager.d.ts.map +1 -0
  53. package/dist/connections/manager.js +266 -0
  54. package/dist/connections/manager.js.map +1 -0
  55. package/dist/connections/types.d.ts +13 -0
  56. package/dist/connections/types.d.ts.map +1 -0
  57. package/dist/connections/types.js +2 -0
  58. package/dist/connections/types.js.map +1 -0
  59. package/dist/logging.d.ts +46 -0
  60. package/dist/logging.d.ts.map +1 -0
  61. package/dist/logging.js +63 -0
  62. package/dist/logging.js.map +1 -0
  63. package/dist/main.d.ts +13 -0
  64. package/dist/main.d.ts.map +1 -0
  65. package/dist/main.js +206 -0
  66. package/dist/main.js.map +1 -0
  67. package/dist/prompts/actions.prompt.d.ts +9 -0
  68. package/dist/prompts/actions.prompt.d.ts.map +1 -0
  69. package/dist/prompts/actions.prompt.js +64 -0
  70. package/dist/prompts/actions.prompt.js.map +1 -0
  71. package/dist/prompts/calendar.prompt.d.ts +9 -0
  72. package/dist/prompts/calendar.prompt.d.ts.map +1 -0
  73. package/dist/prompts/calendar.prompt.js +55 -0
  74. package/dist/prompts/calendar.prompt.js.map +1 -0
  75. package/dist/prompts/cleanup.prompt.d.ts +9 -0
  76. package/dist/prompts/cleanup.prompt.d.ts.map +1 -0
  77. package/dist/prompts/cleanup.prompt.js +78 -0
  78. package/dist/prompts/cleanup.prompt.js.map +1 -0
  79. package/dist/prompts/compose.prompt.d.ts +8 -0
  80. package/dist/prompts/compose.prompt.d.ts.map +1 -0
  81. package/dist/prompts/compose.prompt.js +116 -0
  82. package/dist/prompts/compose.prompt.js.map +1 -0
  83. package/dist/prompts/register.d.ts +8 -0
  84. package/dist/prompts/register.d.ts.map +1 -0
  85. package/dist/prompts/register.js +20 -0
  86. package/dist/prompts/register.js.map +1 -0
  87. package/dist/prompts/thread.prompt.d.ts +9 -0
  88. package/dist/prompts/thread.prompt.d.ts.map +1 -0
  89. package/dist/prompts/thread.prompt.js +58 -0
  90. package/dist/prompts/thread.prompt.js.map +1 -0
  91. package/dist/prompts/triage.prompt.d.ts +9 -0
  92. package/dist/prompts/triage.prompt.d.ts.map +1 -0
  93. package/dist/prompts/triage.prompt.js +64 -0
  94. package/dist/prompts/triage.prompt.js.map +1 -0
  95. package/dist/resources/accounts.resource.d.ts +9 -0
  96. package/dist/resources/accounts.resource.d.ts.map +1 -0
  97. package/dist/resources/accounts.resource.js +26 -0
  98. package/dist/resources/accounts.resource.js.map +1 -0
  99. package/dist/resources/mailboxes.resource.d.ts +10 -0
  100. package/dist/resources/mailboxes.resource.d.ts.map +1 -0
  101. package/dist/resources/mailboxes.resource.js +33 -0
  102. package/dist/resources/mailboxes.resource.js.map +1 -0
  103. package/dist/resources/register.d.ts +12 -0
  104. package/dist/resources/register.d.ts.map +1 -0
  105. package/dist/resources/register.js +20 -0
  106. package/dist/resources/register.js.map +1 -0
  107. package/dist/resources/scheduled.resource.d.ts +9 -0
  108. package/dist/resources/scheduled.resource.d.ts.map +1 -0
  109. package/dist/resources/scheduled.resource.js +31 -0
  110. package/dist/resources/scheduled.resource.js.map +1 -0
  111. package/dist/resources/stats.resource.d.ts +10 -0
  112. package/dist/resources/stats.resource.d.ts.map +1 -0
  113. package/dist/resources/stats.resource.js +45 -0
  114. package/dist/resources/stats.resource.js.map +1 -0
  115. package/dist/resources/templates.resource.d.ts +9 -0
  116. package/dist/resources/templates.resource.d.ts.map +1 -0
  117. package/dist/resources/templates.resource.js +34 -0
  118. package/dist/resources/templates.resource.js.map +1 -0
  119. package/dist/resources/unread.resource.d.ts +11 -0
  120. package/dist/resources/unread.resource.d.ts.map +1 -0
  121. package/dist/resources/unread.resource.js +46 -0
  122. package/dist/resources/unread.resource.js.map +1 -0
  123. package/dist/safety/audit.d.ts +17 -0
  124. package/dist/safety/audit.d.ts.map +1 -0
  125. package/dist/safety/audit.js +50 -0
  126. package/dist/safety/audit.js.map +1 -0
  127. package/dist/safety/rate-limiter.d.ts +22 -0
  128. package/dist/safety/rate-limiter.d.ts.map +1 -0
  129. package/dist/safety/rate-limiter.js +52 -0
  130. package/dist/safety/rate-limiter.js.map +1 -0
  131. package/dist/safety/validation.d.ts +44 -0
  132. package/dist/safety/validation.d.ts.map +1 -0
  133. package/dist/safety/validation.js +113 -0
  134. package/dist/safety/validation.js.map +1 -0
  135. package/dist/server.d.ts +10 -0
  136. package/dist/server.d.ts.map +1 -0
  137. package/dist/server.js +25 -0
  138. package/dist/server.js.map +1 -0
  139. package/dist/services/calendar.service.d.ts +22 -0
  140. package/dist/services/calendar.service.d.ts.map +1 -0
  141. package/dist/services/calendar.service.js +115 -0
  142. package/dist/services/calendar.service.js.map +1 -0
  143. package/dist/services/event-bus.d.ts +28 -0
  144. package/dist/services/event-bus.d.ts.map +1 -0
  145. package/dist/services/event-bus.js +16 -0
  146. package/dist/services/event-bus.js.map +1 -0
  147. package/dist/services/hooks.service.d.ts +77 -0
  148. package/dist/services/hooks.service.d.ts.map +1 -0
  149. package/dist/services/hooks.service.js +498 -0
  150. package/dist/services/hooks.service.js.map +1 -0
  151. package/dist/services/imap.service.d.ts +133 -0
  152. package/dist/services/imap.service.d.ts.map +1 -0
  153. package/dist/services/imap.service.js +1393 -0
  154. package/dist/services/imap.service.js.map +1 -0
  155. package/dist/services/label-strategy.d.ts +20 -0
  156. package/dist/services/label-strategy.d.ts.map +1 -0
  157. package/dist/services/label-strategy.js +237 -0
  158. package/dist/services/label-strategy.js.map +1 -0
  159. package/dist/services/local-calendar.service.d.ts +126 -0
  160. package/dist/services/local-calendar.service.d.ts.map +1 -0
  161. package/dist/services/local-calendar.service.js +428 -0
  162. package/dist/services/local-calendar.service.js.map +1 -0
  163. package/dist/services/notifier.service.d.ts +69 -0
  164. package/dist/services/notifier.service.d.ts.map +1 -0
  165. package/dist/services/notifier.service.js +319 -0
  166. package/dist/services/notifier.service.js.map +1 -0
  167. package/dist/services/oauth.service.d.ts +47 -0
  168. package/dist/services/oauth.service.d.ts.map +1 -0
  169. package/dist/services/oauth.service.js +140 -0
  170. package/dist/services/oauth.service.js.map +1 -0
  171. package/dist/services/presets.d.ts +36 -0
  172. package/dist/services/presets.d.ts.map +1 -0
  173. package/dist/services/presets.js +173 -0
  174. package/dist/services/presets.js.map +1 -0
  175. package/dist/services/reminders.service.d.ts +63 -0
  176. package/dist/services/reminders.service.d.ts.map +1 -0
  177. package/dist/services/reminders.service.js +281 -0
  178. package/dist/services/reminders.service.js.map +1 -0
  179. package/dist/services/scheduler.service.d.ts +42 -0
  180. package/dist/services/scheduler.service.d.ts.map +1 -0
  181. package/dist/services/scheduler.service.js +260 -0
  182. package/dist/services/scheduler.service.js.map +1 -0
  183. package/dist/services/smtp.service.d.ts +40 -0
  184. package/dist/services/smtp.service.d.ts.map +1 -0
  185. package/dist/services/smtp.service.js +151 -0
  186. package/dist/services/smtp.service.js.map +1 -0
  187. package/dist/services/template.service.d.ts +33 -0
  188. package/dist/services/template.service.d.ts.map +1 -0
  189. package/dist/services/template.service.js +123 -0
  190. package/dist/services/template.service.js.map +1 -0
  191. package/dist/services/watcher.service.d.ts +36 -0
  192. package/dist/services/watcher.service.d.ts.map +1 -0
  193. package/dist/services/watcher.service.js +241 -0
  194. package/dist/services/watcher.service.js.map +1 -0
  195. package/dist/tools/accounts.tool.d.ts +7 -0
  196. package/dist/tools/accounts.tool.d.ts.map +1 -0
  197. package/dist/tools/accounts.tool.js +29 -0
  198. package/dist/tools/accounts.tool.js.map +1 -0
  199. package/dist/tools/analytics.tool.d.ts +9 -0
  200. package/dist/tools/analytics.tool.d.ts.map +1 -0
  201. package/dist/tools/analytics.tool.js +27 -0
  202. package/dist/tools/analytics.tool.js.map +1 -0
  203. package/dist/tools/attachments.tool.d.ts +7 -0
  204. package/dist/tools/attachments.tool.d.ts.map +1 -0
  205. package/dist/tools/attachments.tool.js +45 -0
  206. package/dist/tools/attachments.tool.js.map +1 -0
  207. package/dist/tools/bulk.tool.d.ts +7 -0
  208. package/dist/tools/bulk.tool.d.ts.map +1 -0
  209. package/dist/tools/bulk.tool.js +75 -0
  210. package/dist/tools/bulk.tool.js.map +1 -0
  211. package/dist/tools/calendar.tool.d.ts +19 -0
  212. package/dist/tools/calendar.tool.d.ts.map +1 -0
  213. package/dist/tools/calendar.tool.js +538 -0
  214. package/dist/tools/calendar.tool.js.map +1 -0
  215. package/dist/tools/contacts.tool.d.ts +7 -0
  216. package/dist/tools/contacts.tool.d.ts.map +1 -0
  217. package/dist/tools/contacts.tool.js +44 -0
  218. package/dist/tools/contacts.tool.js.map +1 -0
  219. package/dist/tools/drafts.tool.d.ts +8 -0
  220. package/dist/tools/drafts.tool.d.ts.map +1 -0
  221. package/dist/tools/drafts.tool.js +92 -0
  222. package/dist/tools/drafts.tool.js.map +1 -0
  223. package/dist/tools/emails.tool.d.ts +7 -0
  224. package/dist/tools/emails.tool.d.ts.map +1 -0
  225. package/dist/tools/emails.tool.js +400 -0
  226. package/dist/tools/emails.tool.js.map +1 -0
  227. package/dist/tools/folders.tool.d.ts +7 -0
  228. package/dist/tools/folders.tool.d.ts.map +1 -0
  229. package/dist/tools/folders.tool.js +111 -0
  230. package/dist/tools/folders.tool.js.map +1 -0
  231. package/dist/tools/health.tool.d.ts +10 -0
  232. package/dist/tools/health.tool.d.ts.map +1 -0
  233. package/dist/tools/health.tool.js +78 -0
  234. package/dist/tools/health.tool.js.map +1 -0
  235. package/dist/tools/label.tool.d.ts +11 -0
  236. package/dist/tools/label.tool.d.ts.map +1 -0
  237. package/dist/tools/label.tool.js +165 -0
  238. package/dist/tools/label.tool.js.map +1 -0
  239. package/dist/tools/locate.tool.d.ts +11 -0
  240. package/dist/tools/locate.tool.d.ts.map +1 -0
  241. package/dist/tools/locate.tool.js +59 -0
  242. package/dist/tools/locate.tool.js.map +1 -0
  243. package/dist/tools/mailboxes.tool.d.ts +7 -0
  244. package/dist/tools/mailboxes.tool.d.ts.map +1 -0
  245. package/dist/tools/mailboxes.tool.js +38 -0
  246. package/dist/tools/mailboxes.tool.js.map +1 -0
  247. package/dist/tools/manage.tool.d.ts +7 -0
  248. package/dist/tools/manage.tool.d.ts.map +1 -0
  249. package/dist/tools/manage.tool.js +125 -0
  250. package/dist/tools/manage.tool.js.map +1 -0
  251. package/dist/tools/register.d.ts +20 -0
  252. package/dist/tools/register.d.ts.map +1 -0
  253. package/dist/tools/register.js +53 -0
  254. package/dist/tools/register.js.map +1 -0
  255. package/dist/tools/scheduler.tool.d.ts +9 -0
  256. package/dist/tools/scheduler.tool.d.ts.map +1 -0
  257. package/dist/tools/scheduler.tool.js +104 -0
  258. package/dist/tools/scheduler.tool.js.map +1 -0
  259. package/dist/tools/send.tool.d.ts +7 -0
  260. package/dist/tools/send.tool.d.ts.map +1 -0
  261. package/dist/tools/send.tool.js +123 -0
  262. package/dist/tools/send.tool.js.map +1 -0
  263. package/dist/tools/templates.tool.d.ts +12 -0
  264. package/dist/tools/templates.tool.d.ts.map +1 -0
  265. package/dist/tools/templates.tool.js +140 -0
  266. package/dist/tools/templates.tool.js.map +1 -0
  267. package/dist/tools/thread.tool.d.ts +10 -0
  268. package/dist/tools/thread.tool.d.ts.map +1 -0
  269. package/dist/tools/thread.tool.js +146 -0
  270. package/dist/tools/thread.tool.js.map +1 -0
  271. package/dist/tools/watcher.tool.d.ts +9 -0
  272. package/dist/tools/watcher.tool.d.ts.map +1 -0
  273. package/dist/tools/watcher.tool.js +282 -0
  274. package/dist/tools/watcher.tool.js.map +1 -0
  275. package/dist/types/index.d.ts +271 -0
  276. package/dist/types/index.d.ts.map +1 -0
  277. package/dist/types/index.js +5 -0
  278. package/dist/types/index.js.map +1 -0
  279. package/dist/utils/calendar-notes.d.ts +31 -0
  280. package/dist/utils/calendar-notes.d.ts.map +1 -0
  281. package/dist/utils/calendar-notes.js +99 -0
  282. package/dist/utils/calendar-notes.js.map +1 -0
  283. package/dist/utils/calendar-state.d.ts +27 -0
  284. package/dist/utils/calendar-state.d.ts.map +1 -0
  285. package/dist/utils/calendar-state.js +85 -0
  286. package/dist/utils/calendar-state.js.map +1 -0
  287. package/dist/utils/conference-details.d.ts +12 -0
  288. package/dist/utils/conference-details.d.ts.map +1 -0
  289. package/dist/utils/conference-details.js +71 -0
  290. package/dist/utils/conference-details.js.map +1 -0
  291. package/dist/utils/meeting-url.d.ts +10 -0
  292. package/dist/utils/meeting-url.d.ts.map +1 -0
  293. package/dist/utils/meeting-url.js +30 -0
  294. package/dist/utils/meeting-url.js.map +1 -0
  295. package/package.json +108 -0
@@ -0,0 +1,111 @@
1
+ /**
2
+ * MCP tools: create_mailbox, rename_mailbox, delete_mailbox
3
+ */
4
+ import { z } from 'zod';
5
+ import audit from '../safety/audit.js';
6
+ export default function registerFolderTools(server, imapService) {
7
+ // ---------------------------------------------------------------------------
8
+ // create_mailbox
9
+ // ---------------------------------------------------------------------------
10
+ server.tool('create_mailbox', "Create a new mailbox (folder). Use '/' as separator for nested folders (e.g., 'Work/Projects'). Use list_mailboxes to see existing folders.", {
11
+ account: z.string().describe('Account name from list_accounts'),
12
+ path: z
13
+ .string()
14
+ .min(1)
15
+ .describe("Folder path to create (e.g., 'Archive/2026' or 'Projects')"),
16
+ }, { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, async ({ account, path: folderPath }) => {
17
+ try {
18
+ await imapService.createMailbox(account, folderPath);
19
+ await audit.log('create_mailbox', account, { path: folderPath }, 'ok');
20
+ return {
21
+ content: [
22
+ {
23
+ type: 'text',
24
+ text: `📁 Mailbox "${folderPath}" created.`,
25
+ },
26
+ ],
27
+ };
28
+ }
29
+ catch (err) {
30
+ const errMsg = err instanceof Error ? err.message : String(err);
31
+ await audit.log('create_mailbox', account, { path: folderPath }, 'error', errMsg);
32
+ return {
33
+ isError: true,
34
+ content: [
35
+ {
36
+ type: 'text',
37
+ text: `Failed to create mailbox: ${errMsg}`,
38
+ },
39
+ ],
40
+ };
41
+ }
42
+ });
43
+ // ---------------------------------------------------------------------------
44
+ // rename_mailbox
45
+ // ---------------------------------------------------------------------------
46
+ server.tool('rename_mailbox', 'Rename an existing mailbox (folder). Use list_mailboxes to see current folder paths.', {
47
+ account: z.string().describe('Account name from list_accounts'),
48
+ path: z.string().min(1).describe('Current folder path'),
49
+ new_path: z.string().min(1).describe('New folder path'),
50
+ }, { readOnlyHint: false, destructiveHint: false }, async ({ account, path: folderPath, new_path: newPath }) => {
51
+ try {
52
+ await imapService.renameMailbox(account, folderPath, newPath);
53
+ await audit.log('rename_mailbox', account, { path: folderPath, new_path: newPath }, 'ok');
54
+ return {
55
+ content: [
56
+ {
57
+ type: 'text',
58
+ text: `📁 Mailbox renamed from "${folderPath}" to "${newPath}".`,
59
+ },
60
+ ],
61
+ };
62
+ }
63
+ catch (err) {
64
+ const errMsg = err instanceof Error ? err.message : String(err);
65
+ await audit.log('rename_mailbox', account, { path: folderPath, new_path: newPath }, 'error', errMsg);
66
+ return {
67
+ isError: true,
68
+ content: [
69
+ {
70
+ type: 'text',
71
+ text: `Failed to rename mailbox: ${errMsg}`,
72
+ },
73
+ ],
74
+ };
75
+ }
76
+ });
77
+ // ---------------------------------------------------------------------------
78
+ // delete_mailbox
79
+ // ---------------------------------------------------------------------------
80
+ server.tool('delete_mailbox', '⚠️ DESTRUCTIVE: Permanently delete a mailbox and ALL its contents. This cannot be undone. Use list_mailboxes to verify the folder path.', {
81
+ account: z.string().describe('Account name from list_accounts'),
82
+ path: z.string().min(1).describe('Folder path to delete (⚠️ all emails inside will be lost)'),
83
+ }, { readOnlyHint: false, destructiveHint: true }, async ({ account, path: folderPath }) => {
84
+ try {
85
+ await imapService.deleteMailbox(account, folderPath);
86
+ await audit.log('delete_mailbox', account, { path: folderPath }, 'ok');
87
+ return {
88
+ content: [
89
+ {
90
+ type: 'text',
91
+ text: `⚠️ Mailbox "${folderPath}" permanently deleted.`,
92
+ },
93
+ ],
94
+ };
95
+ }
96
+ catch (err) {
97
+ const errMsg = err instanceof Error ? err.message : String(err);
98
+ await audit.log('delete_mailbox', account, { path: folderPath }, 'error', errMsg);
99
+ return {
100
+ isError: true,
101
+ content: [
102
+ {
103
+ type: 'text',
104
+ text: `Failed to delete mailbox: ${errMsg}`,
105
+ },
106
+ ],
107
+ };
108
+ }
109
+ });
110
+ }
111
+ //# sourceMappingURL=folders.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folders.tool.js","sourceRoot":"","sources":["../../src/tools/folders.tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,MAAM,oBAAoB,CAAC;AAIvC,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,MAAiB,EAAE,WAAwB;IACrF,8EAA8E;IAC9E,iBAAiB;IACjB,8EAA8E;IAC9E,MAAM,CAAC,IAAI,CACT,gBAAgB,EAChB,6IAA6I,EAC7I;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;QAC/D,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CAAC,4DAA4D,CAAC;KAC1E,EACD,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,EACrE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,WAAW,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACrD,MAAM,KAAK,CAAC,GAAG,CAAC,gBAAgB,EAAE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AAE,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,WAAW,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACrD,MAAM,KAAK,CAAC,GAAG,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC;YACvE,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,eAAe,UAAU,wBAAwB;qBACxD;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChE,MAAM,KAAK,CAAC,GAAG,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAClF,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,6BAA6B,MAAM,EAAE;qBAC5C;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * MCP Tool: check_health
3
+ *
4
+ * Connection health diagnostics for email accounts.
5
+ */
6
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
7
+ import type ConnectionManager from '../connections/manager.js';
8
+ import type ImapService from '../services/imap.service.js';
9
+ export default function registerHealthTools(server: McpServer, connections: ConnectionManager, imapService: ImapService): void;
10
+ //# sourceMappingURL=health.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.tool.d.ts","sourceRoot":"","sources":["../../src/tools/health.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,KAAK,iBAAiB,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,iBAAiB,EAC9B,WAAW,EAAE,WAAW,GACvB,IAAI,CAqFN"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * MCP Tool: check_health
3
+ *
4
+ * Connection health diagnostics for email accounts.
5
+ */
6
+ import { z } from 'zod';
7
+ export default function registerHealthTools(server, connections, imapService) {
8
+ server.tool('check_health', 'Check connection health, quota, and capabilities for email accounts. Useful for diagnosing issues.', {
9
+ account: z.string().optional().describe('Account name (checks all accounts if omitted)'),
10
+ }, { readOnlyHint: true, destructiveHint: false }, async ({ account }) => {
11
+ const names = account ? [account] : connections.getAccountNames();
12
+ const results = await Promise.all(names.map(async (name) => {
13
+ const cfg = connections.getAccount(name);
14
+ const result = {
15
+ name,
16
+ auth_type: cfg.oauth2 ? 'oauth2' : 'password',
17
+ };
18
+ // IMAP health
19
+ try {
20
+ const start = Date.now();
21
+ await connections.getImapClient(name);
22
+ const latency = Date.now() - start;
23
+ const capabilities = await imapService.getCapabilities(name);
24
+ const quota = await imapService.getQuota(name);
25
+ result.imap = {
26
+ connected: true,
27
+ latency_ms: latency,
28
+ host: cfg.imap.host,
29
+ capabilities: capabilities.slice(0, 20),
30
+ tls: cfg.imap.tls,
31
+ };
32
+ if (quota) {
33
+ result.quota = {
34
+ used_mb: quota.usedMb,
35
+ total_mb: quota.totalMb,
36
+ percentage: quota.percentage,
37
+ };
38
+ }
39
+ }
40
+ catch (err) {
41
+ result.imap = {
42
+ connected: false,
43
+ error: err instanceof Error ? err.message : String(err),
44
+ host: cfg.imap.host,
45
+ };
46
+ }
47
+ // SMTP health
48
+ try {
49
+ const start = Date.now();
50
+ await connections.verifySmtpTransport(name);
51
+ const latency = Date.now() - start;
52
+ result.smtp = {
53
+ connected: true,
54
+ latency_ms: latency,
55
+ host: cfg.smtp.host,
56
+ tls: cfg.smtp.tls,
57
+ };
58
+ }
59
+ catch (err) {
60
+ result.smtp = {
61
+ connected: false,
62
+ error: err instanceof Error ? err.message : String(err),
63
+ host: cfg.smtp.host,
64
+ };
65
+ }
66
+ return result;
67
+ }));
68
+ return {
69
+ content: [
70
+ {
71
+ type: 'text',
72
+ text: JSON.stringify({ accounts: results }, null, 2),
73
+ },
74
+ ],
75
+ };
76
+ });
77
+ }
78
+ //# sourceMappingURL=health.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.tool.js","sourceRoot":"","sources":["../../src/tools/health.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,MAAiB,EACjB,WAA8B,EAC9B,WAAwB;IAExB,MAAM,CAAC,IAAI,CACT,cAAc,EACd,oGAAoG,EACpG;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;KACzF,EACD,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,EAC9C,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACpB,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;QAElE,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACvB,MAAM,GAAG,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YACzC,MAAM,MAAM,GA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;YACd,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBACzB,MAAM,WAAW,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;gBAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;gBAEnC,MAAM,CAAC,IAAI,GAAG;oBACZ,SAAS,EAAE,IAAI;oBACf,UAAU,EAAE,OAAO;oBACnB,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI;oBACnB,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG;iBAClB,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,GAAG;oBACZ,SAAS,EAAE,KAAK;oBAChB,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;oBACvD,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI;iBACpB,CAAC;YACJ,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CACH,CAAC;QAEF,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;iBACrD;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * MCP tools: list_labels, add_label, remove_label, create_label, delete_label
3
+ *
4
+ * Provider-aware label management. Automatically detects whether the account
5
+ * uses ProtonMail (folder-based labels), Gmail (X-GM-LABELS), or standard
6
+ * IMAP keywords, and applies the correct strategy.
7
+ */
8
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
9
+ import type ImapService from '../services/imap.service.js';
10
+ export default function registerLabelTools(server: McpServer, imapService: ImapService): void;
11
+ //# sourceMappingURL=label.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label.tool.d.ts","sourceRoot":"","sources":["../../src/tools/label.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAyL5F"}
@@ -0,0 +1,165 @@
1
+ /**
2
+ * MCP tools: list_labels, add_label, remove_label, create_label, delete_label
3
+ *
4
+ * Provider-aware label management. Automatically detects whether the account
5
+ * uses ProtonMail (folder-based labels), Gmail (X-GM-LABELS), or standard
6
+ * IMAP keywords, and applies the correct strategy.
7
+ */
8
+ import { z } from 'zod';
9
+ import audit from '../safety/audit.js';
10
+ import { validateLabelName } from '../safety/validation.js';
11
+ export default function registerLabelTools(server, imapService) {
12
+ // ---------------------------------------------------------------------------
13
+ // list_labels
14
+ // ---------------------------------------------------------------------------
15
+ server.tool('list_labels', 'List available labels for an email account. ' +
16
+ 'Auto-detects the label system: ProtonMail folder-labels, Gmail X-GM-LABELS, or IMAP keywords. ' +
17
+ 'ProtonMail note: labels are represented as IMAP folders under the Labels/ prefix. ' +
18
+ 'Use list_emails with mailbox="Labels/<name>" to find emails tagged with a ProtonMail label.', {
19
+ account: z.string().describe('Account name from list_accounts'),
20
+ }, { readOnlyHint: true }, async ({ account }) => {
21
+ try {
22
+ const labels = await imapService.listLabels(account);
23
+ if (labels.length === 0) {
24
+ return {
25
+ content: [
26
+ {
27
+ type: 'text',
28
+ text: 'No labels found. Use create_label to create one.',
29
+ },
30
+ ],
31
+ };
32
+ }
33
+ const { strategy } = labels[0];
34
+ const lines = [
35
+ `🏷️ ${labels.length} label(s) — strategy: ${strategy}`,
36
+ '',
37
+ ...labels.map((l) => ` • ${l.name}${l.path ? ` (${l.path})` : ''}`),
38
+ ];
39
+ return {
40
+ content: [{ type: 'text', text: lines.join('\n') }],
41
+ };
42
+ }
43
+ catch (err) {
44
+ const errMsg = err instanceof Error ? err.message : String(err);
45
+ return {
46
+ isError: true,
47
+ content: [{ type: 'text', text: `Failed to list labels: ${errMsg}` }],
48
+ };
49
+ }
50
+ });
51
+ // ---------------------------------------------------------------------------
52
+ // add_label
53
+ // ---------------------------------------------------------------------------
54
+ server.tool('add_label', 'Add a label to an email. ' +
55
+ 'For ProtonMail, this copies the email into the corresponding Labels/<name> folder. ' +
56
+ 'For Gmail and standard IMAP, this sets a keyword flag on the message.', {
57
+ account: z.string().describe('Account name from list_accounts'),
58
+ emailId: z.string().describe('Email ID (UID) from list_emails'),
59
+ mailbox: z.string().describe('Mailbox containing the email (must be a real folder)'),
60
+ label: z.string().describe('Label name to add (e.g., "Important", "Project-X")'),
61
+ }, { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, async ({ account, emailId, mailbox, label }) => {
62
+ try {
63
+ const cleanLabel = validateLabelName(label);
64
+ await imapService.addLabel(account, emailId, mailbox, cleanLabel);
65
+ await audit.log('add_label', account, { emailId, mailbox, label: cleanLabel }, 'ok');
66
+ return {
67
+ content: [
68
+ { type: 'text', text: `🏷️ Label "${label}" added to email ${emailId}.` },
69
+ ],
70
+ };
71
+ }
72
+ catch (err) {
73
+ const errMsg = err instanceof Error ? err.message : String(err);
74
+ await audit.log('add_label', account, { emailId, mailbox, label }, 'error', errMsg);
75
+ return {
76
+ isError: true,
77
+ content: [{ type: 'text', text: `Failed to add label: ${errMsg}` }],
78
+ };
79
+ }
80
+ });
81
+ // ---------------------------------------------------------------------------
82
+ // remove_label
83
+ // ---------------------------------------------------------------------------
84
+ server.tool('remove_label', 'Remove a label from an email. For ProtonMail, this removes the email from the label folder. ' +
85
+ 'For Gmail and standard IMAP, this removes a keyword flag.', {
86
+ account: z.string().describe('Account name from list_accounts'),
87
+ emailId: z.string().describe('Email ID (UID) from list_emails'),
88
+ mailbox: z.string().describe('Mailbox containing the email (must be a real folder)'),
89
+ label: z.string().describe('Label name to remove'),
90
+ }, { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, async ({ account, emailId, mailbox, label }) => {
91
+ try {
92
+ const cleanLabel = validateLabelName(label);
93
+ await imapService.removeLabel(account, emailId, mailbox, cleanLabel);
94
+ await audit.log('remove_label', account, { emailId, mailbox, label: cleanLabel }, 'ok');
95
+ return {
96
+ content: [
97
+ {
98
+ type: 'text',
99
+ text: `🏷️ Label "${label}" removed from email ${emailId}.`,
100
+ },
101
+ ],
102
+ };
103
+ }
104
+ catch (err) {
105
+ const errMsg = err instanceof Error ? err.message : String(err);
106
+ await audit.log('remove_label', account, { emailId, mailbox, label }, 'error', errMsg);
107
+ return {
108
+ isError: true,
109
+ content: [{ type: 'text', text: `Failed to remove label: ${errMsg}` }],
110
+ };
111
+ }
112
+ });
113
+ // ---------------------------------------------------------------------------
114
+ // create_label
115
+ // ---------------------------------------------------------------------------
116
+ server.tool('create_label', 'Create a new label. For ProtonMail, creates a folder under Labels/. ' +
117
+ 'For standard IMAP keywords, labels are auto-created on first use — this is a no-op.', {
118
+ account: z.string().describe('Account name from list_accounts'),
119
+ name: z
120
+ .string()
121
+ .describe('Label name (e.g., "Project-X"). For nested labels use "/" separator (e.g., "Work/Urgent").'),
122
+ }, { readOnlyHint: false, destructiveHint: false }, async ({ account, name }) => {
123
+ try {
124
+ const cleanName = validateLabelName(name);
125
+ await imapService.createLabel(account, cleanName);
126
+ await audit.log('create_label', account, { name: cleanName }, 'ok');
127
+ return {
128
+ content: [{ type: 'text', text: `🏷️ Label "${name}" created.` }],
129
+ };
130
+ }
131
+ catch (err) {
132
+ const errMsg = err instanceof Error ? err.message : String(err);
133
+ await audit.log('create_label', account, { name }, 'error', errMsg);
134
+ return {
135
+ isError: true,
136
+ content: [{ type: 'text', text: `Failed to create label: ${errMsg}` }],
137
+ };
138
+ }
139
+ });
140
+ // ---------------------------------------------------------------------------
141
+ // delete_label
142
+ // ---------------------------------------------------------------------------
143
+ server.tool('delete_label', 'Delete a label. For ProtonMail, deletes the label folder. ' +
144
+ 'For standard IMAP keywords, labels cannot be deleted server-wide — use remove_label on individual emails.', {
145
+ account: z.string().describe('Account name from list_accounts'),
146
+ name: z.string().describe('Label name to delete'),
147
+ }, { readOnlyHint: false, destructiveHint: true }, async ({ account, name }) => {
148
+ try {
149
+ await imapService.deleteLabel(account, name);
150
+ await audit.log('delete_label', account, { name }, 'ok');
151
+ return {
152
+ content: [{ type: 'text', text: `🏷️ Label "${name}" deleted.` }],
153
+ };
154
+ }
155
+ catch (err) {
156
+ const errMsg = err instanceof Error ? err.message : String(err);
157
+ await audit.log('delete_label', account, { name }, 'error', errMsg);
158
+ return {
159
+ isError: true,
160
+ content: [{ type: 'text', text: `Failed to delete label: ${errMsg}` }],
161
+ };
162
+ }
163
+ });
164
+ }
165
+ //# sourceMappingURL=label.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label.tool.js","sourceRoot":"","sources":["../../src/tools/label.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,MAAM,oBAAoB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,MAAiB,EAAE,WAAwB;IACpF,8EAA8E;IAC9E,cAAc;IACd,8EAA8E;IAC9E,MAAM,CAAC,IAAI,CACT,aAAa,EACb,8CAA8C;QAC5C,gGAAgG;QAChG,oFAAoF;QACpF,6FAA6F,EAC/F;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;KAChE,EACD,EAAE,YAAY,EAAE,IAAI,EAAE,EACtB,KAAK,EAAE,EAAE,OAAO,EAAE,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,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChE,MAAM,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YACpE,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,2BAA2B,MAAM,EAAE,EAAE,CAAC;aAChF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * MCP tool: find_email_folder
3
+ *
4
+ * Locates the real mailbox folder(s) containing an email.
5
+ * Essential when working with virtual folders like "All Mail" or "Starred",
6
+ * which don't support IMAP MOVE operations.
7
+ */
8
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
9
+ import type ImapService from '../services/imap.service.js';
10
+ export default function registerLocateTools(server: McpServer, imapService: ImapService): void;
11
+ //# sourceMappingURL=locate.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locate.tool.d.ts","sourceRoot":"","sources":["../../src/tools/locate.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CA6D7F"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * MCP tool: find_email_folder
3
+ *
4
+ * Locates the real mailbox folder(s) containing an email.
5
+ * Essential when working with virtual folders like "All Mail" or "Starred",
6
+ * which don't support IMAP MOVE operations.
7
+ */
8
+ import { z } from 'zod';
9
+ export default function registerLocateTools(server, imapService) {
10
+ server.tool('find_email_folder', 'Find which real mailbox folder(s) an email belongs to. ' +
11
+ 'Required before move_email or delete_email when the email was found in a virtual folder ' +
12
+ '(e.g., "All Mail", "Starred"). Returns the real folder path to use as sourceMailbox.', {
13
+ account: z.string().describe('Account name from list_accounts'),
14
+ emailId: z.string().describe('Email ID (UID) from list_emails'),
15
+ sourceMailbox: z
16
+ .string()
17
+ .default('INBOX')
18
+ .describe('Mailbox where the email is currently visible (e.g., "All Mail")'),
19
+ }, { readOnlyHint: true }, async ({ account, emailId, sourceMailbox }) => {
20
+ try {
21
+ const { folders, messageId } = await imapService.findEmailFolder(account, emailId, sourceMailbox);
22
+ if (folders.length === 0) {
23
+ return {
24
+ content: [
25
+ {
26
+ type: 'text',
27
+ text: `No real folder found for email ${emailId}. It may only exist in virtual folders.`,
28
+ },
29
+ ],
30
+ };
31
+ }
32
+ const lines = [
33
+ `📁 Email ${emailId} found in ${folders.length} folder(s):`,
34
+ ...folders.map((f) => ` • ${f}`),
35
+ '',
36
+ `Use the first folder as sourceMailbox for move_email or delete_email.`,
37
+ ];
38
+ if (messageId) {
39
+ lines.push(`Message-ID: ${messageId}`);
40
+ }
41
+ return {
42
+ content: [{ type: 'text', text: lines.join('\n') }],
43
+ };
44
+ }
45
+ catch (err) {
46
+ const errMsg = err instanceof Error ? err.message : String(err);
47
+ return {
48
+ isError: true,
49
+ content: [
50
+ {
51
+ type: 'text',
52
+ text: `Failed to locate email: ${errMsg}`,
53
+ },
54
+ ],
55
+ };
56
+ }
57
+ });
58
+ }
59
+ //# sourceMappingURL=locate.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locate.tool.js","sourceRoot":"","sources":["../../src/tools/locate.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,MAAiB,EAAE,WAAw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AC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChE,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,2BAA2B,MAAM,EAAE;qBAC1C;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * MCP tool: list_mailboxes
3
+ */
4
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
+ import type ImapService from '../services/imap.service.js';
6
+ export default function registerMailboxesTools(server: McpServer, imapService: ImapService): void;
7
+ //# sourceMappingURL=mailboxes.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mailboxes.tool.d.ts","sourceRoot":"","sources":["../../src/tools/mailboxes.tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAuChG"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * MCP tool: list_mailboxes
3
+ */
4
+ import { z } from 'zod';
5
+ export default function registerMailboxesTools(server, imapService) {
6
+ server.tool('list_mailboxes', 'List all mailbox folders for an account with unread counts and special-use flags. Use list_accounts first to get the account name.', {
7
+ account: z.string().describe('Account name from list_accounts'),
8
+ }, { readOnlyHint: true, destructiveHint: false }, async ({ account }) => {
9
+ try {
10
+ const mailboxes = await imapService.listMailboxes(account);
11
+ const lines = mailboxes.map((mb) => {
12
+ const badge = mb.unseenMessages > 0 ? ` (${mb.unseenMessages} unread)` : '';
13
+ const special = mb.specialUse ? ` [${mb.specialUse}]` : '';
14
+ return `• ${mb.path}${special} — ${mb.totalMessages} messages${badge}`;
15
+ });
16
+ return {
17
+ content: [
18
+ {
19
+ type: 'text',
20
+ text: lines.join('\n') || 'No mailboxes found.',
21
+ },
22
+ ],
23
+ };
24
+ }
25
+ catch (err) {
26
+ return {
27
+ isError: true,
28
+ content: [
29
+ {
30
+ type: 'text',
31
+ text: `Failed to list mailboxes: ${err instanceof Error ? err.message : String(err)}`,
32
+ },
33
+ ],
34
+ };
35
+ }
36
+ });
37
+ }
38
+ //# sourceMappingURL=mailboxes.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mailboxes.tool.js","sourceRoot":"","sources":["../../src/tools/mailboxes.tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,MAAiB,EAAE,WAAwB;IACxF,MAAM,CAAC,IAAI,CACT,gBAAgB,EAChB,oIAAoI,EACpI;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;KAChE,EACD,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,EAC9C,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACpB,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAE3D,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;gBACjC,MAAM,KAAK,GAAG,EAAE,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,cAAc,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5E,MAAM,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3D,OAAO,KAAK,EAAE,CAAC,IAAI,GAAG,OAAO,MAAM,EAAE,CAAC,aAAa,YAAY,KAAK,EAAE,CAAC;YACzE,CAAC,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,qBAAqB;qBAChD;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,6BAA6B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;qBACtF;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * MCP tools: move_email, delete_email, mark_email
3
+ */
4
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
+ import type ImapService from '../services/imap.service.js';
6
+ export default function registerManageTools(server: McpServer, imapService: ImapService): void;
7
+ //# sourceMappingURL=manage.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manage.tool.d.ts","sourceRoot":"","sources":["../../src/tools/manage.tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAiJ7F"}