emailengine-app 2.80.0 → 2.80.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 (101) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +24 -0
  3. package/README.md +6 -0
  4. package/data/google-crawlers.json +1 -1
  5. package/lib/api-routes/account-routes.js +81 -1
  6. package/lib/api-routes/blocklist-routes.js +24 -0
  7. package/lib/api-routes/delivery-test-routes.js +6 -0
  8. package/lib/api-routes/gateway-routes.js +30 -0
  9. package/lib/api-routes/license-routes.js +10 -0
  10. package/lib/api-routes/mcp-oauth-routes.js +3 -3
  11. package/lib/api-routes/mcp-routes.js +39 -21
  12. package/lib/api-routes/oauth2-app-routes.js +38 -1
  13. package/lib/api-routes/outbox-routes.js +6 -0
  14. package/lib/api-routes/permission-map.js +208 -43
  15. package/lib/api-routes/pubsub-routes.js +8 -0
  16. package/lib/api-routes/route-helpers.js +58 -11
  17. package/lib/api-routes/settings-routes.js +50 -4
  18. package/lib/api-routes/stats-routes.js +6 -0
  19. package/lib/api-routes/template-routes.js +21 -0
  20. package/lib/api-routes/token-routes.js +34 -2
  21. package/lib/api-routes/webhook-route-routes.js +13 -0
  22. package/lib/email-client/base-client.js +6 -3
  23. package/lib/email-client/credential-errors.js +4 -0
  24. package/lib/email-client/imap/login-failure.js +52 -0
  25. package/lib/email-client/imap/subconnection.js +2 -1
  26. package/lib/email-client/imap-client.js +3 -6
  27. package/lib/enum-descriptions.js +12 -2
  28. package/lib/imapproxy/imap-server.js +1 -1
  29. package/lib/mcp/oauth.js +46 -8
  30. package/lib/mcp/protocol.js +78 -35
  31. package/lib/mcp/tools.js +53 -17
  32. package/lib/privileged-settings.js +147 -0
  33. package/lib/schemas.js +60 -16
  34. package/lib/settings.js +13 -0
  35. package/lib/tls/catalog.js +428 -0
  36. package/lib/tls/context.js +87 -161
  37. package/lib/tls/listeners.js +62 -0
  38. package/lib/tls/status.js +128 -79
  39. package/lib/tls/store.js +3 -2
  40. package/lib/token-permission-view.js +252 -102
  41. package/lib/token-permissions.js +176 -26
  42. package/lib/tokens.js +7 -6
  43. package/lib/tools.js +4 -3
  44. package/lib/ui-routes/admin-config-routes.js +41 -21
  45. package/lib/ui-routes/admin-entities-routes.js +23 -13
  46. package/lib/ui-routes/mcp-consent-routes.js +72 -31
  47. package/lib/ui-routes/tls-config-routes.js +121 -74
  48. package/package.json +12 -12
  49. package/sbom.json +1 -1
  50. package/server.js +7 -1
  51. package/static/css/flyonui.css +1 -1
  52. package/static/js/ui.js +89 -36
  53. package/static/licenses.html +46 -28
  54. package/translations/messages.pot +74 -68
  55. package/views/account/login-redirect.hbs +1 -1
  56. package/views/account/passkeys.hbs +2 -2
  57. package/views/accounts/account.hbs +2 -2
  58. package/views/accounts/browse.hbs +1 -1
  59. package/views/accounts/edit.hbs +1 -1
  60. package/views/accounts/register/imap-server.hbs +1 -1
  61. package/views/config/ai.hbs +1 -1
  62. package/views/config/branding.hbs +2 -2
  63. package/views/config/document-store/chat.hbs +1 -1
  64. package/views/config/document-store/index.hbs +1 -1
  65. package/views/config/imap-proxy.hbs +1 -1
  66. package/views/config/license.hbs +1 -1
  67. package/views/config/mcp.hbs +88 -52
  68. package/views/config/network.hbs +1 -1
  69. package/views/config/oauth/app.hbs +2 -2
  70. package/views/config/service.hbs +1 -1
  71. package/views/config/smtp.hbs +1 -1
  72. package/views/config/tls.hbs +266 -165
  73. package/views/config/webhooks.hbs +2 -2
  74. package/views/internals/index.hbs +1 -1
  75. package/views/layout/app.hbs +6 -6
  76. package/views/layout/login.hbs +5 -5
  77. package/views/layout/main.hbs +2 -2
  78. package/views/layout/prompt.hbs +3 -3
  79. package/views/layout/public.hbs +1 -1
  80. package/views/mcp/authorize.hbs +47 -45
  81. package/views/partials/ace_assets.hbs +1 -1
  82. package/views/partials/add_account_modal.hbs +1 -1
  83. package/views/partials/filter_editor_js.hbs +2 -2
  84. package/views/partials/gateway_js.hbs +1 -1
  85. package/views/partials/mcp_access_levels.hbs +16 -9
  86. package/views/partials/mcp_tool_count.hbs +15 -14
  87. package/views/partials/oauth_form.hbs +1 -1
  88. package/views/partials/public_theme_init.hbs +1 -1
  89. package/views/partials/template_form.hbs +1 -1
  90. package/views/partials/theme_init.hbs +1 -1
  91. package/views/partials/webhooks_editor_functions.hbs +1 -1
  92. package/views/reference/index.hbs +1 -1
  93. package/views/reference/redirect.hbs +1 -1
  94. package/views/reference/tag.hbs +1 -1
  95. package/views/reference/token.hbs +1 -1
  96. package/views/templates/template.hbs +1 -1
  97. package/views/tokens/new.hbs +175 -74
  98. package/views/unsubscribe.hbs +1 -1
  99. package/views/webhooks/webhook.hbs +1 -1
  100. package/workers/api.js +9 -8
  101. package/workers/smtp.js +1 -1
@@ -1,10 +1,10 @@
1
1
  msgid ""
2
2
  msgstr ""
3
3
  "Content-Type: text/plain; charset=ascii\n"
4
- "POT-Creation-Date: 2026-09-09 01:28+0000\n"
4
+ "POT-Creation-Date: 2026-09-10 17:19+0000\n"
5
5
 
6
6
  #: views/error.hbs:6
7
- #: workers/api.js:3119
7
+ #: workers/api.js:3130
8
8
  msgid "Something went wrong"
9
9
  msgstr ""
10
10
 
@@ -27,6 +27,16 @@ msgid_plural "%d days"
27
27
  msgstr[0] ""
28
28
  msgstr[1] ""
29
29
 
30
+ #: views/config/tls.hbs:418
31
+ msgid "%d certificate"
32
+ msgid_plural "%d certificates"
33
+ msgstr[0] ""
34
+ msgstr[1] ""
35
+
36
+ #: views/redirect.hbs:1
37
+ msgid "Click <a href=\"%s\">here</a> to continue&mldr;"
38
+ msgstr ""
39
+
30
40
  #: views/oauth-scope-error.hbs:5
31
41
  msgid "Insufficient Permissions"
32
42
  msgstr ""
@@ -102,8 +112,42 @@ msgid ""
102
112
  "received."
103
113
  msgstr ""
104
114
 
105
- #: views/redirect.hbs:1
106
- msgid "Click <a href=\"%s\">here</a> to continue&mldr;"
115
+ #: views/accounts/register/imap.hbs:13
116
+ msgid "Your name"
117
+ msgstr ""
118
+
119
+ #: views/accounts/register/imap.hbs:19
120
+ msgid "Enter your full name"
121
+ msgstr ""
122
+
123
+ #: views/accounts/register/imap.hbs:35
124
+ msgid "This setup link is restricted to this email address"
125
+ msgstr ""
126
+
127
+ #: views/accounts/register/imap.hbs:37
128
+ msgid "Enter your email address"
129
+ msgstr ""
130
+
131
+ #: views/accounts/register/imap.hbs:43
132
+ #: views/accounts/register/imap-server.hbs:47
133
+ #: views/accounts/register/imap-server.hbs:154
134
+ msgid "Password"
135
+ msgstr ""
136
+
137
+ #: views/accounts/register/imap.hbs:49
138
+ msgid "Enter your account password"
139
+ msgstr ""
140
+
141
+ #: views/accounts/register/imap.hbs:55
142
+ msgid "Continue"
143
+ msgstr ""
144
+
145
+ #: views/accounts/register/index.hbs:6
146
+ msgid "Choose your email account provider"
147
+ msgstr ""
148
+
149
+ #: views/accounts/register/index.hbs:19
150
+ msgid "Standard IMAP"
107
151
  msgstr ""
108
152
 
109
153
  #: views/accounts/register/imap-server.hbs:23
@@ -121,12 +165,6 @@ msgstr ""
121
165
  msgid "Username"
122
166
  msgstr ""
123
167
 
124
- #: views/accounts/register/imap-server.hbs:47
125
- #: views/accounts/register/imap-server.hbs:154
126
- #: views/accounts/register/imap.hbs:43
127
- msgid "Password"
128
- msgstr ""
129
-
130
168
  #: views/accounts/register/imap-server.hbs:59
131
169
  #: views/accounts/register/imap-server.hbs:166
132
170
  msgid "Important"
@@ -231,38 +269,6 @@ msgstr ""
231
269
  msgid "Request failed."
232
270
  msgstr ""
233
271
 
234
- #: views/accounts/register/imap.hbs:13
235
- msgid "Your name"
236
- msgstr ""
237
-
238
- #: views/accounts/register/imap.hbs:19
239
- msgid "Enter your full name"
240
- msgstr ""
241
-
242
- #: views/accounts/register/imap.hbs:35
243
- msgid "This setup link is restricted to this email address"
244
- msgstr ""
245
-
246
- #: views/accounts/register/imap.hbs:37
247
- msgid "Enter your email address"
248
- msgstr ""
249
-
250
- #: views/accounts/register/imap.hbs:49
251
- msgid "Enter your account password"
252
- msgstr ""
253
-
254
- #: views/accounts/register/imap.hbs:55
255
- msgid "Continue"
256
- msgstr ""
257
-
258
- #: views/accounts/register/index.hbs:6
259
- msgid "Choose your email account provider"
260
- msgstr ""
261
-
262
- #: views/accounts/register/index.hbs:19
263
- msgid "Standard IMAP"
264
- msgstr ""
265
-
266
272
  #: views/account-identity-error.hbs:7
267
273
  msgid "Wrong Email Account"
268
274
  msgstr ""
@@ -287,7 +293,7 @@ msgid ""
287
293
  "contact the service that sent you this link."
288
294
  msgstr ""
289
295
 
290
- #: lib/autodetect-imap-settings.js:134
296
+ #: lib/autodetect-imap-settings.js:151
291
297
  msgid ""
292
298
  "Microsoft has disabled password-based sign-ins (including app passwords) "
293
299
  "for Outlook.com, Hotmail.com, and Microsoft 365 email accounts. To "
@@ -295,19 +301,19 @@ msgid ""
295
301
  "connect your account."
296
302
  msgstr ""
297
303
 
298
- #: lib/tools.js:1534
304
+ #: lib/tools.js:1526
299
305
  #: lib/ui-routes/unsubscribe-routes.js:31
300
306
  #: lib/ui-routes/unsubscribe-routes.js:99
301
307
  msgid "Invalid input"
302
308
  msgstr ""
303
309
 
304
- #: lib/tools.js:2399
310
+ #: lib/tools.js:2391
305
311
  msgid "Signature validation failed"
306
312
  msgstr ""
307
313
 
308
- #: lib/tools.js:2422
309
- #: lib/tools.js:2428
310
- #: lib/tools.js:2433
314
+ #: lib/tools.js:2414
315
+ #: lib/tools.js:2420
316
+ #: lib/tools.js:2425
311
317
  #: lib/ui-routes/account-routes.js:1157
312
318
  msgid "Invalid or expired account setup URL"
313
319
  msgstr ""
@@ -319,8 +325,8 @@ msgstr ""
319
325
  #: lib/ui-routes/account-routes.js:883
320
326
  #: lib/ui-routes/account-routes.js:1270
321
327
  #: lib/ui-routes/route-helpers.js:403
322
- #: workers/api.js:2291
323
- #: workers/api.js:2361
328
+ #: workers/api.js:2302
329
+ #: workers/api.js:2372
324
330
  msgid "Email Account Setup"
325
331
  msgstr ""
326
332
 
@@ -341,25 +347,25 @@ msgstr ""
341
347
 
342
348
  #: lib/ui-routes/account-routes.js:958
343
349
  #: lib/ui-routes/account-routes.js:998
344
- #: lib/ui-routes/admin-entities-routes.js:2077
350
+ #: lib/ui-routes/admin-entities-routes.js:2078
345
351
  msgid "Server hostname was not found"
346
352
  msgstr ""
347
353
 
348
354
  #: lib/ui-routes/account-routes.js:961
349
355
  #: lib/ui-routes/account-routes.js:1001
350
- #: lib/ui-routes/admin-entities-routes.js:2080
356
+ #: lib/ui-routes/admin-entities-routes.js:2081
351
357
  msgid "Invalid username or password"
352
358
  msgstr ""
353
359
 
354
360
  #: lib/ui-routes/account-routes.js:966
355
361
  #: lib/ui-routes/account-routes.js:1018
356
- #: lib/ui-routes/admin-entities-routes.js:2097
362
+ #: lib/ui-routes/admin-entities-routes.js:2098
357
363
  msgid "Connection timed out"
358
364
  msgstr ""
359
365
 
360
366
  #: lib/ui-routes/account-routes.js:972
361
367
  #: lib/ui-routes/account-routes.js:1021
362
- #: lib/ui-routes/admin-entities-routes.js:2100
368
+ #: lib/ui-routes/admin-entities-routes.js:2101
363
369
  msgid "Could not connect to server"
364
370
  msgstr ""
365
371
 
@@ -367,23 +373,23 @@ msgstr ""
367
373
  #: lib/ui-routes/account-routes.js:989
368
374
  #: lib/ui-routes/account-routes.js:1010
369
375
  #: lib/ui-routes/account-routes.js:1014
370
- #: lib/ui-routes/admin-entities-routes.js:2089
371
- #: lib/ui-routes/admin-entities-routes.js:2093
376
+ #: lib/ui-routes/admin-entities-routes.js:2090
377
+ #: lib/ui-routes/admin-entities-routes.js:2094
372
378
  msgid "TLS protocol error"
373
379
  msgstr ""
374
380
 
375
381
  #: lib/ui-routes/account-routes.js:1004
376
- #: lib/ui-routes/admin-entities-routes.js:2083
382
+ #: lib/ui-routes/admin-entities-routes.js:2084
377
383
  msgid "Authentication credentials were not provided"
378
384
  msgstr ""
379
385
 
380
386
  #: lib/ui-routes/account-routes.js:1007
381
- #: lib/ui-routes/admin-entities-routes.js:2086
387
+ #: lib/ui-routes/admin-entities-routes.js:2087
382
388
  msgid "OAuth2 authentication failed"
383
389
  msgstr ""
384
390
 
385
391
  #: lib/ui-routes/account-routes.js:1024
386
- #: lib/ui-routes/admin-entities-routes.js:2103
392
+ #: lib/ui-routes/admin-entities-routes.js:2104
387
393
  msgid "Unexpected server response"
388
394
  msgstr ""
389
395
 
@@ -391,7 +397,7 @@ msgstr ""
391
397
  msgid "Temporary error, please try again"
392
398
  msgstr ""
393
399
 
394
- #: lib/ui-routes/admin-config-routes.js:182
400
+ #: lib/ui-routes/admin-config-routes.js:193
395
401
  msgid "Invalid API key for OpenAI"
396
402
  msgstr ""
397
403
 
@@ -445,37 +451,37 @@ msgstr ""
445
451
  msgid "Couldn't process request. Try again."
446
452
  msgstr ""
447
453
 
448
- #: workers/api.js:2220
454
+ #: workers/api.js:2231
449
455
  msgid ""
450
456
  "The sign-in was cancelled or the requested access was not granted. Open the "
451
457
  "account setup link again to retry."
452
458
  msgstr ""
453
459
 
454
- #: workers/api.js:2229
460
+ #: workers/api.js:2240
455
461
  msgid "Sign-in with the email provider failed: %s"
456
462
  msgstr ""
457
463
 
458
- #: workers/api.js:2233
464
+ #: workers/api.js:2244
459
465
  msgid "Sign-in with the email provider failed: no authorization code was received"
460
466
  msgstr ""
461
467
 
462
- #: workers/api.js:2239
468
+ #: workers/api.js:2250
463
469
  msgid "Sign-in with the email provider failed: the request state is not valid"
464
470
  msgstr ""
465
471
 
466
- #: workers/api.js:2245
472
+ #: workers/api.js:2256
467
473
  msgid ""
468
474
  "The account setup session has expired or was already used. Open the account "
469
475
  "setup link again to retry."
470
476
  msgstr ""
471
477
 
472
- #: workers/api.js:2252
478
+ #: workers/api.js:2263
473
479
  msgid ""
474
480
  "Sign-in with the email provider failed: the stored setup session is not "
475
481
  "valid"
476
482
  msgstr ""
477
483
 
478
- #: workers/api.js:3118
479
- #: workers/api.js:3233
484
+ #: workers/api.js:3129
485
+ #: workers/api.js:3244
480
486
  msgid "Requested page not found"
481
487
  msgstr ""
@@ -17,6 +17,6 @@ what a browser that did not run the script gets. --}}
17
17
 
18
18
  {{> ui/btn label="Continue" href=ssoRedirectUrl id="sso-continue" icon="icon-[tabler--login-2]" class="btn-block"}}
19
19
 
20
- <script nonce="{{cspNonce}}">
20
+ <script data-cfasync="false" nonce="{{cspNonce}}">
21
21
  window.location.replace(document.getElementById('sso-continue').href);
22
22
  </script>
@@ -137,5 +137,5 @@ Are you sure you want to remove <strong class="delete-target-name"></strong>? Yo
137
137
  </div>
138
138
  {{/ui/modal}}
139
139
 
140
- <script src="/static/vendor/simplewebauthn/browser.min.js"></script>
141
- <script src="/static/js/passkey-register.js"></script>
140
+ <script data-cfasync="false" src="/static/vendor/simplewebauthn/browser.min.js"></script>
141
+ <script data-cfasync="false" src="/static/js/passkey-register.js"></script>
@@ -951,7 +951,7 @@ submitLabel="Delete account"}}
951
951
  {{!-- no #crumb input: the layout already renders the element the script reads --}}
952
952
  <input type="hidden" id="account-id" value="{{account.account}}">
953
953
 
954
- <script nonce="{{cspNonce}}">
954
+ <script data-cfasync="false" nonce="{{cspNonce}}">
955
955
  document.addEventListener('DOMContentLoaded', () => {
956
956
 
957
957
  const reconnectAccount = async () => {
@@ -1365,7 +1365,7 @@ submitLabel="Delete account"}}
1365
1365
  });
1366
1366
  </script>
1367
1367
 
1368
- <script nonce="{{cspNonce}}">
1368
+ <script data-cfasync="false" nonce="{{cspNonce}}">
1369
1369
  document.addEventListener('DOMContentLoaded', () => {
1370
1370
  let aborted = false;
1371
1371
 
@@ -26,7 +26,7 @@
26
26
  </div>
27
27
  {{/ui/modal}}
28
28
 
29
- <script type="module" nonce="{{cspNonce}}">
29
+ <script data-cfasync="false" type="module" nonce="{{cspNonce}}">
30
30
  import { EmailEngineClient } from '/static/js/ee-client.js';
31
31
 
32
32
  // Create client with UI container. The embed follows the admin theme -
@@ -140,7 +140,7 @@
140
140
 
141
141
  <input type="hidden" id="availablePaths" value="{{availablePaths}}">
142
142
 
143
- <script nonce="{{cspNonce}}">
143
+ <script data-cfasync="false" nonce="{{cspNonce}}">
144
144
  document.addEventListener('DOMContentLoaded', () => {
145
145
  let availablePaths = JSON.parse(document.getElementById('availablePaths').value);
146
146
  // native datalist suggestions for the Sent Mail folder input (the
@@ -290,7 +290,7 @@ focus ring on) the corner close button --}}
290
290
 
291
291
  <input type="hidden" id="autoTest" value="{{#if autoTest}}true{{/if}}">
292
292
 
293
- <script nonce="{{cspNonce}}">
293
+ <script data-cfasync="false" nonce="{{cspNonce}}">
294
294
  document.addEventListener('DOMContentLoaded', () => {
295
295
 
296
296
  let formTested = false;
@@ -311,7 +311,7 @@ defaultTestPayload='{"account":"test","path":"INBOX","subject":"test email"}'}}
311
311
 
312
312
  <input type="hidden" id="defaultPromptJson" value="{{defaultPromptJson}}">
313
313
 
314
- <script nonce="{{cspNonce}}">
314
+ <script data-cfasync="false" nonce="{{cspNonce}}">
315
315
  document.addEventListener('DOMContentLoaded', () => {
316
316
 
317
317
  const editorPrompt = uiAceEditor("editor-prompt", "markdown", document.getElementById('openAiPromptElement').value, {
@@ -79,9 +79,9 @@
79
79
 
80
80
 
81
81
  {{> ace_assets}}
82
- <script src="/static/js/ace/ext-language_tools.js"></script>
82
+ <script data-cfasync="false" src="/static/js/ace/ext-language_tools.js"></script>
83
83
 
84
- <script nonce="{{cspNonce}}">
84
+ <script data-cfasync="false" nonce="{{cspNonce}}">
85
85
  document.addEventListener('DOMContentLoaded', () => {
86
86
 
87
87
  const editors = new Map();
@@ -171,7 +171,7 @@
171
171
  </form>
172
172
  {{/ui/modal}}
173
173
 
174
- <script nonce="{{cspNonce}}">
174
+ <script data-cfasync="false" nonce="{{cspNonce}}">
175
175
  document.addEventListener('DOMContentLoaded', () => {
176
176
 
177
177
  const sendQuestionPayload = async () => {
@@ -116,7 +116,7 @@
116
116
 
117
117
  </form>
118
118
 
119
- <script nonce="{{cspNonce}}">
119
+ <script data-cfasync="false" nonce="{{cspNonce}}">
120
120
  document.addEventListener('DOMContentLoaded', () => {
121
121
 
122
122
  const sendTestPayload = async () => {
@@ -139,7 +139,7 @@
139
139
 
140
140
  <input type="hidden" id="availableAddresses" value="{{availableAddresses}}">
141
141
 
142
- <script nonce="{{cspNonce}}">
142
+ <script data-cfasync="false" nonce="{{cspNonce}}">
143
143
  document.addEventListener('DOMContentLoaded', () => {
144
144
 
145
145
  let availableAddresses = document.getElementById('availableAddresses').value.split(',').map(e => e.trim()).filter(e => e);
@@ -122,7 +122,7 @@ 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,9 +1,11 @@
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
+ Let AI agents manage this EmailEngine instance over the Model Context Protocol, and optionally work with the
5
+ connected mailboxes. The MCP endpoint exposes two tool sets behind two scopes: management (accounts, settings,
6
+ OAuth2 applications, gateways, tokens, the license, queues and logs) and mail (list and search messages, read
7
+ content, organize and delete messages, create drafts, send mail). It accepts the same access tokens as the REST
8
+ API.
7
9
  </p>
8
10
 
9
11
  <div class="mb-6 alert alert-soft alert-info">
@@ -46,8 +48,8 @@
46
48
  checked=values.mcpEnabled error=errors.mcpEnabled}}
47
49
  <span class="helper-text">Serves the Model Context Protocol at <code>/mcp</code>. The
48
50
  <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>
51
+ generates access tokens and ready-to-paste setup for clients; a token with the <code>mcp-manage</code> or
52
+ <code>mcp</code> scope works only here and not against the REST API.</span>
51
53
  </div>
52
54
 
53
55
  {{!-- Nested rather than a peer: OAuth is a sub-option of an endpoint that is already on,
@@ -105,8 +107,9 @@
105
107
 
106
108
  {{#> ui/card bodyClass="space-y-4"}}
107
109
 
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>
110
+ <p class="text-sm">Generate an access token and ready-to-paste client configuration in one step. The token gets the MCP
111
+ scopes you choose below (<code>mcp-manage</code> for the instance, <code>mcp</code> for mail), so it works against
112
+ the MCP endpoint and nothing else.</p>
110
113
 
111
114
  {{#unless canProvision}}
112
115
  <div class="alert alert-soft alert-warning text-sm">
@@ -115,28 +118,33 @@
115
118
  </div>
116
119
  {{/unless}}
117
120
 
118
- <div id="mcpTokenGen" data-presets="{{json mcpAccessPresets}}" data-mcp-url="{{mcpUrl}}" class="space-y-4">
121
+ <div id="mcpTokenGen" data-mcp-url="{{mcpUrl}}" class="space-y-4">
119
122
  {{!-- One column on purpose: two-up put the account field a full screen away from its
120
123
  label-mate on wide displays, and the form reads as one top-to-bottom flow --}}
121
124
  {{> ui/form-field id="mcpGenLabel" label="What is this token for?" placeholder="for example Cursor or Claude"
122
125
  hint="Shows up as the token description, so you can tell agents apart on the Access Tokens page."}}
123
126
 
124
- {{> mcp_account_limit id="mcpGenAccount"}}
125
-
127
+ {{!-- The same two sections, in the same order and from the same table, as the OAuth consent
128
+ prompt: management first, mail declined unless picked. The radio group of a section is
129
+ named mcpGen_<key>, which is what ui.js reads the selection back from. --}}
130
+ {{#each mcpSections}}
126
131
  <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>
132
+ <legend class="label-text mb-1">{{label}}</legend>
133
+ {{> mcp_access_levels section=this name=(concat "mcpGen_" @key) idPrefix=(concat "mcpGen_" @key) selected=defaultLevel includeNone=true}}
139
134
  </fieldset>
135
+ {{/each}}
136
+
137
+ {{!-- At the decision point rather than only in the collapsed manual-config block: the
138
+ level chosen here is what decides whether injected instructions can act --}}
139
+ <p class="text-base-content/60 text-sm">Email content flows into whatever model the connected client runs, and
140
+ instructions inside received mail can steer it - grant sending and deleting rights deliberately.</p>
141
+
142
+ {{> mcp_account_limit id="mcpGenAccount"}}
143
+
144
+ {{!-- What the selected levels actually leave the client able to call, which the level names
145
+ alone cannot say: the count follows both sections and the account limit, exactly as
146
+ tools/list will --}}
147
+ {{> mcp_tool_count id="mcpGenToolCount" autoWire=true levelPrefix="mcpGen_" accountId="mcpGenAccount" class="pt-1"}}
140
148
 
141
149
  <div class="flex items-center gap-3">
142
150
  {{#if canProvision}}
@@ -166,8 +174,9 @@
166
174
  </div>
167
175
 
168
176
  <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.
177
+ Every connected agent is an ordinary access token with the <code>mcp-manage</code> or <code>mcp</code> scope -
178
+ review or revoke them on the <a href="/admin/tokens?scope=mcp-manage&amp;scope=mcp" class="link">Access
179
+ Tokens</a> page.
171
180
  </div>
172
181
  </div>
173
182
 
@@ -256,10 +265,10 @@
256
265
  <ol class="text-base-content/80 ms-4 mt-1 list-decimal space-y-1 text-sm">
257
266
  <li>When you connect, the client opens this instance's authorization prompt in the browser. Sign in with the
258
267
  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>
268
+ <li>On the prompt, pick what the connector may manage (observing the instance is the default), switch on mail
269
+ access if it should read mail, optionally limit it to a single account, then approve.</li>
270
+ <li>The connector receives its own access token with the MCP scopes you chose - review or revoke it at any
271
+ time on the <a href="/admin/tokens?scope=mcp-manage&amp;scope=mcp" class="link">Access Tokens</a> page.</li>
263
272
  </ol>
264
273
  </div>
265
274
 
@@ -272,29 +281,50 @@
272
281
  </div>
273
282
 
274
283
  {{!-- 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>
284
+ {{#> ui/details summary="Exposed tools" summarySmall=(concat toolCatalog.total " tools") class="card bg-base-100 shadow-md mb-6"}}
285
+ <div class="space-y-6">
286
+ <p class="text-sm text-base-content/60">This is exactly what a connected agent receives from
287
+ <code>tools/list</code>, grouped by the scope that reaches each tool. Whether a given token can call a tool
288
+ also depends on its access level and account binding.</p>
289
+ {{#each toolCatalog.sections}}
290
+ <div>
291
+ <h6 class="mb-2 font-bold">{{label}} <span class="text-base-content/60 font-normal">({{tools.length}} tools,
292
+ <code>{{scope}}</code>)</span></h6>
293
+ <div class="space-y-3">
294
+ {{#each tools}}
295
+ <div class="flex flex-wrap items-baseline gap-2">
296
+ <code>{{name}}</code>
297
+ {{> ui/badge label=badge.label variant=badge.variant soft=true}}
298
+ {{#if shared}}{{> ui/badge label="both scopes" variant="neutral" soft=true}}{{/if}}
299
+ <span class="text-sm text-base-content/60 basis-full sm:basis-auto sm:grow">{{description}}</span>
300
+ </div>
301
+ {{/each}}
302
+ </div>
303
+ </div>
304
+ {{/each}}
305
+ {{#if toolCatalog.unreached.length}}
306
+ <div>
307
+ <h6 class="mb-2 font-bold">Not offered by any MCP scope</h6>
308
+ <div class="space-y-3">
309
+ {{#each toolCatalog.unreached}}
310
+ <div class="flex flex-wrap items-baseline gap-2">
311
+ <code>{{name}}</code>
312
+ <span class="text-sm text-base-content/60 basis-full sm:basis-auto sm:grow">{{description}}</span>
313
+ </div>
314
+ {{/each}}
286
315
  </div>
287
- {{/each}}
288
316
  </div>
317
+ {{/if}}
289
318
  </div>
290
319
  {{/ui/details}}
291
320
 
292
321
  </div>
293
322
 
294
- <script nonce="{{cspNonce}}">
323
+ <script data-cfasync="false" nonce="{{cspNonce}}">
295
324
  (() => {
296
325
  let container = document.getElementById('mcpTokenGen');
297
- let presets = JSON.parse(container.dataset.presets || '{}');
326
+ // The section table is embedded once, on the tool count element ui.js wires
327
+ let sections = JSON.parse(document.getElementById('mcpGenToolCount').dataset.mcpSections || '{}');
298
328
  let mcpUrl = container.dataset.mcpUrl;
299
329
 
300
330
  // The one place each artifact is written; the manual block shows them with a
@@ -323,25 +353,31 @@
323
353
 
324
354
  let label = (document.getElementById('mcpGenLabel').value || '').trim() || 'MCP agent';
325
355
  let account = (document.getElementById('mcpGenAccount').value || '').trim();
326
- let accessElm = document.querySelector('input[name="mcpGenAccess"]:checked');
327
- let access = (accessElm && accessElm.value) || 'read';
356
+ let choice = uiMcpLevelChoice(sections, 'mcpGen_');
328
357
 
329
358
  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.');
359
+ if (!sections.manage || !sections.mail) {
360
+ // A missing table must not silently mint a wider credential than the
361
+ // selected levels promise
362
+ throw new Error('The access levels failed to load. Reload the page and try again.');
363
+ }
364
+
365
+ // The same union the consent prompt mints, computed by the shared helper: the
366
+ // scopes of the sections that were not declined and the grant pairs of their
367
+ // levels. A token always carries its grants explicitly, so what the operator saw
368
+ // is exactly what the credential holds.
369
+ let record = uiMcpLevelRecord(sections, choice);
370
+ if (!record.surfaces.length) {
371
+ throw new Error('Choose at least one kind of access.');
334
372
  }
335
373
 
336
374
  let data = await uiPostJson('/admin/tokens/new', {
337
375
  description: 'MCP: ' + label,
338
- scopes: ['mcp'],
376
+ scopes: record.surfaces,
339
377
  // The empty string, not null: accountIdSchema is `Joi.string().empty('')`,
340
378
  // which converts '' to the schema default and refuses an explicit null
341
379
  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]
380
+ permissions: { grants: record.grants }
345
381
  });
346
382
 
347
383
  if (!data.success) {
@@ -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