read-email-mcp 1.0.0 → 2.0.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/LICENSE +21 -21
- package/README.md +177 -34
- package/dist/accounts-cli.d.ts +1 -0
- package/dist/accounts-cli.js +530 -0
- package/dist/accounts-cli.js.map +1 -0
- package/dist/config.d.ts +30 -2
- package/dist/config.js +219 -15
- package/dist/config.js.map +1 -1
- package/dist/imap-discovery.d.ts +52 -0
- package/dist/imap-discovery.js +207 -0
- package/dist/imap-discovery.js.map +1 -0
- package/dist/imap.d.ts +41 -5
- package/dist/imap.js +332 -64
- package/dist/imap.js.map +1 -1
- package/dist/index.js +28 -8
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts +12 -0
- package/dist/providers.js +122 -0
- package/dist/providers.js.map +1 -0
- package/dist/server.d.ts +3 -6
- package/dist/server.js +10 -8
- package/dist/server.js.map +1 -1
- package/dist/store.d.ts +31 -2
- package/dist/store.js +300 -153
- package/dist/store.js.map +1 -1
- package/dist/tools.d.ts +189 -174
- package/dist/tools.js +714 -60
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +44 -1
- package/docs/production-readiness.md +84 -70
- package/package.json +10 -9
- package/scripts/smoke-mcp.mjs +8 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 KelpHect
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KelpHect
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@ A read-only [Model Context Protocol](https://modelcontextprotocol.io) server tha
|
|
|
4
4
|
|
|
5
5
|
It works with Gmail, Outlook, Yahoo, Fastmail, iCloud, Proton Mail Bridge, self-hosted mail, and any other provider that exposes standard IMAP.
|
|
6
6
|
|
|
7
|
-
> **Version
|
|
7
|
+
> **Version 2.0.1.** Please report issues.
|
|
8
8
|
|
|
9
9
|
## Why use it
|
|
10
10
|
|
|
11
11
|
- **Fast browsing and search.** Email is synced once into a local SQLite mirror with full-text search. Every browse, search, and read call hits the local copy, so it is quick and never re-logs-in to IMAP per request.
|
|
12
12
|
- **Read-only and safe.** It never sends, deletes, moves, flags, or marks messages. IMAP mailboxes are opened with read-only locks. Your mailbox cannot be mutated by this server.
|
|
13
|
-
- **Provider agnostic.**
|
|
14
|
-
- **Private by design.** Credentials
|
|
13
|
+
- **Provider agnostic.** Works with any IMAP server. Common providers are auto-detected from the email domain, and custom/self-hosted servers get automatic discovery via autoconfig, DNS, and MX records.
|
|
14
|
+
- **Private by design.** Credentials live in environment variables or your password manager's CLI — nothing requires storing passwords on disk. Raw `.eml` files live under your home directory and never leave your machine.
|
|
15
15
|
- **MCP native.** Exposes a clean set of tools over stdio so any MCP-compatible client can read email on your behalf.
|
|
16
16
|
|
|
17
17
|
## Requirements
|
|
@@ -22,20 +22,27 @@ It works with Gmail, Outlook, Yahoo, Fastmail, iCloud, Proton Mail Bridge, self-
|
|
|
22
22
|
|
|
23
23
|
## Quick start
|
|
24
24
|
|
|
25
|
+
The fastest path is the account wizard — it detects your provider, fills in the IMAP settings, verifies the connection, and writes the accounts file for you:
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
npx -y read-email-mcp@2.0.1 accounts add
|
|
29
|
+
npx -y read-email-mcp@2.0.1 init # prints the MCP client config to paste
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
From source instead:
|
|
33
|
+
|
|
25
34
|
```powershell
|
|
26
35
|
git clone <this-repo>
|
|
27
36
|
cd read-email-mcp
|
|
28
37
|
npm install
|
|
29
38
|
npm run build
|
|
39
|
+
node dist/index.js accounts add
|
|
30
40
|
```
|
|
31
41
|
|
|
32
|
-
|
|
42
|
+
Or run the server directly with credentials — the IMAP host is optional for known providers:
|
|
33
43
|
|
|
34
44
|
```powershell
|
|
35
|
-
node dist/index.js
|
|
36
|
-
--email "you@gmail.com" `
|
|
37
|
-
--password "your-app-password" `
|
|
38
|
-
--imap-host "imap.gmail.com"
|
|
45
|
+
node dist/index.js --email "you@gmail.com" --password "your-app-password"
|
|
39
46
|
```
|
|
40
47
|
|
|
41
48
|
Or set environment variables and omit the flags:
|
|
@@ -43,7 +50,6 @@ Or set environment variables and omit the flags:
|
|
|
43
50
|
```powershell
|
|
44
51
|
$env:EMAIL = "you@gmail.com"
|
|
45
52
|
$env:PASSWORD = "your-app-password"
|
|
46
|
-
$env:IMAP_HOST = "imap.gmail.com"
|
|
47
53
|
node dist/index.js
|
|
48
54
|
```
|
|
49
55
|
|
|
@@ -55,15 +61,114 @@ All settings can be passed as CLI args or environment variables. CLI args take p
|
|
|
55
61
|
| --- | --- | --- | --- | --- |
|
|
56
62
|
| Email address | yes | `EMAIL` | `--email` | none |
|
|
57
63
|
| Password | yes | `PASSWORD` | `--password` | none |
|
|
58
|
-
| IMAP host |
|
|
64
|
+
| IMAP host | no* | `IMAP_HOST` | `--imap-host` | auto-detected for known providers |
|
|
59
65
|
| IMAP port | no | `IMAP_PORT` | `--imap-port` | `993` |
|
|
60
66
|
| IMAP TLS | no | `IMAP_SECURE` | `--imap-secure` | `true` |
|
|
61
67
|
| IMAP login user | no | `IMAP_USER` | `--imap-user` | same as email |
|
|
68
|
+
| TLS cert verification | no | `IMAP_TLS_REJECT_UNAUTHORIZED` | — | `true` (set `false` for self-signed certs) |
|
|
69
|
+
| Accounts file | no | `ACCOUNTS_FILE` | `--accounts` | `~/.read-email-mcp/accounts.json` if it exists |
|
|
70
|
+
| Env file | no | `ENV_FILE` | `--env-file` | `./.env` then `~/.read-email-mcp/.env` if present |
|
|
71
|
+
|
|
72
|
+
*`IMAP_HOST` is only required when the email domain isn't a known provider (see "Common provider settings"). For `gmail.com`, `outlook.com`, `icloud.com`, and the other presets, host/port/TLS are filled in automatically — `EMAIL` + `PASSWORD` is enough.
|
|
62
73
|
|
|
63
74
|
`IMAP_SECURE` accepts `true` or `false` (also `1`/`0`, `yes`/`no`, `on`/`off`). Use `false` with port `143` for STARTTLS or plain IMAP.
|
|
64
75
|
|
|
65
76
|
`IMAP_USER` is optional. Set it only when the IMAP login name differs from the mailbox email address. When omitted, the email address is used as the IMAP username.
|
|
66
77
|
|
|
78
|
+
`.env` files are loaded automatically: `./.env` first, then `~/.read-email-mcp/.env`, without overriding variables already set. Use `--env-file`/`ENV_FILE` to point at a specific file instead.
|
|
79
|
+
|
|
80
|
+
> Prefer `PASSWORD` or a `.env` file over `--password`: CLI arguments are visible in process listings and shell history.
|
|
81
|
+
|
|
82
|
+
### Managing accounts from the command line
|
|
83
|
+
|
|
84
|
+
The binary doubles as an account-management CLI — the fastest way to get set up:
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
read-email-mcp accounts add # interactive wizard (prompts for what's missing)
|
|
88
|
+
read-email-mcp accounts list # show configured accounts
|
|
89
|
+
read-email-mcp accounts remove work # remove by name or email
|
|
90
|
+
read-email-mcp accounts test # check IMAP connectivity for every account
|
|
91
|
+
read-email-mcp accounts test work # check one account
|
|
92
|
+
read-email-mcp accounts discover me@corp.example # auto-detect IMAP settings
|
|
93
|
+
read-email-mcp init # print a ready-to-paste MCP client config
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`accounts add` detects the provider from the email domain, fills in IMAP settings, and offers to store the password as an env-var reference (it can save it into the `.env` file for you). Non-interactive use works too — handy for scripts:
|
|
97
|
+
|
|
98
|
+
```powershell
|
|
99
|
+
read-email-mcp accounts add --name work --email me@work.com `
|
|
100
|
+
--imap-host imap.work.com --password-env WORK_IMAP_PASSWORD --group work
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Before writing the file, `accounts add` tests the connection with your credentials and reports how many mailboxes it found — wrong passwords and typos get caught immediately instead of at first sync. Use `--no-test` to skip, or `--test` to enforce the check in scripts.
|
|
104
|
+
|
|
105
|
+
`accounts test` connects to each account, lists its mailboxes, and reports failures with provider hints — use it to verify credentials before wiring the server into a client.
|
|
106
|
+
|
|
107
|
+
### Custom and self-hosted IMAP
|
|
108
|
+
|
|
109
|
+
For domains that don't match a provider preset, `accounts add` auto-detects the IMAP settings instead of making you look them up. It tries, in order:
|
|
110
|
+
|
|
111
|
+
1. **Mozilla autoconfig** — `autoconfig.<domain>` and `/.well-known/autoconfig`, the standard most cPanel/Dovecot and hosted-IMAP setups publish.
|
|
112
|
+
2. **DNS SRV records** — `_imaps._tcp.<domain>` / `_imap._tcp.<domain>` (RFC 6186).
|
|
113
|
+
3. **MX inference** — a company domain hosted on Google Workspace or Microsoft 365 resolves to that provider's IMAP servers.
|
|
114
|
+
4. **Hostname probing** — `imap.<domain>` and `mail.<domain>` on the standard ports.
|
|
115
|
+
|
|
116
|
+
Preview what would be found without creating an account:
|
|
117
|
+
|
|
118
|
+
```powershell
|
|
119
|
+
read-email-mcp accounts discover me@corp.example
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
You can always override the detected values with `--imap-host`, `--imap-port`, `--imap-secure`, and `--imap-user`. For servers with self-signed certificates, pass `--allow-self-signed` (or set `"imapTlsRejectUnauthorized": false` in the accounts file); if the connection test hits a certificate error, the wizard offers this retry automatically. Single-account env config supports the equivalent `IMAP_TLS_REJECT_UNAUTHORIZED=false`.
|
|
123
|
+
|
|
124
|
+
### Multiple accounts
|
|
125
|
+
|
|
126
|
+
Point `--accounts` (or `ACCOUNTS_FILE`) at a JSON file to mirror several mailboxes in one server. Single-account env/CLI config is ignored when an accounts file is used.
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"accounts": [
|
|
131
|
+
{
|
|
132
|
+
"name": "work",
|
|
133
|
+
"email": "me@work.com",
|
|
134
|
+
"passwordEnv": "WORK_IMAP_PASSWORD",
|
|
135
|
+
"imapHost": "imap.work.com",
|
|
136
|
+
"groups": ["work"]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "personal",
|
|
140
|
+
"email": "me@gmail.com",
|
|
141
|
+
"passwordCommand": "op read op://Private/Gmail/app-password",
|
|
142
|
+
"groups": ["personal"]
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The `personal` entry needs no `imapHost` — `gmail.com` resolves to the Gmail preset automatically. Easiest way to produce this file is `read-email-mcp accounts add`.
|
|
149
|
+
|
|
150
|
+
Each entry needs `email` plus one credential method. `imapHost` is optional when the domain (or an explicit `provider`) matches a preset — see "Common provider settings". Optional fields:
|
|
151
|
+
|
|
152
|
+
| Field | Purpose |
|
|
153
|
+
| --- | --- |
|
|
154
|
+
| `name` | Friendly name for the `account` tool parameter (defaults to the email; names and emails must be unique) |
|
|
155
|
+
| `provider` | Preset id (`gmail`, `outlook`, `yahoo`, `icloud`, `fastmail`, `zoho`, `aol`, `gmx`, `proton`, `yandex`, `mailcom`) — fills in host/port/TLS |
|
|
156
|
+
| `passwordEnv` | Name of an env var holding the password (preferred — secrets stay out of the file) |
|
|
157
|
+
| `passwordCommand` | Shell command whose stdout is the password, e.g. `op read op://Private/Email/password` for 1Password CLI |
|
|
158
|
+
| `password` | Inline password (discouraged — only for local testing) |
|
|
159
|
+
| `imapHost` / `imapPort` / `imapSecure` / `imapUser` | Same meaning as the single-account settings |
|
|
160
|
+
| `imapTlsRejectUnauthorized` | Set `false` for self-signed certificates (skip TLS verification — use only on servers you trust) |
|
|
161
|
+
| `groups` | Labels like `["work", "clients"]` — select several accounts at once via the `accountGroup` tool parameter |
|
|
162
|
+
|
|
163
|
+
Every account gets its own mirror under `~/.read-email-mcp/<account-hash>/`. Tools accept `account` (name or email), `accounts` (a list, `*` wildcard supported), or `accountGroup` (matches `groups`):
|
|
164
|
+
|
|
165
|
+
- `sync_email` without a selector syncs every configured account **in parallel** and reports per-account results; a selector scopes it to a subset.
|
|
166
|
+
- `get_recent_emails`, `list_emails`, `search_emails`, and `browse_email_dates` without a selector merge results across accounts into one view; each item is tagged with its account.
|
|
167
|
+
- `get_email`, `get_emails`, `get_thread`, `list_attachments`, `get_attachment`, and `get_raw_email` need a single account when resolving by `id`, `ids`, or `mailbox`+`uid` (ids are per-account). `messageId` lookups search all accounts automatically.
|
|
168
|
+
- `get_sync_status`, `list_mailboxes`, `get_storage_stats`, `optimize_email_store`, `get_inbox_summary`, and `check_accounts` without a selector return a per-account summary.
|
|
169
|
+
|
|
170
|
+
`list_accounts` shows the configured accounts, their providers, groups, storage paths, and message counts.
|
|
171
|
+
|
|
67
172
|
### Common provider settings
|
|
68
173
|
|
|
69
174
|
| Provider | IMAP host | Port | TLS | Notes |
|
|
@@ -78,7 +183,7 @@ All settings can be passed as CLI args or environment variables. CLI args take p
|
|
|
78
183
|
|
|
79
184
|
## MCP client configuration
|
|
80
185
|
|
|
81
|
-
The server speaks MCP over stdio. Add it to any MCP-compatible client.
|
|
186
|
+
The server speaks MCP over stdio. Add it to any MCP-compatible client — `read-email-mcp init` prints a ready-to-paste config block for your setup.
|
|
82
187
|
|
|
83
188
|
### Claude Desktop
|
|
84
189
|
|
|
@@ -89,13 +194,11 @@ The server speaks MCP over stdio. Add it to any MCP-compatible client.
|
|
|
89
194
|
"command": "npx",
|
|
90
195
|
"args": [
|
|
91
196
|
"-y",
|
|
92
|
-
"read-email-mcp
|
|
197
|
+
"read-email-mcp",
|
|
93
198
|
"--email",
|
|
94
199
|
"you@gmail.com",
|
|
95
200
|
"--password",
|
|
96
|
-
"your-app-password"
|
|
97
|
-
"--imap-host",
|
|
98
|
-
"imap.gmail.com"
|
|
201
|
+
"your-app-password"
|
|
99
202
|
]
|
|
100
203
|
}
|
|
101
204
|
}
|
|
@@ -111,51 +214,90 @@ Set credentials in the server environment and pass only the binary:
|
|
|
111
214
|
"mcpServers": {
|
|
112
215
|
"read-email": {
|
|
113
216
|
"command": "npx",
|
|
114
|
-
"args": ["-y", "read-email-mcp
|
|
217
|
+
"args": ["-y", "read-email-mcp"],
|
|
115
218
|
"env": {
|
|
116
219
|
"EMAIL": "you@gmail.com",
|
|
117
|
-
"PASSWORD": "your-app-password"
|
|
118
|
-
"IMAP_HOST": "imap.gmail.com"
|
|
220
|
+
"PASSWORD": "your-app-password"
|
|
119
221
|
}
|
|
120
222
|
}
|
|
121
223
|
}
|
|
122
224
|
}
|
|
123
225
|
```
|
|
124
226
|
|
|
125
|
-
|
|
227
|
+
### opencode
|
|
228
|
+
|
|
229
|
+
`read-email-mcp init` also prints this block. Add it to `opencode.json` (or `.opencode.json`):
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"mcp": {
|
|
234
|
+
"read-email": {
|
|
235
|
+
"type": "local",
|
|
236
|
+
"command": ["npx", "-y", "read-email-mcp"],
|
|
237
|
+
"enabled": true
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Devin CLI
|
|
244
|
+
|
|
245
|
+
```powershell
|
|
246
|
+
devin mcp add read-email -- npx -y read-email-mcp --accounts "C:\path\to\accounts.json"
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Add `-e EMAIL=you@gmail.com -e PASSWORD=app-password` for a single-account env config instead of `--accounts`.
|
|
250
|
+
|
|
251
|
+
> Pin a version (e.g. `read-email-mcp@2.0.1`) or install from source after building.
|
|
126
252
|
|
|
127
253
|
## Tools
|
|
128
254
|
|
|
129
|
-
The server exposes
|
|
255
|
+
The server exposes 19 tools. All read from the local mirror except `sync_email` and `check_accounts`, which talk to IMAP.
|
|
130
256
|
|
|
131
|
-
- `sync_email`: pull
|
|
257
|
+
- `sync_email`: pull messages from IMAP into the local mirror. Call this first, or after a gap, before browsing or searching. Default is incremental (only new UIDs); pass `uids`, `search`, or `since` for a targeted fetch of specific messages, or `refreshFlags` to re-sync read/flagged state. Multiple accounts sync in parallel. See "How sync works" below.
|
|
258
|
+
- `list_accounts`: list configured accounts with providers, groups, storage paths, and message counts.
|
|
259
|
+
- `check_accounts`: test IMAP connectivity per account (connect, list mailboxes, disconnect) — diagnose auth or network problems.
|
|
132
260
|
- `get_sync_status`: show account, storage path, total messages, latest message date, per-mailbox counts, and the last sync result. Good first check to see whether a sync is needed.
|
|
133
261
|
- `list_mailboxes`: list locally known mailboxes (INBOX, Sent, Drafts, and so on) with message counts and last-sync time.
|
|
134
|
-
- `
|
|
262
|
+
- `get_inbox_summary`: one-call triage briefing per account — total/unread/flagged counts, mailbox count, latest message date, and the newest unread summaries.
|
|
263
|
+
- `get_recent_emails`: show the latest emails, newest first, with optional `unreadOnly`, `flaggedOnly`, and `last` lookback windows. This is the everyday tool for checking what is new.
|
|
135
264
|
- `browse_email_dates`: summarize message volume as counts per day, week, or month. Useful for finding a busy period before drilling in with a date range.
|
|
136
|
-
- `search_emails`: full-text search across subject, sender and recipient addresses, preview, and body, with filters and
|
|
265
|
+
- `search_emails`: full-text search across subject, sender and recipient addresses, preview, and body, with filters and pagination. `sort: "relevance"` ranks hits by match quality and interleaves each account's best results first.
|
|
137
266
|
- `list_emails`: list email summaries in chronological order with filters and pagination, without full-text search. Prefer this when browsing by sender, date, or mailbox.
|
|
138
|
-
- `
|
|
267
|
+
- `list_senders`: rank senders by message count with per-sender unread counts, merged across the selected accounts — good for "who emails me most" or finding a person.
|
|
268
|
+
- `get_email`: return metadata and body for a single message, by id, Message-ID, or mailbox plus UID. `format` (`full`/`text`/`headers`/`summary`) and `maxBodyChars` keep responses sized for context windows.
|
|
269
|
+
- `get_emails`: read a group of up to 25 messages in one call by id. Prefer this over looping `get_email` for several full bodies.
|
|
139
270
|
- `get_thread`: return all locally known messages in one conversation, matched by Message-ID, In-Reply-To, and References headers.
|
|
271
|
+
- `list_attachments`: list a message's attachments (index, filename, type, size) without downloading them.
|
|
272
|
+
- `get_attachment`: extract one attachment by index or filename — returns base64 up to `maxBytes`, or writes to disk with `saveTo`.
|
|
140
273
|
- `get_raw_email`: return raw RFC822/MIME source for one message, byte-limited. Use this only when you need original headers or MIME structure.
|
|
141
274
|
- `get_storage_stats`: report SQLite database, WAL, and page statistics for the local mirror.
|
|
142
275
|
- `optimize_email_store`: run lightweight SQLite and FTS maintenance to keep queries fast. Safe to run after large syncs.
|
|
143
276
|
|
|
144
|
-
`search_emails`, `list_emails`, and `get_recent_emails` accept unread and flagged filters
|
|
277
|
+
`search_emails`, `list_emails`, and `get_recent_emails` accept `mailbox`/`mailboxes`, unread, and flagged filters; `search_emails` and `list_emails` add `from`/`to`/`cc`/`subject`, date ranges (`startDate`/`endDate`) or relative `last` windows like `"7d"`, and `limit`/`cursor`/`nextCursor` pagination — pagination works across merged multi-account results too.
|
|
145
278
|
|
|
146
279
|
## Typical workflow
|
|
147
280
|
|
|
148
|
-
1. Run `
|
|
149
|
-
2. Run `get_sync_status` to confirm the mirror is fresh.
|
|
150
|
-
3. Run `get_recent_emails` with `unreadOnly: true
|
|
151
|
-
4. Run `get_email` to
|
|
152
|
-
5. Run `search_emails` or `list_emails` to find older messages by sender, subject, date range, or unread and flagged state.
|
|
281
|
+
1. Run `check_accounts` to verify credentials and connectivity (or `read-email-mcp accounts test` outside the client).
|
|
282
|
+
2. Run `sync_email` with a small limit on one mailbox, then `get_sync_status` to confirm the mirror is fresh.
|
|
283
|
+
3. Run `get_inbox_summary` for unread counts and the newest unread per account, or `get_recent_emails` with `unreadOnly: true`.
|
|
284
|
+
4. Run `get_email` (with `format`/`maxBodyChars` to keep responses small) or `get_thread` to follow a conversation.
|
|
285
|
+
5. Run `search_emails` (optionally `sort: "relevance"`) or `list_emails` to find older messages by sender, subject, date range, or unread and flagged state.
|
|
153
286
|
|
|
154
287
|
## How sync works
|
|
155
288
|
|
|
156
|
-
Sync connects to IMAP, lists selectable mailboxes, and fetches new messages by tracking the highest UID already seen per mailbox. If a mailbox UIDVALIDITY changes, the local copy for that mailbox is reset and refetched. Raw RFC822 source is written to disk, parsed metadata and body text go into SQLite, and a full-text search index is maintained alongside.
|
|
289
|
+
Sync connects to IMAP, lists selectable mailboxes, and fetches new messages by tracking the highest UID already seen per mailbox. If a mailbox UIDVALIDITY changes, the local copy for that mailbox is reset and refetched (stale raw files are removed). Raw RFC822 source is written to disk, parsed metadata and body text go into SQLite, and a full-text search index is maintained alongside.
|
|
290
|
+
|
|
291
|
+
Sync has two modes:
|
|
292
|
+
|
|
293
|
+
- **Incremental** (default): only fetches UIDs above the stored high-water mark per mailbox. `resetMailbox: true` restarts the scan from UID 1 without losing the local copy (upserts refresh rows in place).
|
|
294
|
+
- **Targeted**: pass `uids` (a set like `"12,15,20-30"`, requires one mailbox), `search` (server-side IMAP criteria: `from`, `to`, `cc`, `subject`, `since`, `before`, `unseen`, `flagged`), or `since` (shorthand for `search.since`). Targeted syncs fetch exactly the matching messages and never move the incremental cursor, so they are safe for backfills and one-off fetches.
|
|
295
|
+
|
|
296
|
+
Mailbox selection: `mailbox`/`mailboxes` include specific folders, `excludeMailboxes` drops names (`*` wildcard supported), and `excludeFlags` drops folders by IMAP special-use flag — the default `["\\All"]` avoids double-mirroring Gmail's All Mail. Pass `excludeFlags: []` to sync everything.
|
|
297
|
+
|
|
298
|
+
Flag freshness: incremental sync does not revisit already-synced messages, so `\Seen`/`\Flagged` changes and server-side deletions go stale over time. `refreshFlags: true` performs a cheap flags-only pass over synced UIDs, updating stored flags; `pruneExpunged` (default true alongside `refreshFlags`) also removes local copies of messages deleted on the server.
|
|
157
299
|
|
|
158
|
-
|
|
300
|
+
Mailboxes are opened read-only, so flags and read state on the server are never changed.
|
|
159
301
|
|
|
160
302
|
## Local storage
|
|
161
303
|
|
|
@@ -194,9 +336,10 @@ Tests use fixtures and fake IMAP clients, so they do not require real credential
|
|
|
194
336
|
|
|
195
337
|
- No sending, replying, or composing email.
|
|
196
338
|
- No deleting, moving, flagging, or marking messages read.
|
|
197
|
-
- No OAuth. App passwords
|
|
339
|
+
- No OAuth. App passwords, direct passwords, or `passwordCommand` credential helpers only.
|
|
198
340
|
- No background daemon. Sync runs when the client calls `sync_email`.
|
|
199
|
-
-
|
|
341
|
+
- Threads are assembled within one account's mirror; conversations spanning accounts are not merged.
|
|
342
|
+
- `get_attachment` re-parses the stored `.eml` on demand, so extraction speed depends on message size.
|
|
200
343
|
|
|
201
344
|
## License
|
|
202
345
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runCli(argv: string[]): Promise<number>;
|