@n24q02m/better-email-mcp 1.32.3-beta.2 → 1.33.0-beta.2

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 (61) hide show
  1. package/README.md +36 -18
  2. package/bin/cli.mjs +167 -83
  3. package/build/src/auth/cred-store.d.ts +29 -0
  4. package/build/src/auth/cred-store.d.ts.map +1 -0
  5. package/build/src/auth/cred-store.js +121 -0
  6. package/build/src/auth/cred-store.js.map +1 -0
  7. package/build/src/auth/in-memory-cred-store.d.ts +17 -5
  8. package/build/src/auth/in-memory-cred-store.d.ts.map +1 -1
  9. package/build/src/auth/in-memory-cred-store.js.map +1 -1
  10. package/build/src/auth/subject-context.d.ts +10 -2
  11. package/build/src/auth/subject-context.d.ts.map +1 -1
  12. package/build/src/auth/subject-context.js +12 -2
  13. package/build/src/auth/subject-context.js.map +1 -1
  14. package/build/src/auth/test-helpers.d.ts +34 -0
  15. package/build/src/auth/test-helpers.d.ts.map +1 -0
  16. package/build/src/auth/test-helpers.js +46 -0
  17. package/build/src/auth/test-helpers.js.map +1 -0
  18. package/build/src/credential-form.d.ts.map +1 -1
  19. package/build/src/credential-form.js +88 -11
  20. package/build/src/credential-form.js.map +1 -1
  21. package/build/src/credential-state.d.ts.map +1 -1
  22. package/build/src/credential-state.js +9 -9
  23. package/build/src/credential-state.js.map +1 -1
  24. package/build/src/docs/config.md +3 -3
  25. package/build/src/tools/composite/config.d.ts.map +1 -1
  26. package/build/src/tools/composite/config.js +13 -1
  27. package/build/src/tools/composite/config.js.map +1 -1
  28. package/build/src/tools/helpers/config.d.ts.map +1 -1
  29. package/build/src/tools/helpers/config.js +81 -66
  30. package/build/src/tools/helpers/config.js.map +1 -1
  31. package/build/src/tools/helpers/errors.d.ts +1 -1
  32. package/build/src/tools/helpers/errors.d.ts.map +1 -1
  33. package/build/src/tools/helpers/errors.js +16 -15
  34. package/build/src/tools/helpers/errors.js.map +1 -1
  35. package/build/src/tools/helpers/html-utils.d.ts +10 -1
  36. package/build/src/tools/helpers/html-utils.d.ts.map +1 -1
  37. package/build/src/tools/helpers/html-utils.js +24 -11
  38. package/build/src/tools/helpers/html-utils.js.map +1 -1
  39. package/build/src/tools/helpers/imap-client.d.ts.map +1 -1
  40. package/build/src/tools/helpers/imap-client.js +9 -5
  41. package/build/src/tools/helpers/imap-client.js.map +1 -1
  42. package/build/src/tools/helpers/oauth2.d.ts +29 -7
  43. package/build/src/tools/helpers/oauth2.d.ts.map +1 -1
  44. package/build/src/tools/helpers/oauth2.js +145 -23
  45. package/build/src/tools/helpers/oauth2.js.map +1 -1
  46. package/build/src/tools/helpers/smtp-client.d.ts.map +1 -1
  47. package/build/src/tools/helpers/smtp-client.js +5 -8
  48. package/build/src/tools/helpers/smtp-client.js.map +1 -1
  49. package/build/src/transports/http.d.ts.map +1 -1
  50. package/build/src/transports/http.js +75 -34
  51. package/build/src/transports/http.js.map +1 -1
  52. package/build/src/worker.d.ts +39 -0
  53. package/build/src/worker.d.ts.map +1 -0
  54. package/build/src/worker.js +154 -0
  55. package/build/src/worker.js.map +1 -0
  56. package/build/tsconfig.build.tsbuildinfo +1 -1
  57. package/package.json +18 -14
  58. package/build/src/auth/per-user-credential-store.d.ts +0 -65
  59. package/build/src/auth/per-user-credential-store.d.ts.map +0 -1
  60. package/build/src/auth/per-user-credential-store.js +0 -234
  61. package/build/src/auth/per-user-credential-store.js.map +0 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  mcp-name: io.github.n24q02m/better-email-mcp
4
4
 
5
- **IMAP/SMTP email server for AI agents -- 7 composite tools with multi-account and auto-discovery**
5
+ **IMAP/SMTP email for AI agents -- read, send, organize folders, and manage attachments across multiple accounts, with auto-discovery.**
6
6
 
7
7
  <!-- Badge Row 1: Status -->
8
8
  [![CI](https://github.com/n24q02m/better-email-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/n24q02m/better-email-mcp/actions/workflows/ci.yml)
@@ -24,20 +24,21 @@ mcp-name: io.github.n24q02m/better-email-mcp
24
24
 
25
25
  | Project | Tagline | Tag |
26
26
  |---|---|---|
27
- | [better-code-review-graph](https://github.com/n24q02m/better-code-review-graph) | Knowledge graph for token-efficient code reviews -- fixed search, configurabl... | MCP |
28
- | [better-email-mcp](https://github.com/n24q02m/better-email-mcp) | IMAP/SMTP email server for AI agents -- 6 composite tools with multi-account ... | MCP |
29
- | [better-godot-mcp](https://github.com/n24q02m/better-godot-mcp) | Composite MCP server for Godot Engine -- 17 mega-tools for AI-assisted game d... | MCP |
30
- | [better-notion-mcp](https://github.com/n24q02m/better-notion-mcp) | Markdown-first Notion API server for AI agents -- 10 composite tools replacin... | MCP |
31
- | [better-telegram-mcp](https://github.com/n24q02m/better-telegram-mcp) | MCP server for Telegram with dual-mode support: Bot API (httpx) for quick bot... | MCP |
32
- | [claude-plugins](https://github.com/n24q02m/claude-plugins) | Full documentation: mcp.n24q02m.com unified docs for all 8 servers + the mc... | Marketplace |
33
- | [imagine-mcp](https://github.com/n24q02m/imagine-mcp) | Production-grade MCP server for image and video understanding + generation ac... | MCP |
27
+ | [better-code-review-graph](https://github.com/n24q02m/better-code-review-graph) | Knowledge graph for token-efficient code reviews -- semantic search and call-... | MCP |
28
+ | [better-email-mcp](https://github.com/n24q02m/better-email-mcp) | IMAP/SMTP email for AI agents -- read, send, organize folders, and manage att... | MCP |
29
+ | [better-godot-mcp](https://github.com/n24q02m/better-godot-mcp) | Composite MCP server for Godot Engine -- 17 composite tools for AI-assisted g... | MCP |
30
+ | [better-notion-mcp](https://github.com/n24q02m/better-notion-mcp) | Markdown-first Notion for AI agents -- pages, databases, blocks, and comments... | MCP |
31
+ | [better-telegram-mcp](https://github.com/n24q02m/better-telegram-mcp) | Telegram for AI agents -- messages, chats, media, and contacts across both bo... | MCP |
32
+ | [claude-plugins](https://github.com/n24q02m/claude-plugins) | Claude Code plugin marketplace for the n24q02m MCP servers -- install web sea... | Marketplace |
33
+ | [imagine-mcp](https://github.com/n24q02m/imagine-mcp) | Image and video understanding + generation for AI agents -- across Gemini, Op... | MCP |
34
34
  | [jules-task-archiver](https://github.com/n24q02m/jules-task-archiver) | Chrome Extension for bulk operations on Jules tasks via batchexecute API -- a... | Tooling |
35
- | [mcp-core](https://github.com/n24q02m/mcp-core) | Unified MCP Streamable HTTP 2025-11-25 transport, OAuth 2.1 Authorization Ser... | MCP |
35
+ | [mcp-core](https://github.com/n24q02m/mcp-core) | Shared foundation for building MCP servers -- Streamable HTTP transport, OAut... | MCP |
36
36
  | [mnemo-mcp](https://github.com/n24q02m/mnemo-mcp) | Persistent AI memory with hybrid search and embedded sync. Open, free, unlimi... | MCP |
37
37
  | [qwen3-embed](https://github.com/n24q02m/qwen3-embed) | Lightweight Qwen3 text embedding and reranking via ONNX Runtime and GGUF | Library |
38
38
  | [skret](https://github.com/n24q02m/skret) | Secrets without the server. | CLI |
39
+ | [tacet](https://github.com/n24q02m/tacet) | TACET: a self-distilling neuro-symbolic cascade that amortises LLM cost in kn... | Tooling |
39
40
  | [web-core](https://github.com/n24q02m/web-core) | Shared web infrastructure package for search, scraping, HTTP security, and st... | Library |
40
- | [wet-mcp](https://github.com/n24q02m/wet-mcp) | Open-source MCP Server for web search, content extraction, library docs & mul... | MCP |
41
+ | [wet-mcp](https://github.com/n24q02m/wet-mcp) | Open-source MCP server for AI agents: web search, content extraction, and lib... | MCP |
41
42
 
42
43
  </details>
43
44
  <!-- END: AUTO-GENERATED-CROSS-PROMO -->
@@ -67,7 +68,7 @@ mcp-name: io.github.n24q02m/better-email-mcp
67
68
 
68
69
  - **Multi-account support** -- manage 6+ email accounts (Gmail, Outlook, Yahoo, iCloud, Zoho, ProtonMail, custom IMAP)
69
70
  - **App Passwords** -- no OAuth2 setup required for most providers; clone and run in 1 minute
70
- - **7 composite tools** with 20 actions -- search, read, send, reply, forward, organize, credential setup in single calls
71
+ - **7 composite tools** with 21 actions -- search, read, send, reply, forward, organize, credential setup in single calls
71
72
  - **Auto-discovery** -- provider settings detected from email address, custom IMAP host supported
72
73
  - **Thread-aware** -- reply/forward maintains In-Reply-To and References headers
73
74
  - **Tiered token optimization** -- compressed descriptions + on-demand `help` tool + MCP Resources
@@ -97,7 +98,7 @@ mcp-name: io.github.n24q02m/better-email-mcp
97
98
  Full docs at **[mcp.n24q02m.com/servers/better-email-mcp/setup/](https://mcp.n24q02m.com/servers/better-email-mcp/setup/)**:
98
99
 
99
100
  - [Setup](https://mcp.n24q02m.com/servers/better-email-mcp/setup/) -- install methods for Claude Code, Codex, Gemini CLI, Cursor, Windsurf, mcp.json
100
- - [Modes overview](https://mcp.n24q02m.com/get-started/modes-overview/) -- stdio / local-relay / remote-relay / remote-oauth
101
+ - [Modes overview](https://mcp.n24q02m.com/get-started/modes-overview/) -- stdio (default) and HTTP (opt-in, multi-user with OAuth 2.1)
101
102
  - [Multi-user setup](https://mcp.n24q02m.com/get-started/multi-user/) -- per-JWT-sub credential model
102
103
 
103
104
  **Install with AI agent** -- paste this to your AI coding agent:
@@ -165,11 +166,29 @@ Single multi-user mode (relay form for App-Password providers + bundled Outlook
165
166
  docker run -p 8080:8080 \
166
167
  -e PORT=8080 \
167
168
  -e PUBLIC_URL=https://your-domain.com \
168
- -e CREDENTIAL_SECRET=$(openssl rand -hex 32) \
169
169
  n24q02m/better-email-mcp:latest
170
170
  ```
171
171
 
172
- Users provide their own email credentials through the OAuth flow / paste form. No server-side `EMAIL_CREDENTIALS` needed. Outlook OAuth uses the bundled public Azure client (`d56f8c71-9f7c-43f4-9934-be29cb6e77b0`, Thunderbird-pattern) -- no user-side Azure app registration needed.
172
+ Users provide their own email credentials through the OAuth flow / paste form. No server-side `EMAIL_CREDENTIALS` needed. With the default Docker self-host, per-user credentials are held in an in-memory store (cleared on restart); users re-submit after a restart. Outlook OAuth uses the bundled public Azure client (`d56f8c71-9f7c-43f4-9934-be29cb6e77b0`, Thunderbird-pattern) -- no user-side Azure app registration needed.
173
+
174
+ ### Cloudflare serverless mode (KV-only)
175
+
176
+ Deploy a per-user serverless instance at `https://email.n24q02m.com`: each JWT `sub`
177
+ gets its own Container Durable Object, and all credentials AND Outlook OAuth tokens are
178
+ AES-256-GCM encrypted into Workers KV (one `subs/<sub>/config` blob per user) so they
179
+ **survive scale-to-zero / container recreate with no re-auth**. The JWT signing key is
180
+ derived deterministically from `CREDENTIAL_SECRET` (EdDSA), so the user's identity is
181
+ stable across recreate. Required secrets: `CREDENTIAL_SECRET` (per-sub vault + EdDSA),
182
+ `MCP_RELAY_PASSWORD` (form gate), `MCP_DCR_SERVER_SECRET` (intentional multi-user
183
+ deploy). See `wrangler.jsonc`.
184
+
185
+ > Keying Outlook tokens by JWT `sub` (in the per-sub KV blob) resolves the former
186
+ > email-keyed `tokens.json` ambiguity (CLAUDE.md Known Bug #4): two users' Outlook
187
+ > accounts can no longer collide.
188
+
189
+ > Caveat: `localhost` IMAP accounts (`email:pass:localhost:1993`) are valid for
190
+ > local / VM deployments but CANNOT work on Cloudflare — there is no co-located IMAP
191
+ > proxy inside the container. Use a publicly-reachable IMAP host on CF.
173
192
 
174
193
  ## Outlook OAuth Device Code (HTTP mode)
175
194
 
@@ -178,7 +197,7 @@ In HTTP mode, Outlook/Hotmail/Live accounts use OAuth2 device-code automatically
178
197
  1. The server prints a device code and a Microsoft login URL
179
198
  2. Open the URL in a browser and enter the code
180
199
  3. Sign in and authorize the app
181
- 4. Tokens are persisted per JWT sub (`tokens/<sub>.json`)
200
+ 4. Tokens are persisted per JWT sub — in the encrypted Cloudflare KV credential blob (`subs/<sub>/config`) on the serverless deploy, or in `~/.better-email-mcp/tokens.json` for single-user / stdio
182
201
 
183
202
  OAuth uses the bundled public Azure client (`d56f8c71-9f7c-43f4-9934-be29cb6e77b0`, Thunderbird-pattern) -- no user-side Azure registration needed.
184
203
 
@@ -192,7 +211,6 @@ In **stdio mode**, Outlook accounts use an **App Password** instead (Outlook Acc
192
211
  | `EMAIL_USER` | Alternative (stdio, single-account) | - | Email address. Used with `EMAIL_APP_PASSWORD` as a per-field alternative to `EMAIL_CREDENTIALS`; merged into `EMAIL_CREDENTIALS` at boot |
193
212
  | `EMAIL_APP_PASSWORD` | Alternative (stdio, single-account) | - | App password (Gmail/Yahoo/iCloud) or Outlook App Password; used with `EMAIL_USER` |
194
213
  | `PUBLIC_URL` | No (http) | - | Server's public URL for relay / OAuth redirect links |
195
- | `CREDENTIAL_SECRET` | No (http) | auto-generated | Secret used to encrypt the per-user credential store; if unset, a random 32-byte secret is generated and persisted to a 0600 file |
196
214
  | `PORT` | No | `0` (OS-assigned) | Server port (http mode); set explicitly (e.g. `8080`) to bind a fixed port |
197
215
  | `HOST` | No | - | Bind address (http mode) |
198
216
  | `MCP_AUTH_DISABLE` | No (http) | - | Set to `1` to skip Bearer JWT verification when behind an external auth gateway |
@@ -267,9 +285,9 @@ This plugin implements **TC-NearZK** (in-memory, ephemeral). See the [mcp-core t
267
285
 
268
286
  | Mode | Storage | Encryption | Who can read your data? |
269
287
  |---|---|---|---|
270
- | HTTP n24q02m-hosted (default) | In-memory `Map<sub, OAuthToken>` | In-process only | Server process (cleared on restart) |
288
+ | HTTP remote (hosted) | In-memory `Map<sub, OAuthToken>` | In-process only | Server process (cleared on restart) |
271
289
  | HTTP self-host | Same as hosted | Same | Only you (admin = user) |
272
- | stdio proxy | `~/.better-email-mcp/config.json` | AES-GCM, machine-bound key | Only your OS user (file perm 0600) |
290
+ | stdio | platformdirs `mcp` config dir (`config.enc`; e.g. `%APPDATA%\mcp\Config\config.enc` on Windows) | AES-GCM, machine-bound key | Only your OS user (file perm 0600) |
273
291
 
274
292
  ## License
275
293