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.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +24 -0
- package/README.md +6 -0
- package/data/google-crawlers.json +1 -1
- package/lib/api-routes/account-routes.js +81 -1
- package/lib/api-routes/blocklist-routes.js +24 -0
- package/lib/api-routes/delivery-test-routes.js +6 -0
- package/lib/api-routes/gateway-routes.js +30 -0
- package/lib/api-routes/license-routes.js +10 -0
- package/lib/api-routes/mcp-oauth-routes.js +3 -3
- package/lib/api-routes/mcp-routes.js +39 -21
- package/lib/api-routes/oauth2-app-routes.js +38 -1
- package/lib/api-routes/outbox-routes.js +6 -0
- package/lib/api-routes/permission-map.js +208 -43
- package/lib/api-routes/pubsub-routes.js +8 -0
- package/lib/api-routes/route-helpers.js +58 -11
- package/lib/api-routes/settings-routes.js +50 -4
- package/lib/api-routes/stats-routes.js +6 -0
- package/lib/api-routes/template-routes.js +21 -0
- package/lib/api-routes/token-routes.js +34 -2
- package/lib/api-routes/webhook-route-routes.js +13 -0
- package/lib/email-client/base-client.js +6 -3
- package/lib/email-client/credential-errors.js +4 -0
- package/lib/email-client/imap/login-failure.js +52 -0
- package/lib/email-client/imap/subconnection.js +2 -1
- package/lib/email-client/imap-client.js +3 -6
- package/lib/enum-descriptions.js +12 -2
- package/lib/imapproxy/imap-server.js +1 -1
- package/lib/mcp/oauth.js +46 -8
- package/lib/mcp/protocol.js +78 -35
- package/lib/mcp/tools.js +53 -17
- package/lib/privileged-settings.js +147 -0
- package/lib/schemas.js +60 -16
- package/lib/settings.js +13 -0
- package/lib/tls/catalog.js +428 -0
- package/lib/tls/context.js +87 -161
- package/lib/tls/listeners.js +62 -0
- package/lib/tls/status.js +128 -79
- package/lib/tls/store.js +3 -2
- package/lib/token-permission-view.js +252 -102
- package/lib/token-permissions.js +176 -26
- package/lib/tokens.js +7 -6
- package/lib/tools.js +4 -3
- package/lib/ui-routes/admin-config-routes.js +41 -21
- package/lib/ui-routes/admin-entities-routes.js +23 -13
- package/lib/ui-routes/mcp-consent-routes.js +72 -31
- package/lib/ui-routes/tls-config-routes.js +121 -74
- package/package.json +12 -12
- package/sbom.json +1 -1
- package/server.js +7 -1
- package/static/css/flyonui.css +1 -1
- package/static/js/ui.js +89 -36
- package/static/licenses.html +46 -28
- package/translations/messages.pot +74 -68
- package/views/account/login-redirect.hbs +1 -1
- package/views/account/passkeys.hbs +2 -2
- package/views/accounts/account.hbs +2 -2
- package/views/accounts/browse.hbs +1 -1
- package/views/accounts/edit.hbs +1 -1
- package/views/accounts/register/imap-server.hbs +1 -1
- package/views/config/ai.hbs +1 -1
- package/views/config/branding.hbs +2 -2
- package/views/config/document-store/chat.hbs +1 -1
- package/views/config/document-store/index.hbs +1 -1
- package/views/config/imap-proxy.hbs +1 -1
- package/views/config/license.hbs +1 -1
- package/views/config/mcp.hbs +88 -52
- package/views/config/network.hbs +1 -1
- package/views/config/oauth/app.hbs +2 -2
- package/views/config/service.hbs +1 -1
- package/views/config/smtp.hbs +1 -1
- package/views/config/tls.hbs +266 -165
- package/views/config/webhooks.hbs +2 -2
- package/views/internals/index.hbs +1 -1
- package/views/layout/app.hbs +6 -6
- package/views/layout/login.hbs +5 -5
- package/views/layout/main.hbs +2 -2
- package/views/layout/prompt.hbs +3 -3
- package/views/layout/public.hbs +1 -1
- package/views/mcp/authorize.hbs +47 -45
- package/views/partials/ace_assets.hbs +1 -1
- package/views/partials/add_account_modal.hbs +1 -1
- package/views/partials/filter_editor_js.hbs +2 -2
- package/views/partials/gateway_js.hbs +1 -1
- package/views/partials/mcp_access_levels.hbs +16 -9
- package/views/partials/mcp_tool_count.hbs +15 -14
- package/views/partials/oauth_form.hbs +1 -1
- package/views/partials/public_theme_init.hbs +1 -1
- package/views/partials/template_form.hbs +1 -1
- package/views/partials/theme_init.hbs +1 -1
- package/views/partials/webhooks_editor_functions.hbs +1 -1
- package/views/reference/index.hbs +1 -1
- package/views/reference/redirect.hbs +1 -1
- package/views/reference/tag.hbs +1 -1
- package/views/reference/token.hbs +1 -1
- package/views/templates/template.hbs +1 -1
- package/views/tokens/new.hbs +175 -74
- package/views/unsubscribe.hbs +1 -1
- package/views/webhooks/webhook.hbs +1 -1
- package/workers/api.js +9 -8
- package/workers/smtp.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.80.1](https://github.com/postalsys/emailengine/compare/v2.80.0...v2.80.1) (2026-09-10)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **accounts:** stop a delete in the startup window from reporting a failure ([b41896b](https://github.com/postalsys/emailengine/commit/b41896b6706a8165b5481db39abff2f4e3299a13))
|
|
9
|
+
* **admin:** keep the admin UI working behind an HTML-rewriting CDN ([c2e6596](https://github.com/postalsys/emailengine/commit/c2e659687f909e8eaa416407b0fb0b4e5c19ba09))
|
|
10
|
+
* **deps:** update imapflow to 2.0.1 for the Exchange Online IMAP4rev2 advertisement ([a6b1b8f](https://github.com/postalsys/emailengine/commit/a6b1b8f0408a404aca76c8d89e894538eb97f00f))
|
|
11
|
+
* **deps:** update imapflow to 2.0.2, bull-board to 9.10.0 and @postalsys/certs to 1.4.1 ([2817f41](https://github.com/postalsys/emailengine/commit/2817f4134437f75e8c1a27049c850d28adc6351c))
|
|
12
|
+
* **deps:** update nodemailer to 10.0.3 across the packages that pin it ([a791216](https://github.com/postalsys/emailengine/commit/a7912162425c8d7e5bcd3ae020ca875b9d950c91))
|
|
13
|
+
* **imap:** report a login the server could not serve as a connection failure, and announce a repeated failure once ([832d6ab](https://github.com/postalsys/emailengine/commit/832d6ab966e0ad0f490aa3137f8130520d12de13))
|
|
14
|
+
* **mcp:** add the mcp-manage surface scope ([4f5043c](https://github.com/postalsys/emailengine/commit/4f5043c0dc118e73fe90cc0851cb110856d6239e))
|
|
15
|
+
* **mcp:** expose the instance management tools ([08f35a8](https://github.com/postalsys/emailengine/commit/08f35a8a1433bfbf1c14d4f03051876bd7bd2571))
|
|
16
|
+
* **mcp:** keep the connection check out of the Observe level and the service URL out of a settings grant ([e85de25](https://github.com/postalsys/emailengine/commit/e85de254950f6d65e8c342f4f7b371fb96428704))
|
|
17
|
+
* **mcp:** keep the TLS mode and mail certificate checking out of a settings grant ([ad6428f](https://github.com/postalsys/emailengine/commit/ad6428ff5c4bdee1421fc1568a6b1810a9598894))
|
|
18
|
+
* **mcp:** offer instance management first on the consent prompt, the generator and the token form ([6022a5c](https://github.com/postalsys/emailengine/commit/6022a5cfa3d792d8b3fe0e08bfa3bfa324d7a500))
|
|
19
|
+
* **mcp:** read every MCP access decision off one section table ([136c860](https://github.com/postalsys/emailengine/commit/136c860f7586a23c644899526c995ff2533034cd))
|
|
20
|
+
* **tls:** let each listener choose the certificate it presents by default ([056ff8f](https://github.com/postalsys/emailengine/commit/056ff8feb4b9cc990b08c8c0484bac0c044a1e28))
|
|
21
|
+
* **tokens:** accept a per-section grant list on token permissions ([ca6ff34](https://github.com/postalsys/emailengine/commit/ca6ff34f8a13cab3f65c614ab5df4644b3bdfa09))
|
|
22
|
+
* **tokens:** keep a record that names no groups out of the sections the admin split created ([d817416](https://github.com/postalsys/emailengine/commit/d81741690a32c26329f0e993bb1f0ce16414f2dc))
|
|
23
|
+
* **tokens:** keep the built-in listeners and the AI endpoint out of a settings grant ([d069dd7](https://github.com/postalsys/emailengine/commit/d069dd7e706f39791e0591e134286cb17e699f66))
|
|
24
|
+
* **tokens:** make the management endpoints grantable in their own sections ([4f975bf](https://github.com/postalsys/emailengine/commit/4f975bf72aeb818bcb3b64c98473f7eef92d040b))
|
|
25
|
+
* **ui:** rebuild the stylesheet so the MCP configuration page gets its section spacing ([e99bd30](https://github.com/postalsys/emailengine/commit/e99bd30644442ced19bfa82f4139076352db7c17))
|
|
26
|
+
|
|
3
27
|
## [2.80.0](https://github.com/postalsys/emailengine/compare/v2.79.9...v2.80.0) (2026-09-09)
|
|
4
28
|
|
|
5
29
|
|
package/README.md
CHANGED
|
@@ -68,6 +68,12 @@ Refer to the [configuration documentation](https://learn.emailengine.app/docs/co
|
|
|
68
68
|
|
|
69
69
|
By default, EmailEngine only allows connections from localhost. To enable external access, either edit the config file or use the CLI option `--api.host="0.0.0.0"`. Ensure to secure external access with a firewall or proxy to allow only trusted sources.
|
|
70
70
|
|
|
71
|
+
### Content-Security-Policy
|
|
72
|
+
|
|
73
|
+
Since v2.79.9 the admin interface is served with a nonce-based Content-Security-Policy, so only the scripts EmailEngine rendered will run. A CDN or proxy that rewrites the HTML on its way to the browser breaks that, because the scripts it re-creates do not carry the nonce. Cloudflare's Rocket Loader is the common case: the admin pages still render, but nothing on them works, and the browser console reports blocked inline scripts. Turn such an optimizer off for the hostname EmailEngine is served from.
|
|
74
|
+
|
|
75
|
+
Set `EENGINE_CSP_MODE=report-only` to keep the policy out of the way while still logging violations to the browser console, or `EENGINE_CSP_MODE=off` to send only the framing protection. See the [configuration documentation](https://learn.emailengine.app/docs/configuration/environment-variables).
|
|
76
|
+
|
|
71
77
|
## Deployment
|
|
72
78
|
|
|
73
79
|
### Ubuntu or Debian
|
|
@@ -11,7 +11,7 @@ const { autodetectImapSettings } = require('../autodetect-imap-settings');
|
|
|
11
11
|
const Boom = require('@hapi/boom');
|
|
12
12
|
const Joi = require('joi');
|
|
13
13
|
const { failAction, getSignedFormData, getLogs, verifyAccountInfo } = require('../tools');
|
|
14
|
-
const { handleError, maskSecrets, MASKED, MASK_NOTE } = require('./route-helpers');
|
|
14
|
+
const { handleError, maskSecrets, assertNoNetworkOverride, MASKED, MASK_NOTE } = require('./route-helpers');
|
|
15
15
|
|
|
16
16
|
const {
|
|
17
17
|
settingsSchema,
|
|
@@ -106,6 +106,10 @@ async function init(args) {
|
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
try {
|
|
109
|
+
// A narrowed provisioning token may add an account, but not route its connection
|
|
110
|
+
// through a host of its own choosing - the same rule the submit routes apply
|
|
111
|
+
assertNoNetworkOverride(request);
|
|
112
|
+
|
|
109
113
|
if (request.payload.oauth2 && request.payload.oauth2.authorize) {
|
|
110
114
|
// redirect to OAuth2 consent screen
|
|
111
115
|
|
|
@@ -186,6 +190,13 @@ async function init(args) {
|
|
|
186
190
|
tags: ['api', 'Account'],
|
|
187
191
|
|
|
188
192
|
plugins: {
|
|
193
|
+
mcp: {
|
|
194
|
+
name: 'create_account',
|
|
195
|
+
title: 'Create account',
|
|
196
|
+
description:
|
|
197
|
+
'Register an email account. For an OAuth2 provider set oauth2.provider to the application id (from list_oauth2_apps) and oauth2.authorize to true: the response carries a redirect URL for the user to open and sign in, and no credentials are needed. For IMAP set imap and smtp with the host, port and auth the user supplied (autodiscover_settings finds the servers). Prefer create_account_setup_link when the user can open a link themselves, so no password passes through this conversation.',
|
|
198
|
+
omit: ['proxy', 'smtpEhloName', 'webhooksCustomHeaders', 'copy', 'locale', 'tz']
|
|
199
|
+
},
|
|
189
200
|
openapi: {
|
|
190
201
|
'x-ee-behavior': [BEHAVIOR.CREDENTIALS_VERIFIED_LATER],
|
|
191
202
|
responses: apiResponses(
|
|
@@ -341,6 +352,10 @@ async function init(args) {
|
|
|
341
352
|
});
|
|
342
353
|
|
|
343
354
|
try {
|
|
355
|
+
// The stored credential survives a partial update, so where the connection goes is
|
|
356
|
+
// the one thing a narrowed token must not decide (see the provisioning group)
|
|
357
|
+
assertNoNetworkOverride(request);
|
|
358
|
+
|
|
344
359
|
// Validate delegation fields are only used with OAuth2 provider
|
|
345
360
|
validateDelegationFields(request.payload);
|
|
346
361
|
|
|
@@ -358,6 +373,13 @@ async function init(args) {
|
|
|
358
373
|
tags: ['api', 'Account'],
|
|
359
374
|
|
|
360
375
|
plugins: {
|
|
376
|
+
mcp: {
|
|
377
|
+
name: 'update_account',
|
|
378
|
+
title: 'Update account',
|
|
379
|
+
description:
|
|
380
|
+
"Change an account's configuration: name, email, sync and notification settings, special folders, the webhook target, and the IMAP, SMTP or OAuth2 connection settings. Send only the fields to change. Changing a host makes the next connection authenticate to the new host with the stored credential, so confirm connection changes with the user.",
|
|
381
|
+
omit: ['proxy', 'smtpEhloName', 'webhooksCustomHeaders', 'copy', 'locale', 'tz']
|
|
382
|
+
},
|
|
361
383
|
openapi: {
|
|
362
384
|
'x-ee-behavior': [BEHAVIOR.CREDENTIALS_VERIFIED_LATER],
|
|
363
385
|
responses: apiResponses('Returns the account ID. Changed credentials take effect on the next connection.', 400, 401, 403, 404, 429, 500)
|
|
@@ -482,6 +504,14 @@ async function init(args) {
|
|
|
482
504
|
tags: ['api', 'Account'],
|
|
483
505
|
|
|
484
506
|
plugins: {
|
|
507
|
+
mcp: {
|
|
508
|
+
name: 'reconnect_account',
|
|
509
|
+
title: 'Reconnect account',
|
|
510
|
+
description:
|
|
511
|
+
"Ask the account's worker to close and re-open its connection. Use after fixing credentials or server settings, or when an account is stuck connecting.",
|
|
512
|
+
omit: ['reconnect'],
|
|
513
|
+
force: { reconnect: true }
|
|
514
|
+
},
|
|
485
515
|
openapi: {
|
|
486
516
|
'x-ee-behavior': [BEHAVIOR.SCHEDULED_ON_WORKER],
|
|
487
517
|
responses: apiResponses(
|
|
@@ -554,6 +584,13 @@ async function init(args) {
|
|
|
554
584
|
tags: ['api', 'Account'],
|
|
555
585
|
|
|
556
586
|
plugins: {
|
|
587
|
+
mcp: {
|
|
588
|
+
name: 'sync_account',
|
|
589
|
+
title: 'Sync account now',
|
|
590
|
+
description: "Ask the account's worker to run a sync now instead of waiting for the next scheduled one.",
|
|
591
|
+
omit: ['sync'],
|
|
592
|
+
force: { sync: true }
|
|
593
|
+
},
|
|
557
594
|
openapi: {
|
|
558
595
|
'x-ee-behavior': [BEHAVIOR.SCHEDULED_ON_WORKER],
|
|
559
596
|
responses: apiResponses(
|
|
@@ -631,6 +668,12 @@ async function init(args) {
|
|
|
631
668
|
tags: ['api', 'Account'],
|
|
632
669
|
|
|
633
670
|
plugins: {
|
|
671
|
+
mcp: {
|
|
672
|
+
name: 'delete_account',
|
|
673
|
+
title: 'Delete account',
|
|
674
|
+
description:
|
|
675
|
+
'Remove an account from this instance, with its synced index and the tokens bound to it. The mailbox at the provider is untouched. Set revoke to true to also revoke the OAuth2 grant at the provider. Confirm with the user before calling this.'
|
|
676
|
+
},
|
|
634
677
|
openapi: {
|
|
635
678
|
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
636
679
|
'x-ee-behavior': [BEHAVIOR.DELETION_SCOPE],
|
|
@@ -714,6 +757,14 @@ async function init(args) {
|
|
|
714
757
|
tags: ['api', 'Account'],
|
|
715
758
|
|
|
716
759
|
plugins: {
|
|
760
|
+
mcp: {
|
|
761
|
+
name: 'flush_account',
|
|
762
|
+
title: 'Flush and re-sync account',
|
|
763
|
+
description:
|
|
764
|
+
"Discard the account's local index and sync it again from scratch. Every existing message counts as new again, so webhooks fire for all of them; use only when the index is broken or the sync settings changed. Confirm with the user before calling this.",
|
|
765
|
+
omit: ['flush'],
|
|
766
|
+
force: { flush: true }
|
|
767
|
+
},
|
|
717
768
|
openapi: {
|
|
718
769
|
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
719
770
|
'x-ee-behavior': [BEHAVIOR.SCHEDULED_ON_WORKER],
|
|
@@ -1518,6 +1569,13 @@ async function init(args) {
|
|
|
1518
1569
|
tags: ['api', 'Account'],
|
|
1519
1570
|
|
|
1520
1571
|
plugins: {
|
|
1572
|
+
mcp: {
|
|
1573
|
+
name: 'create_account_setup_link',
|
|
1574
|
+
title: 'Create account setup link',
|
|
1575
|
+
description:
|
|
1576
|
+
'Create a one-time link to the hosted setup form, where the user signs in to their mailbox themselves, so no password passes through this conversation. Give the link to the user. Set redirectUrl to where they should land afterwards; optionally account (the id to assign), name, email, expectedEmail (the setup is refused if they sign in as someone else) and type (an OAuth2 application id, or imap).',
|
|
1577
|
+
keep: ['account', 'name', 'email', 'expectedEmail', 'redirectUrl', 'type']
|
|
1578
|
+
},
|
|
1521
1579
|
openapi: {
|
|
1522
1580
|
responses: apiResponses('Returns a single-use URL for the hosted authentication form.', 400, 401, 403, 404, 429, 500)
|
|
1523
1581
|
}
|
|
@@ -1629,6 +1687,12 @@ async function init(args) {
|
|
|
1629
1687
|
cors: CORS_CONFIG,
|
|
1630
1688
|
|
|
1631
1689
|
plugins: {
|
|
1690
|
+
mcp: {
|
|
1691
|
+
name: 'get_account_logs',
|
|
1692
|
+
title: 'Get account connection log',
|
|
1693
|
+
description:
|
|
1694
|
+
'Read the stored connection log of an account: the raw IMAP or provider API trace, which names folders, message ids and subjects. Use it to find out why an account fails to connect or sync. Only kept while logging is enabled for the account or for the whole instance.'
|
|
1695
|
+
},
|
|
1632
1696
|
openapi: {
|
|
1633
1697
|
'x-ee-behavior': [BEHAVIOR.ACCOUNT_LOG_SCOPE],
|
|
1634
1698
|
produces: ['text/plain'],
|
|
@@ -1657,6 +1721,7 @@ async function init(args) {
|
|
|
1657
1721
|
|
|
1658
1722
|
async handler(request) {
|
|
1659
1723
|
try {
|
|
1724
|
+
assertNoNetworkOverride(request);
|
|
1660
1725
|
return await verifyAccountInfo(redis, request.payload, request.logger.child({ action: 'verify-account' }));
|
|
1661
1726
|
} catch (err) {
|
|
1662
1727
|
handleError(request, err);
|
|
@@ -1668,6 +1733,14 @@ async function init(args) {
|
|
|
1668
1733
|
tags: ['api', 'Account'],
|
|
1669
1734
|
|
|
1670
1735
|
plugins: {
|
|
1736
|
+
mcp: {
|
|
1737
|
+
name: 'verify_account_settings',
|
|
1738
|
+
title: 'Verify account settings',
|
|
1739
|
+
description:
|
|
1740
|
+
'Test IMAP and SMTP settings without saving them: connects and authenticates with the supplied host, port and credentials and reports what failed. Set mailboxes to true to also list the folders. Useful before create_account or update_account.',
|
|
1741
|
+
omit: ['proxy', 'smtpEhloName'],
|
|
1742
|
+
openWorld: true
|
|
1743
|
+
},
|
|
1671
1744
|
openapi: {
|
|
1672
1745
|
'x-ee-impact': IMPACT.READONLY,
|
|
1673
1746
|
responses: apiResponses(
|
|
@@ -1745,6 +1818,13 @@ async function init(args) {
|
|
|
1745
1818
|
tags: ['api', 'Settings'],
|
|
1746
1819
|
|
|
1747
1820
|
plugins: {
|
|
1821
|
+
mcp: {
|
|
1822
|
+
name: 'autodiscover_settings',
|
|
1823
|
+
title: 'Discover mail server settings',
|
|
1824
|
+
description:
|
|
1825
|
+
"Discover the IMAP and SMTP server settings for an email address from DNS and the provider's autoconfiguration. The natural first step before create_account or verify_account_settings for a mailbox that does not use an OAuth2 application.",
|
|
1826
|
+
openWorld: true
|
|
1827
|
+
},
|
|
1748
1828
|
openapi: {
|
|
1749
1829
|
responses: apiResponses(
|
|
1750
1830
|
'Returns the discovered IMAP and SMTP settings for the address, or empty values when nothing could be resolved.',
|
|
@@ -10,6 +10,7 @@ const { failAction } = require('../tools');
|
|
|
10
10
|
const { handleError } = require('./route-helpers');
|
|
11
11
|
const { accountIdSchema, blocklistListIdSchema, apiResponses } = require('../schemas');
|
|
12
12
|
const { IMPACT } = require('./operation-impact');
|
|
13
|
+
const { MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
13
14
|
|
|
14
15
|
async function init(args) {
|
|
15
16
|
const { server, call, CORS_CONFIG } = args;
|
|
@@ -32,6 +33,12 @@ async function init(args) {
|
|
|
32
33
|
tags: ['api', 'Blocklists'],
|
|
33
34
|
|
|
34
35
|
plugins: {
|
|
36
|
+
mcp: {
|
|
37
|
+
name: 'list_blocklists',
|
|
38
|
+
title: 'List suppression lists',
|
|
39
|
+
description: 'List the suppression lists (blocklists) and how many addresses each holds, paged.',
|
|
40
|
+
bounds: { pageSize: MCP_MAX_PAGE_SIZE }
|
|
41
|
+
},
|
|
35
42
|
openapi: {
|
|
36
43
|
responses: apiResponses('Returns every blocklist with its entry count.', 400, 401, 403, 429, 500)
|
|
37
44
|
}
|
|
@@ -102,6 +109,12 @@ async function init(args) {
|
|
|
102
109
|
tags: ['api', 'Blocklists'],
|
|
103
110
|
|
|
104
111
|
plugins: {
|
|
112
|
+
mcp: {
|
|
113
|
+
name: 'get_blocklist',
|
|
114
|
+
title: 'Get suppression list',
|
|
115
|
+
description: 'List the addresses on one suppression list, paged, with the reason and source of each entry.',
|
|
116
|
+
bounds: { pageSize: MCP_MAX_PAGE_SIZE }
|
|
117
|
+
},
|
|
105
118
|
openapi: {
|
|
106
119
|
responses: apiResponses('Returns a page of entries on the blocklist.', 400, 401, 403, 404, 429, 500)
|
|
107
120
|
}
|
|
@@ -208,6 +221,12 @@ async function init(args) {
|
|
|
208
221
|
tags: ['api', 'Blocklists'],
|
|
209
222
|
|
|
210
223
|
plugins: {
|
|
224
|
+
mcp: {
|
|
225
|
+
name: 'add_to_blocklist',
|
|
226
|
+
title: 'Add to suppression list',
|
|
227
|
+
description:
|
|
228
|
+
'Add a recipient address to a suppression list, so messages sent with that list id are not delivered to it. Needs the account the block was raised for.'
|
|
229
|
+
},
|
|
211
230
|
openapi: {
|
|
212
231
|
responses: apiResponses('Returns whether the address was added or was already listed.', 400, 401, 403, 404, 429, 500)
|
|
213
232
|
}
|
|
@@ -276,6 +295,11 @@ async function init(args) {
|
|
|
276
295
|
tags: ['api', 'Blocklists'],
|
|
277
296
|
|
|
278
297
|
plugins: {
|
|
298
|
+
mcp: {
|
|
299
|
+
name: 'remove_from_blocklist',
|
|
300
|
+
title: 'Remove from suppression list',
|
|
301
|
+
description: 'Remove a recipient address from a suppression list, so messages to it are delivered again.'
|
|
302
|
+
},
|
|
279
303
|
openapi: {
|
|
280
304
|
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
281
305
|
responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 404, 429, 500)
|
|
@@ -278,6 +278,12 @@ ${now}`,
|
|
|
278
278
|
tags: ['api', 'Delivery Test'],
|
|
279
279
|
|
|
280
280
|
plugins: {
|
|
281
|
+
mcp: {
|
|
282
|
+
name: 'check_delivery_test',
|
|
283
|
+
title: 'Check delivery test',
|
|
284
|
+
description:
|
|
285
|
+
'Check the result of a delivery test started over the REST API: whether the probe message arrived, and its SPF, DKIM and DMARC results.'
|
|
286
|
+
},
|
|
281
287
|
openapi: {
|
|
282
288
|
responses: apiResponses(
|
|
283
289
|
'Returns the test result once it has completed, including SPF, DKIM and DMARC outcomes.',
|
|
@@ -9,6 +9,7 @@ const { handleError, maskSecrets, MASKED, MASK_NOTE } = require('./route-helpers
|
|
|
9
9
|
const { apiResponses } = require('../schemas');
|
|
10
10
|
const { ENUM_DESCRIPTIONS } = require('../enum-descriptions');
|
|
11
11
|
const { IMPACT } = require('./operation-impact');
|
|
12
|
+
const { MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
12
13
|
|
|
13
14
|
// Gateways store SMTP delivery errors, not OAuth2 errors, so the error shape differs from the
|
|
14
15
|
// account-level lastErrorSchema
|
|
@@ -60,6 +61,13 @@ async function init(args) {
|
|
|
60
61
|
tags: ['api', 'SMTP Gateway'],
|
|
61
62
|
|
|
62
63
|
plugins: {
|
|
64
|
+
mcp: {
|
|
65
|
+
name: 'list_gateways',
|
|
66
|
+
title: 'List SMTP gateways',
|
|
67
|
+
description:
|
|
68
|
+
"List the SMTP gateways (relay servers messages can be sent through instead of the account's own SMTP server), paged. Passwords are masked.",
|
|
69
|
+
bounds: { pageSize: MCP_MAX_PAGE_SIZE }
|
|
70
|
+
},
|
|
63
71
|
openapi: {
|
|
64
72
|
responses: apiResponses('Returns a page of configured SMTP gateways.', 400, 401, 403, 429, 500)
|
|
65
73
|
}
|
|
@@ -156,6 +164,11 @@ async function init(args) {
|
|
|
156
164
|
tags: ['api', 'SMTP Gateway'],
|
|
157
165
|
|
|
158
166
|
plugins: {
|
|
167
|
+
mcp: {
|
|
168
|
+
name: 'get_gateway',
|
|
169
|
+
title: 'Get SMTP gateway',
|
|
170
|
+
description: 'Get one SMTP gateway: host, port, TLS mode, username and the last delivery error. The password is masked.'
|
|
171
|
+
},
|
|
159
172
|
openapi: {
|
|
160
173
|
responses: apiResponses('Returns the gateway configuration. The password is masked.', 400, 401, 403, 404, 429, 500)
|
|
161
174
|
}
|
|
@@ -253,6 +266,12 @@ async function init(args) {
|
|
|
253
266
|
tags: ['api', 'SMTP Gateway'],
|
|
254
267
|
|
|
255
268
|
plugins: {
|
|
269
|
+
mcp: {
|
|
270
|
+
name: 'create_gateway',
|
|
271
|
+
title: 'Create SMTP gateway',
|
|
272
|
+
description:
|
|
273
|
+
'Register an SMTP gateway, a relay server messages can be sent through. Needs an id, a name, the host and the port; a password can be written but never read back.'
|
|
274
|
+
},
|
|
256
275
|
openapi: {
|
|
257
276
|
responses: apiResponses('Returns the registered gateway.', 400, 401, 403, 429, 500)
|
|
258
277
|
}
|
|
@@ -342,6 +361,12 @@ async function init(args) {
|
|
|
342
361
|
tags: ['api', 'SMTP Gateway'],
|
|
343
362
|
|
|
344
363
|
plugins: {
|
|
364
|
+
mcp: {
|
|
365
|
+
name: 'update_gateway',
|
|
366
|
+
title: 'Update SMTP gateway',
|
|
367
|
+
description:
|
|
368
|
+
'Update an SMTP gateway. Send only the fields to change. Changing the host makes the next delivery authenticate to the new host with the stored password, so confirm host changes with the user.'
|
|
369
|
+
},
|
|
345
370
|
openapi: {
|
|
346
371
|
responses: apiResponses('Returns the updated gateway.', 400, 401, 403, 404, 429, 500)
|
|
347
372
|
}
|
|
@@ -429,6 +454,11 @@ async function init(args) {
|
|
|
429
454
|
tags: ['api', 'SMTP Gateway'],
|
|
430
455
|
|
|
431
456
|
plugins: {
|
|
457
|
+
mcp: {
|
|
458
|
+
name: 'delete_gateway',
|
|
459
|
+
title: 'Delete SMTP gateway',
|
|
460
|
+
description: 'Remove an SMTP gateway. Messages queued through it fail to deliver. Confirm with the user before calling this.'
|
|
461
|
+
},
|
|
432
462
|
openapi: {
|
|
433
463
|
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
434
464
|
responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 404, 429, 500)
|
|
@@ -32,6 +32,11 @@ async function init(args) {
|
|
|
32
32
|
tags: ['api', 'License'],
|
|
33
33
|
|
|
34
34
|
plugins: {
|
|
35
|
+
mcp: {
|
|
36
|
+
name: 'get_license',
|
|
37
|
+
title: 'Get license',
|
|
38
|
+
description: 'Get the active license: who it is issued to and when it expires, or an empty object when the instance runs unlicensed.'
|
|
39
|
+
},
|
|
35
40
|
openapi: {
|
|
36
41
|
responses: apiResponses('Returns the active license and its expiry, or an empty object when unlicensed.', 401, 403, 429, 500)
|
|
37
42
|
}
|
|
@@ -119,6 +124,11 @@ async function init(args) {
|
|
|
119
124
|
tags: ['api', 'License'],
|
|
120
125
|
|
|
121
126
|
plugins: {
|
|
127
|
+
mcp: {
|
|
128
|
+
name: 'set_license',
|
|
129
|
+
title: 'Apply license',
|
|
130
|
+
description: 'Apply a license key to this instance. Takes the full license text as issued, including its BEGIN and END lines.'
|
|
131
|
+
},
|
|
122
132
|
openapi: {
|
|
123
133
|
responses: apiResponses('Returns the registered license.', 400, 401, 403, 429, 500)
|
|
124
134
|
}
|
|
@@ -19,7 +19,7 @@ const Boom = require('@hapi/boom');
|
|
|
19
19
|
const Joi = require('joi');
|
|
20
20
|
|
|
21
21
|
const { checkRateLimit } = require('../rate-limit');
|
|
22
|
-
const { oauthOrigin, mcpResource, registerClient, redeemAuthorizationCode, MAX_REDIRECT_URIS } = require('../mcp/oauth');
|
|
22
|
+
const { oauthOrigin, mcpResource, registerClient, redeemAuthorizationCode, MAX_REDIRECT_URIS, MCP_OAUTH_SCOPES } = require('../mcp/oauth');
|
|
23
23
|
|
|
24
24
|
const OPEN_CORS = { origin: ['*'] };
|
|
25
25
|
|
|
@@ -95,7 +95,7 @@ async function init(args) {
|
|
|
95
95
|
return {
|
|
96
96
|
resource: mcpResource(origin),
|
|
97
97
|
authorization_servers: [origin],
|
|
98
|
-
scopes_supported:
|
|
98
|
+
scopes_supported: MCP_OAUTH_SCOPES,
|
|
99
99
|
bearer_methods_supported: ['header'],
|
|
100
100
|
resource_name: 'EmailEngine MCP'
|
|
101
101
|
};
|
|
@@ -128,7 +128,7 @@ async function init(args) {
|
|
|
128
128
|
grant_types_supported: ['authorization_code'],
|
|
129
129
|
code_challenge_methods_supported: ['S256'],
|
|
130
130
|
token_endpoint_auth_methods_supported: ['none'],
|
|
131
|
-
scopes_supported:
|
|
131
|
+
scopes_supported: MCP_OAUTH_SCOPES,
|
|
132
132
|
authorization_response_iss_parameter_supported: true
|
|
133
133
|
};
|
|
134
134
|
},
|
|
@@ -21,7 +21,7 @@ const Boom = require('@hapi/boom');
|
|
|
21
21
|
const settings = require('../settings');
|
|
22
22
|
const { isMcpEnabled, MCP_DISABLED_MESSAGE } = require('../mcp');
|
|
23
23
|
const { processMcpRequest, isAllowedOrigin, acceptsEventStream, rpcError, ERROR_CODES, serverInstructions } = require('../mcp/protocol');
|
|
24
|
-
const { getToolRegistry, callTool, listToolsFor } = require('../mcp/tools');
|
|
24
|
+
const { getToolRegistry, callTool, listToolsFor, catalogSurfaces } = require('../mcp/tools');
|
|
25
25
|
const { listResources, readResource } = require('../mcp/resources');
|
|
26
26
|
const { acceptFilter, openListenStream, canOpenListenStream, MAX_STREAMS_PER_CREDENTIAL } = require('../mcp/listen');
|
|
27
27
|
|
|
@@ -56,18 +56,31 @@ async function init(args) {
|
|
|
56
56
|
|
|
57
57
|
const boundAccount = request.app.mcpBoundAccount;
|
|
58
58
|
|
|
59
|
+
// A credential sees the surface it can actually use, so the agent does not plan
|
|
60
|
+
// around tools that would only ever answer it with a 403: a bound credential loses
|
|
61
|
+
// the instance-wide listings (list_accounts, get_outbox) and the `account` argument
|
|
62
|
+
// of everything else, a token holding one MCP scope loses the other scope's tools,
|
|
63
|
+
// and a permission-narrowed token loses the tools whose grant its record refuses -
|
|
64
|
+
// the same checks the injected inner request would enforce, asked ahead of time.
|
|
65
|
+
// Advertisement only: tools/call still dispatches whatever is asked, and the inner
|
|
66
|
+
// request stays the enforcement.
|
|
67
|
+
//
|
|
68
|
+
// Computed on first use and at most once per request: only tools/list and the
|
|
69
|
+
// discovery methods read the catalog, and only the latter read the instructions, so
|
|
70
|
+
// a tools/call or a ping pays for neither.
|
|
71
|
+
//
|
|
72
|
+
// Auth mode is required and every strategy success path sets artifacts (the token
|
|
73
|
+
// record, or {} for the preauth caller).
|
|
74
|
+
let catalog = null;
|
|
75
|
+
const listTools = () => {
|
|
76
|
+
if (!catalog) {
|
|
77
|
+
catalog = listToolsFor(server, { tokenData: request.auth.artifacts, boundAccount });
|
|
78
|
+
}
|
|
79
|
+
return catalog;
|
|
80
|
+
};
|
|
81
|
+
|
|
59
82
|
const ctx = {
|
|
60
|
-
|
|
61
|
-
// around tools that would only ever answer it with a 403: a bound credential
|
|
62
|
-
// loses the instance-wide listings (list_accounts, get_outbox) and the `account`
|
|
63
|
-
// argument of everything else, and a permission-narrowed token loses the tools
|
|
64
|
-
// whose grant its record refuses - the same check the injected inner request
|
|
65
|
-
// would enforce, asked ahead of time. Advertisement only: tools/call still
|
|
66
|
-
// dispatches whatever is asked, and the inner request stays the enforcement.
|
|
67
|
-
//
|
|
68
|
-
// Auth mode is required and every strategy success path sets artifacts (the token
|
|
69
|
-
// record, or {} for the preauth caller).
|
|
70
|
-
listTools: () => listToolsFor(server, { tokenData: request.auth.artifacts, boundAccount }),
|
|
83
|
+
listTools,
|
|
71
84
|
|
|
72
85
|
callTool: async (name, toolArgs) => {
|
|
73
86
|
const tool = getToolRegistry(server).byName.get(name);
|
|
@@ -82,10 +95,15 @@ async function init(args) {
|
|
|
82
95
|
listResources: () => listResources({ server, request }),
|
|
83
96
|
readResource: uri => readResource({ server, request, uri }),
|
|
84
97
|
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
|
|
98
|
+
// Written for this credential: which tool sets it holds, read off the catalog it
|
|
99
|
+
// is advertised rather than off its scopes (a narrowed record can empty a scope
|
|
100
|
+
// out, and the instructions should describe the tools the agent will see), and
|
|
101
|
+
// whether it is bound to one account (in which case the generic opening - call
|
|
102
|
+
// list_accounts, then pass the id - describes a workflow it cannot perform)
|
|
103
|
+
get instructions() {
|
|
104
|
+
const advertised = listTools();
|
|
105
|
+
return serverInstructions({ account: boundAccount, surfaces: catalogSurfaces(server, advertised), hasTools: advertised.length > 0 });
|
|
106
|
+
},
|
|
89
107
|
|
|
90
108
|
acceptsEventStream: acceptsEventStream(request.headers.accept)
|
|
91
109
|
};
|
|
@@ -120,11 +138,11 @@ async function init(args) {
|
|
|
120
138
|
description: 'MCP endpoint',
|
|
121
139
|
notes: ['JSON-RPC endpoint implementing the Model Context Protocol Streamable HTTP transport'],
|
|
122
140
|
|
|
123
|
-
// `external`: no CSRF crumb and no OpenAPI operation.
|
|
124
|
-
// do over MCP whatever they can do over REST, and `mcp`
|
|
125
|
-
//
|
|
126
|
-
// workers/api.js).
|
|
127
|
-
tags: ['external', 'scope:api', 'scope:mcp'],
|
|
141
|
+
// `external`: no CSRF crumb and no OpenAPI operation. Three scopes: `api` tokens can
|
|
142
|
+
// do over MCP whatever they can do over REST, and `mcp` (mail) and `mcp-manage`
|
|
143
|
+
// (instance management) tokens are surface-bound credentials this endpoint admits
|
|
144
|
+
// and plain REST refuses (see the scope check in workers/api.js).
|
|
145
|
+
tags: ['external', 'scope:api', 'scope:mcp', 'scope:mcp-manage'],
|
|
128
146
|
|
|
129
147
|
plugins: {
|
|
130
148
|
mcp: { endpoint: true }
|
|
@@ -16,7 +16,7 @@ const {
|
|
|
16
16
|
ENUM_DESCRIPTIONS
|
|
17
17
|
} = require('../schemas');
|
|
18
18
|
const { handleError, throwNotFound, flattenOAuthAppMeta, MASKED } = require('./route-helpers');
|
|
19
|
-
const { ENCRYPTED_APP_KEYS } = require('../consts');
|
|
19
|
+
const { ENCRYPTED_APP_KEYS, MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
20
20
|
const { IMPACT } = require('./operation-impact');
|
|
21
21
|
|
|
22
22
|
// Stored fields that are returned on OAuth2 application objects in addition to the basic fields
|
|
@@ -101,6 +101,13 @@ async function init(args) {
|
|
|
101
101
|
tags: ['api', 'OAuth2 Applications'],
|
|
102
102
|
|
|
103
103
|
plugins: {
|
|
104
|
+
mcp: {
|
|
105
|
+
name: 'list_oauth2_apps',
|
|
106
|
+
title: 'List OAuth2 applications',
|
|
107
|
+
description:
|
|
108
|
+
'List the OAuth2 applications (Gmail, Outlook and other providers) that accounts can sign in through, paged. Client secrets are masked.',
|
|
109
|
+
bounds: { pageSize: MCP_MAX_PAGE_SIZE }
|
|
110
|
+
},
|
|
104
111
|
openapi: {
|
|
105
112
|
responses: apiResponses('Returns a page of OAuth2 applications.', 400, 401, 403, 429, 500)
|
|
106
113
|
}
|
|
@@ -249,6 +256,11 @@ async function init(args) {
|
|
|
249
256
|
tags: ['api', 'OAuth2 Applications'],
|
|
250
257
|
|
|
251
258
|
plugins: {
|
|
259
|
+
mcp: {
|
|
260
|
+
name: 'get_oauth2_app',
|
|
261
|
+
title: 'Get OAuth2 application',
|
|
262
|
+
description: 'Get one OAuth2 application: its provider, client id, scopes, redirect URL and Pub/Sub settings. Client secrets are masked.'
|
|
263
|
+
},
|
|
252
264
|
openapi: {
|
|
253
265
|
responses: apiResponses('Returns the OAuth2 application. Client secrets are masked.', 400, 401, 403, 404, 429, 500)
|
|
254
266
|
}
|
|
@@ -359,6 +371,12 @@ async function init(args) {
|
|
|
359
371
|
tags: ['api', 'OAuth2 Applications'],
|
|
360
372
|
|
|
361
373
|
plugins: {
|
|
374
|
+
mcp: {
|
|
375
|
+
name: 'create_oauth2_app',
|
|
376
|
+
title: 'Create OAuth2 application',
|
|
377
|
+
description:
|
|
378
|
+
'Register an OAuth2 application that accounts can sign in through. Needs the provider and the client credentials created at that provider; a client secret or service key can be written but never read back. Confirm the redirect URL with the user: it is where the provider sends authorization codes and has to match what the provider has on file.'
|
|
379
|
+
},
|
|
362
380
|
openapi: {
|
|
363
381
|
responses: apiResponses('Returns the registered OAuth2 application.', 400, 401, 403, 429, 500)
|
|
364
382
|
}
|
|
@@ -409,6 +427,12 @@ async function init(args) {
|
|
|
409
427
|
tags: ['api', 'OAuth2 Applications'],
|
|
410
428
|
|
|
411
429
|
plugins: {
|
|
430
|
+
mcp: {
|
|
431
|
+
name: 'update_oauth2_app',
|
|
432
|
+
title: 'Update OAuth2 application',
|
|
433
|
+
description:
|
|
434
|
+
'Update an OAuth2 application. Send only the fields to change; a client secret can be replaced but not read back. Changing the redirect URL moves where the provider sends authorization codes, so confirm that with the user.'
|
|
435
|
+
},
|
|
412
436
|
openapi: {
|
|
413
437
|
responses: apiResponses('Returns the updated OAuth2 application.', 400, 401, 403, 404, 429, 500)
|
|
414
438
|
}
|
|
@@ -560,6 +584,12 @@ async function init(args) {
|
|
|
560
584
|
tags: ['api', 'OAuth2 Applications'],
|
|
561
585
|
|
|
562
586
|
plugins: {
|
|
587
|
+
mcp: {
|
|
588
|
+
name: 'delete_oauth2_app',
|
|
589
|
+
title: 'Delete OAuth2 application',
|
|
590
|
+
description:
|
|
591
|
+
'Remove an OAuth2 application. Accounts that signed in through it can no longer refresh their access tokens and stop syncing. Confirm with the user before calling this.'
|
|
592
|
+
},
|
|
563
593
|
openapi: {
|
|
564
594
|
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
565
595
|
responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 404, 429, 500)
|
|
@@ -616,6 +646,13 @@ async function init(args) {
|
|
|
616
646
|
tags: ['api', 'OAuth2 Applications'],
|
|
617
647
|
|
|
618
648
|
plugins: {
|
|
649
|
+
mcp: {
|
|
650
|
+
name: 'verify_oauth2_app',
|
|
651
|
+
title: 'Verify OAuth2 application',
|
|
652
|
+
description:
|
|
653
|
+
'Check an OAuth2 application against its provider: the credentials, the Pub/Sub setup where it has one, and optionally the connection of one account that uses it.',
|
|
654
|
+
openWorld: true
|
|
655
|
+
},
|
|
619
656
|
openapi: {
|
|
620
657
|
'x-ee-impact': IMPACT.READONLY,
|
|
621
658
|
responses: apiResponses('Returns the outcome of the credential check against the provider.', 400, 401, 403, 404, 429, 500)
|
|
@@ -162,6 +162,12 @@ async function init(args) {
|
|
|
162
162
|
tags: ['api', 'Outbox'],
|
|
163
163
|
|
|
164
164
|
plugins: {
|
|
165
|
+
mcp: {
|
|
166
|
+
name: 'cancel_queued_message',
|
|
167
|
+
title: 'Cancel queued message',
|
|
168
|
+
description:
|
|
169
|
+
'Cancel a message waiting in the sending queue, by the queue id from get_outbox. A message already handed to the mail server cannot be cancelled.'
|
|
170
|
+
},
|
|
165
171
|
openapi: {
|
|
166
172
|
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
167
173
|
responses: apiResponses('Returns a deletion marker. A message already being delivered cannot be removed.', 400, 401, 403, 429, 500)
|