emailengine-app 2.80.0 → 2.81.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 (178) hide show
  1. package/.dockerignore +44 -0
  2. package/.github/docker-smoke-test.sh +16 -0
  3. package/.github/workflows/deploy.yml +4 -0
  4. package/.github/workflows/release.yaml +4 -0
  5. package/.github/workflows/test.yml +2 -0
  6. package/.release-please-manifest.json +1 -1
  7. package/CHANGELOG.md +56 -0
  8. package/Dockerfile +17 -9
  9. package/README.md +6 -0
  10. package/data/google-crawlers.json +1 -1
  11. package/docker-compose.yml +7 -1
  12. package/lib/api-routes/account-routes.js +239 -73
  13. package/lib/api-routes/blocklist-routes.js +24 -0
  14. package/lib/api-routes/delivery-test-routes.js +6 -0
  15. package/lib/api-routes/gateway-routes.js +30 -0
  16. package/lib/api-routes/license-routes.js +10 -0
  17. package/lib/api-routes/mcp-oauth-routes.js +3 -3
  18. package/lib/api-routes/mcp-routes.js +39 -21
  19. package/lib/api-routes/oauth2-app-routes.js +38 -1
  20. package/lib/api-routes/outbox-routes.js +6 -0
  21. package/lib/api-routes/permission-map.js +212 -42
  22. package/lib/api-routes/pubsub-routes.js +8 -0
  23. package/lib/api-routes/route-helpers.js +58 -11
  24. package/lib/api-routes/settings-routes.js +50 -4
  25. package/lib/api-routes/stats-routes.js +6 -0
  26. package/lib/api-routes/template-routes.js +21 -0
  27. package/lib/api-routes/token-routes.js +34 -2
  28. package/lib/api-routes/webhook-route-routes.js +13 -0
  29. package/lib/autodetect-imap-settings.js +4 -4
  30. package/lib/email-client/base-client.js +6 -3
  31. package/lib/email-client/credential-errors.js +4 -0
  32. package/lib/email-client/imap/login-failure.js +52 -0
  33. package/lib/email-client/imap/subconnection.js +2 -1
  34. package/lib/email-client/imap-client.js +3 -6
  35. package/lib/enum-descriptions.js +12 -2
  36. package/lib/imapproxy/imap-server.js +1 -1
  37. package/lib/mcp/oauth.js +46 -8
  38. package/lib/mcp/protocol.js +78 -35
  39. package/lib/mcp/tools.js +53 -17
  40. package/lib/privileged-settings.js +147 -0
  41. package/lib/schemas.js +60 -16
  42. package/lib/sentry.js +13 -2
  43. package/lib/settings.js +13 -0
  44. package/lib/tls/catalog.js +428 -0
  45. package/lib/tls/context.js +87 -161
  46. package/lib/tls/listeners.js +62 -0
  47. package/lib/tls/provision.js +1 -1
  48. package/lib/tls/status.js +128 -79
  49. package/lib/tls/store.js +3 -2
  50. package/lib/token-permission-view.js +253 -102
  51. package/lib/token-permissions.js +176 -26
  52. package/lib/tokens.js +7 -6
  53. package/lib/tools.js +5 -3
  54. package/lib/ui-routes/account-routes.js +195 -61
  55. package/lib/ui-routes/admin-config-routes.js +41 -21
  56. package/lib/ui-routes/admin-entities-routes.js +32 -22
  57. package/lib/ui-routes/mcp-consent-routes.js +72 -31
  58. package/lib/ui-routes/tls-config-routes.js +121 -74
  59. package/package.json +16 -16
  60. package/sbom.json +1 -1
  61. package/server.js +7 -1
  62. package/static/css/flyonui.css +1 -1
  63. package/static/css/public.css +41 -0
  64. package/static/css/src/app.tailwind.css +135 -4
  65. package/static/js/public.js +218 -0
  66. package/static/js/ui.js +89 -36
  67. package/static/licenses.html +55 -37
  68. package/translations/README.md +4 -3
  69. package/translations/de.mo +0 -0
  70. package/translations/de.po +296 -185
  71. package/translations/en.po +220 -128
  72. package/translations/es.mo +0 -0
  73. package/translations/es.po +558 -0
  74. package/translations/et.mo +0 -0
  75. package/translations/et.po +288 -181
  76. package/translations/fr.mo +0 -0
  77. package/translations/fr.po +295 -183
  78. package/translations/it.mo +0 -0
  79. package/translations/it.po +558 -0
  80. package/translations/ja.mo +0 -0
  81. package/translations/ja.po +268 -192
  82. package/translations/locales.json +24 -0
  83. package/translations/messages.pot +179 -127
  84. package/translations/nl.mo +0 -0
  85. package/translations/nl.po +288 -175
  86. package/translations/pl.mo +0 -0
  87. package/translations/pl.po +294 -181
  88. package/translations/sv.mo +0 -0
  89. package/translations/sv.po +555 -0
  90. package/translations/tr.mo +0 -0
  91. package/translations/tr.po +555 -0
  92. package/update-info.sh +12 -6
  93. package/views/account/login-redirect.hbs +6 -5
  94. package/views/account/passkeys.hbs +8 -8
  95. package/views/account/security.hbs +2 -2
  96. package/views/accounts/account.hbs +19 -21
  97. package/views/accounts/browse.hbs +1 -1
  98. package/views/accounts/edit.hbs +15 -15
  99. package/views/accounts/index.hbs +3 -3
  100. package/views/accounts/register/imap-server.hbs +27 -173
  101. package/views/accounts/register/validating.hbs +139 -0
  102. package/views/config/ai.hbs +15 -17
  103. package/views/config/branding.hbs +7 -7
  104. package/views/config/document-store/chat.hbs +9 -8
  105. package/views/config/document-store/index.hbs +14 -15
  106. package/views/config/document-store/mappings/index.hbs +5 -6
  107. package/views/config/document-store/mappings/new.hbs +1 -2
  108. package/views/config/document-store/pre-processing/index.hbs +4 -4
  109. package/views/config/email-processing.hbs +6 -6
  110. package/views/config/imap-proxy.hbs +7 -8
  111. package/views/config/license.hbs +9 -9
  112. package/views/config/logging.hbs +5 -7
  113. package/views/config/mcp.hbs +90 -58
  114. package/views/config/network.hbs +4 -4
  115. package/views/config/oauth/app.hbs +12 -12
  116. package/views/config/oauth/index.hbs +6 -6
  117. package/views/config/oauth/subscriptions.hbs +9 -9
  118. package/views/config/security.hbs +5 -7
  119. package/views/config/service.hbs +11 -10
  120. package/views/config/smtp.hbs +9 -12
  121. package/views/config/tls-upload.hbs +3 -3
  122. package/views/config/tls.hbs +281 -182
  123. package/views/config/webhooks.hbs +12 -15
  124. package/views/dashboard.hbs +9 -8
  125. package/views/gateways/edit.hbs +3 -3
  126. package/views/gateways/gateway.hbs +3 -3
  127. package/views/gateways/index.hbs +6 -6
  128. package/views/gateways/new.hbs +3 -3
  129. package/views/internals/index.hbs +15 -13
  130. package/views/layout/app.hbs +6 -6
  131. package/views/layout/login.hbs +32 -19
  132. package/views/layout/main.hbs +2 -2
  133. package/views/layout/prompt.hbs +15 -18
  134. package/views/layout/public.hbs +1 -1
  135. package/views/mcp/authorize.hbs +47 -45
  136. package/views/partials/accounts_table.hbs +5 -5
  137. package/views/partials/ace_assets.hbs +1 -1
  138. package/views/partials/add_account_modal.hbs +4 -4
  139. package/views/partials/address_list.hbs +4 -4
  140. package/views/partials/filter_editor_js.hbs +2 -2
  141. package/views/partials/gateway_form.hbs +5 -5
  142. package/views/partials/gateway_js.hbs +1 -1
  143. package/views/partials/mcp_access_levels.hbs +16 -9
  144. package/views/partials/mcp_account_limit.hbs +2 -2
  145. package/views/partials/mcp_tool_count.hbs +15 -14
  146. package/views/partials/oauth_config_header.hbs +2 -2
  147. package/views/partials/oauth_form.hbs +37 -42
  148. package/views/partials/public_alerts.hbs +1 -1
  149. package/views/partials/public_test_labels.hbs +15 -0
  150. package/views/partials/public_theme_init.hbs +1 -1
  151. package/views/partials/security_header.hbs +2 -2
  152. package/views/partials/template_form.hbs +4 -4
  153. package/views/partials/theme_init.hbs +1 -1
  154. package/views/partials/tls_security_card.hbs +4 -1
  155. package/views/partials/ui/form-field.hbs +6 -1
  156. package/views/partials/ui/setting-ref.hbs +12 -7
  157. package/views/partials/ui/stat-card.hbs +4 -1
  158. package/views/partials/ui/tabs.hbs +3 -7
  159. package/views/partials/webhook_form.hbs +9 -12
  160. package/views/partials/webhooks_editor_functions.hbs +1 -1
  161. package/views/reference/index.hbs +3 -3
  162. package/views/reference/redirect.hbs +1 -1
  163. package/views/reference/tag.hbs +1 -1
  164. package/views/reference/token.hbs +4 -4
  165. package/views/suppression-lists/index.hbs +8 -6
  166. package/views/suppression-lists/list.hbs +13 -8
  167. package/views/templates/edit.hbs +1 -1
  168. package/views/templates/index.hbs +10 -11
  169. package/views/templates/template.hbs +5 -5
  170. package/views/tokens/index.hbs +17 -17
  171. package/views/tokens/new.hbs +190 -93
  172. package/views/unsubscribe.hbs +1 -1
  173. package/views/webhooks/edit.hbs +1 -1
  174. package/views/webhooks/index.hbs +10 -11
  175. package/views/webhooks/new.hbs +1 -1
  176. package/views/webhooks/webhook.hbs +5 -6
  177. package/workers/api.js +9 -8
  178. package/workers/smtp.js +1 -1
@@ -22,7 +22,7 @@ class="mb-1"}}
22
22
  </p>
23
23
 
24
24
  <div>
25
- {{> ui/btn href="https://postalsys.com/plans" external=true label="Renew Subscription"
25
+ {{> ui/btn href="https://postalsys.com/plans" external=true label="Renew subscription"
26
26
  icon="icon-[tabler--arrow-right]"}}
27
27
  </div>
28
28
 
@@ -33,7 +33,7 @@ class="mb-1"}}
33
33
 
34
34
  {{#> ui/card}}
35
35
  <div class="float-right ms-4">
36
- {{> ui/btn href="https://postalsys.com/licenses" external=true label="Get a License"
36
+ {{> ui/btn href="https://postalsys.com/licenses" external=true label="Get a license"
37
37
  icon="icon-[tabler--arrow-right]"}}
38
38
  </div>
39
39
  <p>
@@ -49,9 +49,9 @@ class="mb-1"}}
49
49
 
50
50
  {{#if licenseInfo.active}}
51
51
  <div class="card bg-base-100 shadow-md mb-6">
52
- <div class="card-header flex items-center justify-between">
52
+ <div class="card-header flex flex-wrap items-center justify-between gap-3">
53
53
  <h6 class="card-title text-primary">Current License</h6>
54
- {{> ui/btn label="Remove License" variant="error" style="soft" size="sm" icon="icon-[tabler--trash]"
54
+ {{> ui/btn label="Remove license" variant="error" style="soft" size="sm" icon="icon-[tabler--trash]"
55
55
  id="unregister-license-link" overlay="#deleteLicense"}}
56
56
  </div>
57
57
  <div class="card-body">
@@ -97,7 +97,7 @@ class="mb-1"}}
97
97
  <input type="hidden" name="crumb" value="{{crumb}}" />
98
98
 
99
99
  <div class="mb-6">
100
- {{> ui/btn label="Upload License File" variant="info" id="licenseFile" icon="icon-[tabler--file-import]"}}
100
+ {{> ui/btn label="Upload license file" variant="info" id="licenseFile" icon="icon-[tabler--file-import]"}}
101
101
  </div>
102
102
 
103
103
  <div class="mb-6">
@@ -111,18 +111,18 @@ class="mb-1"}}
111
111
  </div>
112
112
 
113
113
  <div class="mb-2">
114
- {{> ui/btn label="Activate License" type="submit" icon="icon-[tabler--key]"}}
114
+ {{> ui/btn label="Activate license" type="submit" icon="icon-[tabler--key]"}}
115
115
  </div>
116
116
 
117
117
  </form>
118
118
  {{/ui/details}}
119
119
 
120
- {{#> ui/confirm-modal id="deleteLicense" title="Remove License" action="/admin/config/license/delete"
121
- submitLabel="Remove License"}}
120
+ {{#> ui/confirm-modal id="deleteLicense" title="Remove license" action="/admin/config/license/delete"
121
+ submitLabel="Remove license"}}
122
122
  Remove the current license key from this EmailEngine instance?
123
123
  {{/ui/confirm-modal}}
124
124
 
125
- <script nonce="{{cspNonce}}">
125
+ <script data-cfasync="false" nonce="{{cspNonce}}">
126
126
  document.addEventListener('DOMContentLoaded', () => {
127
127
  let licenseTextElm = document.getElementById('licenseTextElement')
128
128
  let fileSelectElm = document.getElementById('licenseFile');
@@ -1,8 +1,8 @@
1
1
  {{> ui/page-header title="Logging" icon="icon-[tabler--settings]" class="mb-1"}}
2
2
 
3
3
  <p class="mb-6">
4
- Track API requests for debugging and monitoring. EmailEngine can log IMAP, SMTP, Gmail API, and MS Graph API
5
- activity (credentials and message content are never logged). Download logs anytime for troubleshooting.
4
+ Record account connection activity for troubleshooting, including IMAP, SMTP, Gmail API, and Microsoft Graph
5
+ requests. Download stored logs from each account's page.
6
6
  </p>
7
7
 
8
8
  {{> ui/env-managed-alert}}
@@ -16,8 +16,7 @@
16
16
  {{> ui/setting-ref name="logs.all"}}
17
17
  {{> ui/checkbox id="settingsLogsAll" name="all" label="Enable Logging for All Accounts"
18
18
  checked=values.all error=errors.all}}
19
- <span class="helper-text">Turn on logging for every connected account. Use with caution, this can impact
20
- performance with many accounts.<br>
19
+ <span class="helper-text">Record logs for every connected account. Logging many accounts increases memory use and can affect performance.<br>
21
20
  <strong>Restart required</strong> after changing this setting.</span>
22
21
  </div>
23
22
 
@@ -28,8 +27,7 @@
28
27
  <input type="number" class="input{{#if errors.maxLogLines}} is-invalid{{/if}}"
29
28
  id="settingsLogsMaxLogLines" min="0" max="10000000" name="maxLogLines"
30
29
  value="{{values.maxLogLines}}" />
31
- <span class="helper-text">Maximum log entries to keep per account. Logs are stored in memory (Redis), so
32
- choose wisely to avoid running out of RAM.</span>
30
+ <span class="helper-text">Maximum log entries to retain per account. Higher limits use more Redis memory.</span>
33
31
  {{/ui/form-field}}
34
32
  </div>
35
33
 
@@ -72,7 +70,7 @@
72
70
  {{/ui/card}}
73
71
 
74
72
  <div class="mb-6">
75
- {{> ui/btn label="Save Changes" type="submit" icon="icon-[tabler--settings]"}}
73
+ {{> ui/btn label="Save changes" type="submit" icon="icon-[tabler--settings]"}}
76
74
  </div>
77
75
 
78
76
  </form>
@@ -1,9 +1,8 @@
1
1
  {{> ui/page-header title="MCP" icon="icon-[tabler--plug-connected]" badgeLabel="Beta" badgeVariant="info" class="mb-1"}}
2
2
 
3
3
  <p class="mb-6">
4
- Let AI agents work with the connected email accounts over the Model Context Protocol. The MCP endpoint exposes a
5
- curated tool set (list and search messages, read content, organize and delete messages, create drafts, send mail)
6
- and accepts the same access tokens as the REST API.
4
+ Connect AI agents through the Model Context Protocol (MCP). Choose whether each agent can manage this
5
+ EmailEngine instance, work with email, or both. Access tokens control which tools and accounts it can use.
7
6
  </p>
8
7
 
9
8
  <div class="mb-6 alert alert-soft alert-info">
@@ -16,8 +15,7 @@
16
15
  <div class="mb-6 alert alert-soft alert-warning">
17
16
  <span class="icon-[tabler--alert-triangle] size-5 shrink-0"></span>
18
17
  <span>The MCP endpoint is disabled for this deployment (<code>EENGINE_MCP_ENABLED</code> or <code>[mcp]
19
- enabled</code> in the configuration file), so the settings below have no effect until that gate is turned
20
- back on and EmailEngine is restarted.</span>
18
+ enabled</code> in the configuration file), so the settings below take effect only after MCP is enabled at startup and EmailEngine is restarted.</span>
21
19
  </div>
22
20
  {{/unless}}
23
21
 
@@ -46,8 +44,8 @@
46
44
  checked=values.mcpEnabled error=errors.mcpEnabled}}
47
45
  <span class="helper-text">Serves the Model Context Protocol at <code>/mcp</code>. The
48
46
  <button type="button" class="link cursor-pointer" data-goto-tab="mcp-connect">Connect an agent</button> tab
49
- generates access tokens and ready-to-paste setup for clients; a token with the <code>mcp</code> scope works
50
- only here and not against the REST API.</span>
47
+ generates access tokens and ready-to-paste setup for clients; a token with the <code>mcp-manage</code> or
48
+ <code>mcp</code> scope works only here and not against the REST API.</span>
51
49
  </div>
52
50
 
53
51
  {{!-- Nested rather than a peer: OAuth is a sub-option of an endpoint that is already on,
@@ -67,7 +65,7 @@
67
65
  {{/ui/card}}
68
66
 
69
67
  <div class="mb-6">
70
- {{> ui/btn label="Save Changes" type="submit" icon="icon-[tabler--settings]"}}
68
+ {{> ui/btn label="Save changes" type="submit" icon="icon-[tabler--settings]"}}
71
69
  </div>
72
70
  </form>
73
71
 
@@ -82,7 +80,7 @@
82
80
  {{#unless values.mcpEnabled}}
83
81
  <div class="mb-6 alert alert-soft alert-warning">
84
82
  <span class="icon-[tabler--alert-triangle] size-5 shrink-0"></span>
85
- <span>The MCP endpoint is not enabled yet, so a connected client would get nothing to talk to. Turn it on under
83
+ <span>Enable the MCP endpoint before connecting a client. Turn it on under
86
84
  <button type="button" class="link cursor-pointer" data-goto-tab="mcp-settings">Settings</button> first.</span>
87
85
  </div>
88
86
  {{/unless}}
@@ -105,8 +103,9 @@
105
103
 
106
104
  {{#> ui/card bodyClass="space-y-4"}}
107
105
 
108
- <p class="text-sm">Generate an access token and ready-to-paste client configuration in one step. The token gets the
109
- <code>mcp</code> scope, so it works against the MCP endpoint and nothing else.</p>
106
+ <p class="text-sm">Generate an access token and ready-to-paste client configuration in one step. The token gets the MCP
107
+ scopes you choose below (<code>mcp-manage</code> for the instance, <code>mcp</code> for mail), so it works against
108
+ the MCP endpoint and nothing else.</p>
110
109
 
111
110
  {{#unless canProvision}}
112
111
  <div class="alert alert-soft alert-warning text-sm">
@@ -115,28 +114,33 @@
115
114
  </div>
116
115
  {{/unless}}
117
116
 
118
- <div id="mcpTokenGen" data-presets="{{json mcpAccessPresets}}" data-mcp-url="{{mcpUrl}}" class="space-y-4">
117
+ <div id="mcpTokenGen" data-mcp-url="{{mcpUrl}}" class="space-y-4">
119
118
  {{!-- One column on purpose: two-up put the account field a full screen away from its
120
119
  label-mate on wide displays, and the form reads as one top-to-bottom flow --}}
121
120
  {{> ui/form-field id="mcpGenLabel" label="What is this token for?" placeholder="for example Cursor or Claude"
122
121
  hint="Shows up as the token description, so you can tell agents apart on the Access Tokens page."}}
123
122
 
124
- {{> mcp_account_limit id="mcpGenAccount"}}
125
-
123
+ {{!-- The same two sections, in the same order and from the same table, as the OAuth consent
124
+ prompt: management first, mail declined unless picked. The radio group of a section is
125
+ named mcpGen_<key>, which is what ui.js reads the selection back from. --}}
126
+ {{#each mcpSections}}
126
127
  <fieldset class="space-y-2">
127
- <legend class="label-text mb-1">Access level</legend>
128
- {{> mcp_access_levels name="mcpGenAccess" idPrefix="mcpGenAccess" selected="read"}}
129
-
130
- {{!-- What the selected level actually leaves the client able to call, which the level
131
- names alone cannot say: the count follows both the level and the account limit
132
- above, exactly as tools/list will --}}
133
- {{> mcp_tool_count id="mcpGenToolCount" levelName="mcpGenAccess" accountId="mcpGenAccount" class="pt-1"}}
134
-
135
- {{!-- At the decision point rather than only in the collapsed manual-config block: the
136
- level chosen here is what decides whether injected instructions can act --}}
137
- <p class="text-base-content/60 text-sm">Email content flows into whatever model the connected client runs, and
138
- instructions inside received mail can steer it - grant sending and deleting rights deliberately.</p>
128
+ <legend class="label-text mb-1">{{label}}</legend>
129
+ {{> mcp_access_levels section=this name=(concat "mcpGen_" @key) idPrefix=(concat "mcpGen_" @key) selected=defaultLevel includeNone=true}}
139
130
  </fieldset>
131
+ {{/each}}
132
+
133
+ {{!-- At the decision point rather than only in the collapsed manual-config block: the
134
+ level chosen here is what decides whether injected instructions can act --}}
135
+ <p class="text-base-content/60 text-sm">The connected client may send email content to its AI model. Instructions in received emails can influence
136
+ the agent. Grant permission to send or delete email only when the agent needs it.</p>
137
+
138
+ {{> mcp_account_limit id="mcpGenAccount"}}
139
+
140
+ {{!-- What the selected levels actually leave the client able to call, which the level names
141
+ alone cannot say: the count follows both sections and the account limit, exactly as
142
+ tools/list will --}}
143
+ {{> mcp_tool_count id="mcpGenToolCount" autoWire=true levelPrefix="mcpGen_" accountId="mcpGenAccount" class="pt-1"}}
140
144
 
141
145
  <div class="flex items-center gap-3">
142
146
  {{#if canProvision}}
@@ -166,8 +170,9 @@
166
170
  </div>
167
171
 
168
172
  <div class="text-sm text-base-content/60">
169
- Every connected agent is an ordinary access token with the <code>mcp</code> scope - review or revoke them on
170
- the <a href="/admin/tokens?scope=mcp" class="link">Access Tokens</a> page.
173
+ Each agent connects using an access token with the <code>mcp-manage</code> or <code>mcp</code> scope.
174
+ Review or revoke these tokens on the <a href="/admin/tokens?scope=mcp-manage&amp;scope=mcp" class="link">Access
175
+ Tokens</a> page.
171
176
  </div>
172
177
  </div>
173
178
 
@@ -197,8 +202,9 @@
197
202
  {{!-- No prompt-injection sentence here: the generator fieldset in this same panel already
198
203
  carries it, at the point where the access level is chosen --}}
199
204
  <div class="text-sm text-base-content/60">
200
- Any access token from the <a href="/admin/tokens" class="link">Access Tokens</a> page works. For an AI agent,
201
- prefer a token bound to a single account, with the <code>mcp</code> scope.
205
+ Create a token on the <a href="/admin/tokens" class="link">Access Tokens</a> page with
206
+ <code>mcp-manage</code> scope for instance management, <code>mcp</code> scope for email, or both.
207
+ If the agent only needs one mailbox, limit the token to that account.
202
208
  </div>
203
209
 
204
210
  </div>
@@ -256,10 +262,10 @@
256
262
  <ol class="text-base-content/80 ms-4 mt-1 list-decimal space-y-1 text-sm">
257
263
  <li>When you connect, the client opens this instance's authorization prompt in the browser. Sign in with the
258
264
  admin credentials if asked.</li>
259
- <li>On the prompt, pick the access level (read-only is the default) and optionally limit the connector to a
260
- single account, then approve.</li>
261
- <li>The connector receives its own access token with the <code>mcp</code> scope - review or revoke it at any
262
- time on the <a href="/admin/tokens?scope=mcp" class="link">Access Tokens</a> page.</li>
265
+ <li>On the prompt, pick what the connector may manage (observing the instance is the default), switch on mail
266
+ access if it should read mail, optionally limit it to a single account, then approve.</li>
267
+ <li>The connector receives its own access token with the MCP scopes you chose - review or revoke it at any
268
+ time on the <a href="/admin/tokens?scope=mcp-manage&amp;scope=mcp" class="link">Access Tokens</a> page.</li>
263
269
  </ol>
264
270
  </div>
265
271
 
@@ -272,29 +278,49 @@
272
278
  </div>
273
279
 
274
280
  {{!-- Outside the method panels: what a connected agent receives is the same either way --}}
275
- {{#> ui/details summary="Exposed tools" summarySmall=(concat toolCatalog.length " tools") class="card bg-base-100 shadow-md mb-6"}}
276
- <div>
277
- <p class="text-sm text-base-content/60 mb-4">This is exactly what a connected agent receives from
278
- <code>tools/list</code>. Whether a given token can call a tool also depends on its account binding and
279
- permission restrictions.</p>
280
- <div class="space-y-3">
281
- {{#each toolCatalog}}
282
- <div class="flex flex-wrap items-baseline gap-2">
283
- <code>{{name}}</code>
284
- {{> ui/badge label=badge.label variant=badge.variant soft=true}}
285
- <span class="text-sm text-base-content/60 basis-full sm:basis-auto sm:grow">{{description}}</span>
281
+ {{#> ui/details summary="Exposed tools" summarySmall=(concat toolCatalog.total " tools") class="card bg-base-100 shadow-md mb-6"}}
282
+ <div class="space-y-6">
283
+ <p class="text-sm text-base-content/60">Available MCP tools, grouped by scope. A connected agent receives only the tools allowed by its token
284
+ scopes, permissions, and account restriction.</p>
285
+ {{#each toolCatalog.sections}}
286
+ <div>
287
+ <h6 class="mb-2 font-bold">{{label}} <span class="text-base-content/60 font-normal">({{tools.length}} tools,
288
+ <code>{{scope}}</code>)</span></h6>
289
+ <div class="space-y-3">
290
+ {{#each tools}}
291
+ <div class="flex flex-wrap items-baseline gap-2">
292
+ <code>{{name}}</code>
293
+ {{> ui/badge label=badge.label variant=badge.variant soft=true}}
294
+ {{#if shared}}{{> ui/badge label="both scopes" variant="neutral" soft=true}}{{/if}}
295
+ <span class="text-sm text-base-content/60 basis-full sm:basis-auto sm:grow">{{description}}</span>
296
+ </div>
297
+ {{/each}}
298
+ </div>
299
+ </div>
300
+ {{/each}}
301
+ {{#if toolCatalog.unreached.length}}
302
+ <div>
303
+ <h6 class="mb-2 font-bold">Not offered by any MCP scope</h6>
304
+ <div class="space-y-3">
305
+ {{#each toolCatalog.unreached}}
306
+ <div class="flex flex-wrap items-baseline gap-2">
307
+ <code>{{name}}</code>
308
+ <span class="text-sm text-base-content/60 basis-full sm:basis-auto sm:grow">{{description}}</span>
309
+ </div>
310
+ {{/each}}
286
311
  </div>
287
- {{/each}}
288
312
  </div>
313
+ {{/if}}
289
314
  </div>
290
315
  {{/ui/details}}
291
316
 
292
317
  </div>
293
318
 
294
- <script nonce="{{cspNonce}}">
319
+ <script data-cfasync="false" nonce="{{cspNonce}}">
295
320
  (() => {
296
321
  let container = document.getElementById('mcpTokenGen');
297
- let presets = JSON.parse(container.dataset.presets || '{}');
322
+ // The section table is embedded once, on the tool count element ui.js wires
323
+ let sections = JSON.parse(document.getElementById('mcpGenToolCount').dataset.mcpSections || '{}');
298
324
  let mcpUrl = container.dataset.mcpUrl;
299
325
 
300
326
  // The one place each artifact is written; the manual block shows them with a
@@ -323,25 +349,31 @@
323
349
 
324
350
  let label = (document.getElementById('mcpGenLabel').value || '').trim() || 'MCP agent';
325
351
  let account = (document.getElementById('mcpGenAccount').value || '').trim();
326
- let accessElm = document.querySelector('input[name="mcpGenAccess"]:checked');
327
- let access = (accessElm && accessElm.value) || 'read';
352
+ let choice = uiMcpLevelChoice(sections, 'mcpGen_');
328
353
 
329
354
  try {
330
- if (!Object.prototype.hasOwnProperty.call(presets, access)) {
331
- // A missing preset must not silently mint a wider credential than the
332
- // selected level promises
333
- throw new Error('The access preset failed to load. Reload the page and try again.');
355
+ if (!sections.manage || !sections.mail) {
356
+ // A missing table must not silently mint a wider credential than the
357
+ // selected levels promise
358
+ throw new Error('The access levels failed to load. Reload the page and try again.');
359
+ }
360
+
361
+ // The same union the consent prompt mints, computed by the shared helper: the
362
+ // scopes of the sections that were not declined and the grant pairs of their
363
+ // levels. A token always carries its grants explicitly, so what the operator saw
364
+ // is exactly what the credential holds.
365
+ let record = uiMcpLevelRecord(sections, choice);
366
+ if (!record.surfaces.length) {
367
+ throw new Error('Choose at least one kind of access.');
334
368
  }
335
369
 
336
370
  let data = await uiPostJson('/admin/tokens/new', {
337
371
  description: 'MCP: ' + label,
338
- scopes: ['mcp'],
372
+ scopes: record.surfaces,
339
373
  // The empty string, not null: accountIdSchema is `Joi.string().empty('')`,
340
374
  // which converts '' to the schema default and refuses an explicit null
341
375
  account: account,
342
- // The access-level table maps 'full' to null: the absence of a permissions
343
- // record, because the mcp scope already bounds the token to the MCP surface
344
- permissions: presets[access]
376
+ permissions: { grants: record.grants }
345
377
  });
346
378
 
347
379
  if (!data.success) {
@@ -133,7 +133,7 @@
133
133
  </div>
134
134
 
135
135
  <div class="card bg-base-100 shadow-md mb-6">
136
- <div class="card-header flex items-center justify-between">
136
+ <div class="card-header flex flex-wrap items-center justify-between gap-3">
137
137
  <h6 class="card-title text-primary">Available IP Addresses</h6>
138
138
  {{> ui/btn label="Scan for IPs" id="reload-btn" icon="icon-[tabler--refresh] reload-icon"}}
139
139
  </div>
@@ -144,7 +144,7 @@
144
144
  become unavailable, EmailEngine falls back to server defaults.
145
145
  </div>
146
146
  <div class="overflow-x-auto">
147
- <table class="table">
147
+ <table class="table ee-table-stack">
148
148
  <thead>
149
149
  <tr>
150
150
  <th>
@@ -172,7 +172,7 @@
172
172
  </div>
173
173
 
174
174
  <div class="mb-6">
175
- {{> ui/btn label="Save Changes" type="submit" icon="icon-[tabler--settings]"}}
175
+ {{> ui/btn label="Save changes" type="submit" icon="icon-[tabler--settings]"}}
176
176
  </div>
177
177
 
178
178
  </form>
@@ -184,7 +184,7 @@ Remove this IP from the list? It will be re-added if found during the next scan.
184
184
  {{/ui/confirm-modal}}
185
185
 
186
186
 
187
- <script nonce="{{cspNonce}}">
187
+ <script data-cfasync="false" nonce="{{cspNonce}}">
188
188
  document.addEventListener('DOMContentLoaded', () => {
189
189
  let reloadBtn = document.getElementById('reload-btn');
190
190
 
@@ -76,7 +76,7 @@
76
76
  <dd>
77
77
  {{> ui/copy-field id="appIdValue" value=app.id ariaLabel="ID" small=true join=true
78
78
  class="w-full max-w-md" inputClass="bg-base-200 border-0"}}
79
- <span class="helper-text" id="inputDescriptionHelp">Use this ID value as the
79
+ <span class="helper-text" id="inputDescriptionHelp">Use this ID as the
80
80
  <em>"provider"</em> property in the account's OAuth2 options.</span>
81
81
  </dd>
82
82
 
@@ -111,7 +111,7 @@
111
111
  {{/if}}
112
112
 
113
113
  {{#if app.serviceClientEmail}}
114
- <dt>Service Client Email</dt>
114
+ <dt>Service account email</dt>
115
115
  <dd class="font-mono"><small>{{app.serviceClientEmail}}</small></dd>
116
116
  {{/if}}
117
117
 
@@ -121,7 +121,7 @@
121
121
  {{/if}}
122
122
 
123
123
  {{#if app.serviceKey}}
124
- <dt>Secret service key</dt>
124
+ <dt>Private key</dt>
125
125
  <dd class="font-mono"><small>*****</small></dd>
126
126
  {{/if}}
127
127
 
@@ -207,7 +207,7 @@
207
207
 
208
208
  {{#if isServiceAccount}}
209
209
  {{#> ui/card title="API usage example"}}
210
- <p class="text-base-content/60 text-sm mb-2">This application uses service credentials, so accounts can not be
210
+ <p class="text-base-content/60 text-sm mb-2">This application uses service credentials, so accounts cannot be
211
211
  added through the hosted authentication form. Use the API to register email accounts instead.</p>
212
212
  <pre
213
213
  class="ee-code-block mb-0 whitespace-pre-wrap break-words"><code>curl -XPOST "{{serviceUrl}}/v1/account" \
@@ -287,9 +287,9 @@
287
287
  {{/if}}
288
288
 
289
289
 
290
- {{#> ui/confirm-modal id="deleteModal" title="Delete OAuth2 App" action="/admin/config/oauth/delete"
290
+ {{#> ui/confirm-modal id="deleteModal" title="Delete OAuth2 app" action="/admin/config/oauth/delete"
291
291
  fieldName="app" fieldValue=app.id submitLabel="Delete app" submitIcon="icon-[tabler--trash]"}}
292
- <p>Are you sure you want to delete the OAuth2 application "{{app.name}}"? This action cannot be undone.</p>
292
+ <p>Delete the OAuth2 app "{{app.name}}"? Accounts using this app will stop working until reconfigured. This action cannot be undone.</p>
293
293
  {{/ui/confirm-modal}}
294
294
 
295
295
  {{#> ui/modal id="verifySetupModal" title="Verify OAuth2 setup" titleId="verifySetupModalLabel" dialogClass="max-w-3xl"}}
@@ -334,18 +334,18 @@ fieldName="app" fieldValue=app.id submitLabel="Delete app" submitIcon="icon-[tab
334
334
  screen, so the account is registered directly. The mailbox must be reachable with the
335
335
  application's service credentials.</small></p>
336
336
  <div>
337
- {{> ui/form-field id="service-account-name" name="name" label="Full name:" placeholder="e.g., John Smith"}}
337
+ {{> ui/form-field id="service-account-name" name="name" label="Full name" placeholder="e.g., John Smith"}}
338
338
  </div>
339
339
  <div>
340
- {{#> ui/form-field id="service-account-email" label="Email address:"}}
340
+ {{#> ui/form-field id="service-account-email" label="Email address"}}
341
341
  <input type="email" class="input" id="service-account-email" name="email"
342
342
  placeholder="e.g., user@example.com" required>
343
343
  {{/ui/form-field}}
344
344
  </div>
345
345
  <div>
346
- {{> ui/form-field id="service-account-id" name="account" label="Account identifier (optional):"
346
+ {{> ui/form-field id="service-account-id" name="account" label="Account ID (optional)"
347
347
  placeholder="e.g., account_123"
348
- hint="Leave blank to auto-generate. Existing accounts with this ID will be updated."}}
348
+ hint="Leave blank to generate an ID. Using an existing ID updates that account."}}
349
349
  </div>
350
350
  </div>
351
351
  <div class="modal-footer">
@@ -355,7 +355,7 @@ fieldName="app" fieldValue=app.id submitLabel="Delete app" submitIcon="icon-[tab
355
355
  </form>
356
356
  {{/ui/modal}}
357
357
 
358
- <script nonce="{{cspNonce}}">
358
+ <script data-cfasync="false" nonce="{{cspNonce}}">
359
359
  document.addEventListener('DOMContentLoaded', () => {
360
360
  document.getElementById('addServiceAccountModal').addEventListener('open.overlay', () => {
361
361
  document.getElementById('service-account-name').focus();
@@ -364,7 +364,7 @@ fieldName="app" fieldValue=app.id submitLabel="Delete app" submitIcon="icon-[tab
364
364
  </script>
365
365
  {{/if}}
366
366
 
367
- <script nonce="{{cspNonce}}">
367
+ <script data-cfasync="false" nonce="{{cspNonce}}">
368
368
  document.addEventListener('DOMContentLoaded', () => {
369
369
  const appId = "{{app.id}}";
370
370
  const stepsElm = document.getElementById('verify-steps');
@@ -21,7 +21,7 @@
21
21
  {{#if apps}}
22
22
  <div class="card bg-base-100 shadow-md mb-6">
23
23
  <div class="overflow-x-auto">
24
- <table class="table">
24
+ <table class="table ee-table-stack">
25
25
  <thead>
26
26
  <tr>
27
27
  <th>Name</th>
@@ -49,19 +49,19 @@
49
49
  {{/if}}
50
50
  </td>
51
51
 
52
- <td class="relative">
52
+ <td class="relative" data-label="Description">
53
53
  {{> ui/row-link href=(concat "/admin/config/oauth/app/" id)}}{{description}}
54
54
  </td>
55
55
 
56
- <td class="relative">
56
+ <td class="relative" data-label="Type">
57
57
  {{> ui/row-link href=(concat "/admin/config/oauth/app/" id)}}{{providerData.comment}}
58
58
  </td>
59
59
 
60
- <td class="relative">
60
+ <td class="relative" data-label="Base scopes">
61
61
  {{> ui/row-link href=(concat "/admin/config/oauth/app/" id)}}{{baseScopesText}}
62
62
  </td>
63
63
 
64
- <td class="relative">
64
+ <td class="relative" data-label="Status">
65
65
  {{> ui/row-link href=(concat "/admin/config/oauth/app/" id)}}
66
66
  {{#if enabled}}
67
67
 
@@ -75,7 +75,7 @@
75
75
  {{/if}}
76
76
  </td>
77
77
 
78
- <td class="relative text-end">
78
+ <td class="ee-stack-actions relative text-end">
79
79
  {{> ui/row-actions openHref=(concat "/admin/config/oauth/app/" id) label="OAuth2 app actions"
80
80
  deleteModal="#deleteOauthApp" deleteId=id deleteName=name}}
81
81
  </td>
@@ -5,7 +5,7 @@
5
5
  {{#if apps}}
6
6
  <div class="card bg-base-100 shadow-md mb-6">
7
7
  <div class="overflow-x-auto">
8
- <table class="table">
8
+ <table class="table ee-table-stack">
9
9
  <thead>
10
10
  <tr>
11
11
  <th>Name</th>
@@ -27,11 +27,11 @@
27
27
  {{> ui/entity-id id=id prefix="Provider ID"}}
28
28
  </td>
29
29
 
30
- <td class="relative">
30
+ <td class="relative" data-label="Project ID">
31
31
  {{> ui/row-link href=(concat "/admin/config/oauth/app/" id)}}{{googleProjectId}}
32
32
  </td>
33
33
 
34
- <td class="relative">
34
+ <td class="relative" data-label="Topic">
35
35
  {{> ui/row-link href=(concat "/admin/config/oauth/app/" id)}}
36
36
  {{#if pubSubTopic}}
37
37
  {{> ui/badge label="Created" variant="success"}}
@@ -40,7 +40,7 @@
40
40
  {{/if}}
41
41
  </td>
42
42
 
43
- <td class="relative">
43
+ <td class="relative" data-label="Subscription">
44
44
  {{> ui/row-link href=(concat "/admin/config/oauth/app/" id)}}
45
45
  {{#if pubSubSubscription}}
46
46
  {{> ui/badge label="Created" variant="success"}}
@@ -49,7 +49,7 @@
49
49
  {{/if}}
50
50
  </td>
51
51
 
52
- <td class="relative">
52
+ <td class="relative" data-label="Expiration">
53
53
  {{> ui/row-link href=(concat "/admin/config/oauth/app/" id)}}
54
54
  {{#if expirationLabel}}
55
55
  {{expirationLabel}}
@@ -58,7 +58,7 @@
58
58
  {{/if}}
59
59
  </td>
60
60
 
61
- <td class="relative">
61
+ <td class="relative" data-label="Status">
62
62
  {{> ui/row-link href=(concat "/admin/config/oauth/app/" id)}}
63
63
  {{!-- relative z-[1] on the tooltip lifts the badge above the
64
64
  row-overlay link so the error tooltip stays hoverable --}}
@@ -75,7 +75,7 @@
75
75
  {{/if}}
76
76
  </td>
77
77
 
78
- <td class="relative text-end">
78
+ <td class="ee-stack-actions relative text-end">
79
79
  {{> ui/row-actions openHref=(concat "/admin/config/oauth/app/" id) label="OAuth2 app actions"}}
80
80
  </td>
81
81
  </tr>
@@ -109,8 +109,8 @@
109
109
  for a set period. This setting controls that period for both new and existing subscriptions.
110
110
  Changes take effect the next time an OAuth app is created, updated, or its subscription is recovered.
111
111
  If a subscription does expire, EmailEngine detects this and recreates it automatically.
112
- No messages are lost during the gap because EmailEngine also polls the Gmail API every 10 minutes
113
- and uses the History API to catch up on any missed changes.
112
+ EmailEngine also polls the Gmail API about every 10 minutes and uses the History API to catch up
113
+ on missed changes while notifications are unavailable.
114
114
  </div>
115
115
 
116
116
  {{/ui/card}}
@@ -17,8 +17,7 @@
17
17
  error=errors.enableTokens}}
18
18
  {{> ui/badge label=(when values.enableTokens "enabled" "disabled") variant=(when values.enableTokens "success" "error")}}
19
19
  {{/ui/checkbox}}
20
- <span class="helper-text">Disable for development only. Always enable in production for secure API
21
- access. Set <code>EENGINE_REQUIRE_API_AUTH=false</code> at startup to disable by default (not
20
+ <span class="helper-text">Require an access token for API requests. Keep this enabled in production. Set <code>EENGINE_REQUIRE_API_AUTH=false</code> at startup to disable by default (not
22
21
  recommended).</span>
23
22
  </div>
24
23
 
@@ -40,7 +39,7 @@
40
39
  error=errors.enableOAuthTokensApi}}
41
40
  <span class="helper-text">Enable <a href="/admin/reference/account#getV1AccountAccountOauthtoken"
42
41
  target="_blank" rel="noopener noreferrer" class="link link-animated">API endpoint</a> to
43
- retrieve OAuth2 tokens. Set <code>EENGINE_ENABLE_OAUTH_TOKENS_API=true</code> at startup to enable
42
+ retrieve accounts' live OAuth2 access tokens. Set <code>EENGINE_ENABLE_OAUTH_TOKENS_API=true</code> at startup to enable
44
43
  by default.</span>
45
44
  </div>
46
45
 
@@ -51,10 +50,9 @@
51
50
  checked=values.tokenAuditLog error=errors.tokenAuditLog}}
52
51
  {{> ui/badge label=(when values.tokenAuditLog "enabled" "disabled") variant=(when values.tokenAuditLog "success" "neutral")}}
53
52
  {{/ui/checkbox}}
54
- <span class="helper-text">Record which requests each access token makes, readable at <a
53
+ <span class="helper-text">Record requests made with each access token. Read the entries at <a
55
54
  href="/admin/reference/access-tokens#getV1TokensTokenLog" target="_blank"
56
- rel="noopener noreferrer" class="link link-animated">the token log endpoint</a>. Adds a write to
57
- every authenticated request, and entries only exist from the point this is switched on.</span>
55
+ rel="noopener noreferrer" class="link link-animated">the token log endpoint</a>. Logging starts when enabled and adds a storage write to each authenticated request.</span>
58
56
  </div>
59
57
 
60
58
  {{/ui/card}}
@@ -101,7 +99,7 @@
101
99
  {{/ui/card}}
102
100
 
103
101
  <div class="mb-6">
104
- {{> ui/btn label="Save Changes" type="submit" icon="icon-[tabler--settings]"}}
102
+ {{> ui/btn label="Save changes" type="submit" icon="icon-[tabler--settings]"}}
105
103
  </div>
106
104
 
107
105
  </form>