hypermail-mcp 0.6.1 → 0.6.3

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/README.md CHANGED
@@ -3,14 +3,20 @@
3
3
  A **Model Context Protocol** server that lets an agent operate any of the user's
4
4
  inboxes through a single, unified tool surface.
5
5
 
6
+ > **v0.6.3** — Unify stdio and HTTP modes into a single feature set. Removed
7
+ > email watch (inbox polling, SSE push, notification buffer), agent
8
+ > multi-tenancy (`agents.yaml`, `x-api-key` auth, per-agent allowlists), and
9
+ > the `check_notifications` tool. Dropped `js-yaml` dependency. Dockerfile
10
+ > simplified to a single `install → build → prune` step.
11
+ >
12
+ > **v0.6.2** — Version source-of-truth fix: `version.ts` now imports directly
13
+ > from `package.json` instead of hardcoding, preventing version drift between
14
+ > the two files.
15
+ >
6
16
  > **v0.6.1** — Docker deployment (standalone Dockerfile with HEALTHCHECK),
7
17
  > email notification bug fixes (ID-based dedup, pagination cap, dynamic
8
18
  > re-scan), Node 22 base image, dropped docker-compose.
9
19
  >
10
- > **v0.6.0** — Email watch notifications (polling-based), `signaturePath`
11
- > support in `set_account_settings` for loading signatures from files,
12
- > and a `check_notifications` tool for draining pending alerts.
13
- >
14
20
  > **v0.5.0** — Replaced optional `isHtml` boolean with required `format`
15
21
  > parameter (`"html"` | `"markdown"`) on `send_email`, `draft_email`, and
16
22
  > `edit_draft`. Markdown bodies are converted to HTML via `marked` so
@@ -95,135 +101,37 @@ docker run -d \
95
101
 
96
102
  The image runs the server in HTTP mode on port 3000 with a 30-second
97
103
  HEALTHCHECK against `/mcp`. Data is persisted via a Docker volume at `/data`.
98
- Pass `HYPERMAIL_AGENTS_CONFIG` and mount a config file for agent multi-tenancy.
99
104
 
100
- ### Development (HTTP mode + email watch)
105
+ ### Development
101
106
 
102
- To test the email watch feature locally:
107
+ To test the HTTP server locally:
103
108
 
104
109
  ```bash
105
110
  # Terminal 1: auto-rebuild TypeScript on save
106
111
  pnpm dev
107
112
 
108
- # Terminal 2: start HTTP server with dev config (10s poll, separate data dir)
113
+ # Terminal 2: start HTTP server with dev config
109
114
  pnpm dev:http
110
115
  ```
111
116
 
112
117
  The server listens on `http://127.0.0.1:3000/mcp`. Pi connects via the
113
118
  `.pi/mcp.json` config (read by `pi-mcp-adapter`). Tools appear as
114
- `hypermail_http_*` (e.g. `hypermail_http_check_notifications`).
115
-
116
- The dev config (`hypermail-config.http.json`) uses a separate data dir
117
- (`~/.hypermail-mcp-dev`) and a 10-second poll interval for fast feedback.
118
-
119
- ## Modes: stdio vs HTTP
120
-
121
- The server runs in one of two modes — the choice affects session management,
122
- security, and which features are available.
123
-
124
- | | stdio (default) | HTTP (`--http`) |
125
- | --- | --- | --- |
126
- | **Transport** | stdin/stdout | HTTP (Streamable HTTP MCP) |
127
- | **Lifecycle** | Per-invocation (lazy) — spawned on demand by the MCP host | Long-lived server process |
128
- | **Session model** | One `McpServer` instance for all invocations | One `McpServer` per MCP session (multi-tenant) |
129
- | **Key management** | Auto-generated, stored in OS keychain or `master.key` file | Requires `HYPERMAIL_MCP_KEY` env var (32-byte key for AES-256-GCM) |
130
- | **Email watch** | ❌ Not available | ✅ Polls inbox every N seconds for new mail |
131
- | **`check_notifications`** | ❌ Not registered | ✅ Drains pending new-mail alerts |
132
- | **Agent multi-tenancy** | ❌ Unrestricted access | ✅ Per-agent API keys, account allowlists, provisioning control (via `agents.yaml`) |
133
- | **Pi tool naming** | `hyper_*` | `hypermail_http_*` |
134
-
135
- **When to use HTTP mode:**
136
- - You need email watch / push notifications
137
- - You want to expose the server to multiple agents with different permissions
138
- - You're hosting the server as a service (Docker, cloud)
139
-
140
- **When to use stdio mode:**
141
- - Single-user local development with a desktop MCP client (Claude, Pi)
142
- - You don't need email watch or multi-agent access control
143
-
144
- ## Agent multi-tenancy
145
-
146
- In HTTP mode, the server can be shared across multiple agents with
147
- different permissions. Agent identity and authorization are defined in an
148
- `agents.yaml` file.
149
-
150
- ### agents.yaml
151
-
152
- ```yaml
153
- agents:
154
- - id: my-assistant
155
- api_key: hm_sk_<64-hex-chars>
156
- name: My Email Assistant
157
- accounts: # which email addresses this agent can access
158
- - alice@example.com
159
- - bob@example.com
160
- provisioning: false # can this agent add/remove accounts?
161
-
162
- - id: admin-agent
163
- api_key: hm_sk_<64-hex-chars>
164
- name: Admin Agent
165
- accounts: [] # empty = all accounts
166
- provisioning: true
167
-
168
- # Optional: pre-declare email accounts with provider hints
169
- email_accounts:
170
- alice@example.com:
171
- provider: outlook
172
- ```
173
-
174
- **Agent ID:** lowercase letters, digits, hyphens, underscores. No spaces.
175
-
176
- **API key format:** `hm_sk_` prefix + 64 hex characters. Generate with:
177
-
178
- ```bash
179
- hypermail-mcp generate-key
180
- # => hm_sk_a1b2c3d4...
181
- ```
182
-
183
- The API key is hashed (SHA-256) before storage — the plaintext is never
184
- written to disk. Agents authenticate by passing the key in the
185
- `Authorization: Bearer hm_sk_...` header.
186
-
187
- **accounts:** An allowlist of email addresses the agent can operate on.
188
- If empty or omitted, the agent can access all configured accounts.
189
-
190
- **provisioning:** When `true`, the agent can call `add_account` and
191
- `remove_account`. Defaults to `false`.
192
-
193
- ### Configuration
194
-
195
- Point the server at your agents.yaml:
119
+ `hypermail_http_*`.
196
120
 
197
- ```bash
198
- # Via CLI flag
199
- hypermail-mcp --http --agents-config ./agents.yaml
200
-
201
- # Via env var
202
- export HYPERMAIL_AGENTS_CONFIG=/etc/hypermail/agents.yaml
203
- ```
204
-
205
- The server watches `agents.yaml` for changes and reloads automatically
206
- (live reload — no restart needed). Agents removed from the file lose
207
- access on their next request.
208
-
209
- In **stdio mode**, agent multi-tenancy is not available — the server runs
210
- with unrestricted access (the local user _is_ the agent).
211
-
212
- ## Configuration
121
+ ## Add-account flow (Outlook)
213
122
 
214
123
  | Env var | Purpose | Default |
215
124
  | --- | --- | --- |
216
125
  | `HYPERMAIL_MCP_DATA_DIR` | Where to keep the encrypted accounts blob | `~/.hypermail-mcp` |
217
- | `HYPERMAIL_MCP_KEY` | 32-byte AES-256-GCM key (hex, base64, or any passphrase — derived via SHA-256). Required for hosted deployments. | auto-generated, stored via OS keychain (`keytar`) or a local `master.key` file |
218
- | `HYPERMAIL_AGENTS_CONFIG` | Path to `agents.yaml` for HTTP multi-tenant mode (see Agent multi-tenancy above). | — (multi-tenancy disabled) |
126
+ | `HYPERMAIL_MCP_KEY` | 32-byte AES-256-GCM key (hex, base64, or any passphrase — derived via SHA-256). Required for hosted deployments. Auto-generated for stdio. | auto-generated, stored via OS keychain (`keytar`) or a local `master.key` file |
219
127
  | `MS_CLIENT_ID` | Azure Entra public client (application) id used for device-code login | placeholder — **set your own for production** |
220
128
  | `MS_TENANT_ID` | Tenant for the authority URL | `common` |
221
129
 
222
- CLI flags: `--http`, `--port`, `--host`, `--data-dir`, `--agents-config`, `--read-only`, `--help`.
130
+ CLI flags: `--http`, `--port`, `--host`, `--data-dir`, `--read-only`, `--help`.
223
131
 
224
- Subcommands: `hypermail-mcp generate-key` — generate an `hm_sk_` API key for agents.yaml.
132
+ Subcommands: `hypermail-mcp generate-key` — generate an `hm_sk_` API key.
225
133
 
226
- ### Config file (`hypermail-config.json`)
134
+ ### Configuration
227
135
 
228
136
  Instead of (or in addition to) CLI flags and env vars, you can configure the
229
137
  server with a `hypermail-config.json` file next to the server binary. The server
@@ -281,45 +189,8 @@ account store.
281
189
  | `rename_folder` | `account`, `folderId`, `newName` | Rename an existing mail folder. Disabled under `--read-only`. |
282
190
  | `mark_read` | `account`, `id` | Mark a message as read. Disabled under `--read-only`. |
283
191
  | `mark_unread` | `account`, `id` | Mark a message as unread. Disabled under `--read-only`. |
284
- | `check_notifications` | — | Returns pending email-watch notifications (new-email alerts, auth failures). Drains the buffer on read. Only registered in HTTP mode. |
285
-
286
- ## Email Watch
287
-
288
- When running in **HTTP mode** (`--http`), the server polls all configured
289
- accounts every N seconds for new inbox mail. Detected emails and auth failures
290
- are delivered through two channels:
291
-
292
- - **Push** — `notifications/message` sent over the MCP stream. Compatible
293
- clients (e.g. Mastra) receive these in real time.
294
- - **Poll** — `check_notifications` tool drains an in-memory buffer. Works with
295
- **any** MCP client, even those that don't maintain an SSE listener.
296
-
297
- **Configuration** (in `hypermail-config.json`):
298
-
299
- ```jsonc
300
- {
301
- "watch": {
302
- "enabled": true, // default true
303
- "pollIntervalSeconds": 60 // default 60 (min 10, max 3600)
304
- }
305
- }
306
- ```
307
-
308
- **Behavior:**
309
-
310
- - Only the **inbox** folder is watched. All stored accounts are polled by default.
311
- - On first poll per account, the server records the newest email as a baseline
312
- (no notifications). Only emails arriving after baseline trigger alerts.
313
- - Baselines (`lastSeenAt`) persist in the account store — they survive server
314
- restarts.
315
- - Each poll paginates through the inbox (25 items per page) to catch email
316
- bursts without missing messages.
317
- - Auth failures (e.g. expired OAuth tokens) generate immediate notifications.
318
-
319
- **Not supported in stdio mode.** The watcher requires a long-lived server
320
- process. In stdio mode the `check_notifications` tool is not registered.
321
192
 
322
- ### Add-account flow (Outlook)
193
+ ## Add-account flow (Outlook)
323
194
 
324
195
  1. Agent calls `add_account({ provider: "outlook" })`.
325
196
  2. Server returns:
@@ -353,11 +224,8 @@ src/
353
224
  server.ts # MCP server, stdio + HTTP transports, session management
354
225
  version.ts # version constant
355
226
  config.ts # hypermail-config.json schema + resolution
356
- config/
357
- agents-config.ts # agents.yaml schema, validation, live-reload watcher
358
227
  store/
359
228
  account-store.ts # encrypted multi-account store (AES-256-GCM)
360
- agent-store.ts # agent identity + credentials store (HTTP multi-tenant)
361
229
  crypto.ts # AES-256-GCM encrypt/decrypt, key resolution, atomic writes
362
230
  providers/
363
231
  types.ts # EmailProvider interface + shared DTOs
@@ -372,17 +240,12 @@ src/
372
240
  client.ts # Gmail API (googleapis)
373
241
  index.ts # GmailProvider implementation
374
242
  shared/ # shared utilities across providers
375
- watcher/
376
- manager.ts # inbox poller + notification buffer
377
- index.ts # watcher public API
378
243
  tools/
379
244
  index.ts # MCP tool registrations
380
- agent-context.ts # agent authorization guards (checkAccountAccess, checkProvisioning)
381
245
  accounts.ts # list/add/remove/complete-add account tools
382
246
  browse.ts # list/search/read email tools
383
247
  compose.ts # send/draft/edit/send-draft/add-attachment tools
384
248
  folders.ts # list/create/delete/rename folder tools
385
- notifications.ts # check_notifications tool (HTTP only)
386
249
  organize.ts # archive/trash/move/mark-read/mark-unread tools
387
250
  shared.ts # shared tool helpers
388
251
  ```