@rndmjoker/proton-mcp 0.4.13 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +138 -21
  2. package/dist/browser/channel.d.ts +76 -0
  3. package/dist/browser/channel.js +162 -0
  4. package/dist/browser/channel.js.map +1 -0
  5. package/dist/browser/client.d.ts +50 -0
  6. package/dist/browser/client.js +284 -0
  7. package/dist/browser/client.js.map +1 -0
  8. package/dist/browser/connector.d.ts +15 -0
  9. package/dist/browser/connector.js +26 -0
  10. package/dist/browser/connector.js.map +1 -0
  11. package/dist/browser/host.d.ts +50 -0
  12. package/dist/browser/host.js +258 -0
  13. package/dist/browser/host.js.map +1 -0
  14. package/dist/browser/messages.d.ts +163 -0
  15. package/dist/browser/messages.js +338 -0
  16. package/dist/browser/messages.js.map +1 -0
  17. package/dist/browser/paths.d.ts +51 -0
  18. package/dist/browser/paths.js +92 -0
  19. package/dist/browser/paths.js.map +1 -0
  20. package/dist/browser/setup.d.ts +42 -0
  21. package/dist/browser/setup.js +170 -0
  22. package/dist/browser/setup.js.map +1 -0
  23. package/dist/filters/order.d.ts +66 -0
  24. package/dist/filters/order.js +108 -0
  25. package/dist/filters/order.js.map +1 -0
  26. package/dist/filters/sieve.d.ts +184 -0
  27. package/dist/filters/sieve.js +1312 -0
  28. package/dist/filters/sieve.js.map +1 -0
  29. package/dist/instances.d.ts +58 -0
  30. package/dist/instances.js +145 -0
  31. package/dist/instances.js.map +1 -0
  32. package/dist/mail/compose.d.ts +10 -0
  33. package/dist/mail/compose.js.map +1 -1
  34. package/dist/mail/record.d.ts +36 -0
  35. package/dist/mail/record.js +74 -0
  36. package/dist/mail/record.js.map +1 -0
  37. package/dist/permissions.d.ts +139 -0
  38. package/dist/permissions.js +355 -0
  39. package/dist/permissions.js.map +1 -0
  40. package/dist/server.js +330 -16
  41. package/dist/server.js.map +1 -1
  42. package/dist/session.d.ts +12 -0
  43. package/dist/session.js +23 -0
  44. package/dist/session.js.map +1 -1
  45. package/dist/settings.d.ts +81 -11
  46. package/dist/settings.js +160 -25
  47. package/dist/settings.js.map +1 -1
  48. package/dist/tools/confirm.d.ts +4 -2
  49. package/dist/tools/confirm.js +12 -3
  50. package/dist/tools/confirm.js.map +1 -1
  51. package/dist/tools/failures.d.ts +6 -8
  52. package/dist/tools/failures.js +36 -17
  53. package/dist/tools/failures.js.map +1 -1
  54. package/dist/tools/filter-tools.d.ts +82 -0
  55. package/dist/tools/filter-tools.js +729 -0
  56. package/dist/tools/filter-tools.js.map +1 -0
  57. package/dist/tools/filters.d.ts +8 -1
  58. package/dist/tools/filters.js +24 -12
  59. package/dist/tools/filters.js.map +1 -1
  60. package/dist/tools/format.d.ts +15 -0
  61. package/dist/tools/format.js +4 -3
  62. package/dist/tools/format.js.map +1 -1
  63. package/dist/tools/guidance.js +12 -7
  64. package/dist/tools/guidance.js.map +1 -1
  65. package/dist/tools/interface.d.ts +20 -6
  66. package/dist/tools/interface.js +40 -16
  67. package/dist/tools/interface.js.map +1 -1
  68. package/dist/tools/send.d.ts +9 -0
  69. package/dist/tools/send.js +51 -9
  70. package/dist/tools/send.js.map +1 -1
  71. package/dist/tools/sign-in-required.d.ts +15 -2
  72. package/dist/tools/sign-in-required.js +30 -2
  73. package/dist/tools/sign-in-required.js.map +1 -1
  74. package/dist/web/layout.d.ts +12 -5
  75. package/dist/web/layout.js +32 -9
  76. package/dist/web/layout.js.map +1 -1
  77. package/dist/web/pages.d.ts +4 -2
  78. package/dist/web/pages.js +10 -9
  79. package/dist/web/pages.js.map +1 -1
  80. package/dist/web/pending.d.ts +9 -6
  81. package/dist/web/pending.js +9 -7
  82. package/dist/web/pending.js.map +1 -1
  83. package/dist/web/preview-server.d.ts +33 -0
  84. package/dist/web/preview-server.js +102 -0
  85. package/dist/web/preview-server.js.map +1 -0
  86. package/dist/web/sections.d.ts +86 -1
  87. package/dist/web/sections.js +290 -7
  88. package/dist/web/sections.js.map +1 -1
  89. package/dist/web/security.d.ts +48 -13
  90. package/dist/web/security.js +68 -16
  91. package/dist/web/security.js.map +1 -1
  92. package/dist/web/server.d.ts +81 -24
  93. package/dist/web/server.js +478 -117
  94. package/dist/web/server.js.map +1 -1
  95. package/package.json +1 -1
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Tools: list_filters, get_filters, propose_filter, apply_filter,
3
+ * reorder_filters, delete_filter and set_filter_status (#59)
4
+ *
5
+ * Proton Mail filters live behind an interface Proton has not opened to other
6
+ * programs, and the Bridge does not carry them. So these tools go through the
7
+ * user's own browser: the extension Proton MCP Helper does the work in the
8
+ * Proton page the user is signed in to, and a connector Chrome starts carries
9
+ * the requests from here to there. This server never holds a Proton session
10
+ * or password.
11
+ *
12
+ * Reading comes in two steps, decided by Tobi on 06.11.2026 after a real
13
+ * account held 96 filters, some 82,000 characters at once: list_filters gives
14
+ * the names, get_filters one or several filters in full.
15
+ *
16
+ * Proposing is held to the same rules in two places, here and again in the
17
+ * extension (src/filters/sieve.ts): Proton's spam guard first, then filing and
18
+ * the read and star flags, and beyond that only what the user allowed, one
19
+ * action at a time, on the Permissions page and again in the popup of the
20
+ * extension (Tobi, 06.11.2026: the user decides, and the settings are where).
21
+ * Nothing that could make the confirmation read differently from what runs
22
+ * is taken, whatever is allowed. Deleting a filter and switching one on or off
23
+ * are tools of their own, off until the user switches them on.
24
+ *
25
+ * By default the user confirms every change in a window of the extension,
26
+ * which shows the whole script and, for a change, the difference to the
27
+ * current one. That window belongs to the extension, not to the Proton page;
28
+ * measured on 06.11.2026, a browser tool an assistant drives does not reach
29
+ * it. Each call returns before the user decides, as Tobi chose on 05.11.2026:
30
+ * a client waiting on a person can run into its own time limit, and
31
+ * list_filters shows the outcome either way. The user can let each tool act on
32
+ * its own on the Permissions page, like the sending tools; the rules above
33
+ * hold regardless.
34
+ *
35
+ * Applying runs a saved filter over the mail that is already there, as
36
+ * Proton's settings do with "Apply filter to existing emails". Only a filter
37
+ * that passes the rules can be applied by an assistant, since one with discard
38
+ * would delete the existing mail it matches.
39
+ *
40
+ * Moving changes the order Proton runs filters in. Every filter runs on each
41
+ * incoming message; when several file it into folders, the last one wins. So
42
+ * a move can change where mail ends up, and the answer names the filters a
43
+ * moved one passes, warning where one of them does something an assistant may
44
+ * not set up.
45
+ *
46
+ * Applying takes time: on a large mailbox a run can take hours, and while it
47
+ * runs Proton applies no other filter. So the extension keeps an application
48
+ * in its queue until Proton takes it, for as long as Chrome stays open, rather
49
+ * than failing (Tobi, 06.11.2026); saving and moving go through meanwhile.
50
+ * list_filters shows what waits.
51
+ *
52
+ * Every tool first makes sure the Proton page belongs to the account this
53
+ * server is signed in to, so a filter cannot land in a second account that
54
+ * happens to be open in the same browser.
55
+ */
56
+ import type { McpServer } from '@modelcontextprotocol/server';
57
+ import type { BridgeCredentials } from '../config.js';
58
+ import type { Permissions } from '../permissions.js';
59
+ import type { BrowserRequest, BrowserResponse, ProtonFilter, QueuedAction, RecentChange } from '../browser/messages.js';
60
+ import { type Unlockable } from '../filters/sieve.js';
61
+ export interface FilterToolDependencies {
62
+ getCredentials: () => Promise<BridgeCredentials | undefined>;
63
+ permissions?: Permissions;
64
+ /** Replaced in tests. */
65
+ ask?: (request: BrowserRequest) => Promise<BrowserResponse>;
66
+ }
67
+ /** The most filters get_filters returns in one call. */
68
+ export declare const MAX_GET = 20;
69
+ /** The most characters of scripts get_filters returns in one call; the rest is named, not dropped. */
70
+ export declare const GET_BUDGET = 60000;
71
+ export declare const LIST_DESCRIPTION: string;
72
+ export declare const GET_DESCRIPTION: string;
73
+ export declare const PROPOSE_DESCRIPTION: string;
74
+ export declare const APPLY_DESCRIPTION: string;
75
+ export declare const DELETE_DESCRIPTION: string;
76
+ export declare const STATUS_DESCRIPTION: string;
77
+ export declare const REORDER_DESCRIPTION: string;
78
+ export declare function formatNames(filters: ProtonFilter[], queue?: QueuedAction[], recent?: RecentChange[], unlocked?: ReadonlySet<Unlockable>): string;
79
+ export declare function formatFull(filters: ProtonFilter[], ids: string[], allowed?: ReadonlySet<Unlockable>): string;
80
+ export declare function registerBrowserFilterTools(server: McpServer, deps: FilterToolDependencies): void;
81
+ /** Which filter moves where, which ones it passes, and where that touches something an assistant may not set up. */
82
+ export declare function describeMoves(before: string[], after: string[], byId: Map<string, ProtonFilter>, ids: string[]): string;