hypermail-mcp 0.1.0
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 -0
- package/README.md +140 -0
- package/dist/cli.js +1101 -0
- package/dist/cli.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mateo Tiedra
|
|
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
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# hypermail-mcp
|
|
2
|
+
|
|
3
|
+
A **Model Context Protocol** server that lets an agent operate any of the user's
|
|
4
|
+
inboxes through a single, unified tool surface.
|
|
5
|
+
|
|
6
|
+
The agent doesn't care whether an address is a work Outlook account, a personal
|
|
7
|
+
Microsoft account, or (soon) a personal IMAP mailbox — it just calls
|
|
8
|
+
`list_emails`, `search_emails`, `read_email`, `send_email` and passes the email
|
|
9
|
+
address as the `account` argument. The server routes to the right backend.
|
|
10
|
+
|
|
11
|
+
**v1 status:** Outlook / Microsoft 365 (personal + work) fully supported via
|
|
12
|
+
Microsoft Graph. IMAP and Gmail are stubbed at the provider interface so they
|
|
13
|
+
can be plugged in without touching tool definitions.
|
|
14
|
+
|
|
15
|
+
## Why
|
|
16
|
+
|
|
17
|
+
- Existing Outlook/M365 MCP servers (e.g. `@softeria/ms-365-mcp-server`) expose
|
|
18
|
+
~200 raw Graph endpoints and are tied to a single signed-in user.
|
|
19
|
+
- This project wraps the same proven stack (`@azure/msal-node` for auth,
|
|
20
|
+
`@microsoft/microsoft-graph-client` for HTTP) but exposes only a small,
|
|
21
|
+
provider-agnostic email API and supports **multiple accounts at once**, keyed
|
|
22
|
+
by email address.
|
|
23
|
+
|
|
24
|
+
## Install / run
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g hypermail-mcp # or pnpm / npx
|
|
28
|
+
hypermail-mcp --help
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Run as a stdio MCP server (the default) — wire it into your MCP host:
|
|
32
|
+
|
|
33
|
+
### Claude Desktop / Claude Code
|
|
34
|
+
|
|
35
|
+
```jsonc
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"hyper-email": {
|
|
39
|
+
"command": "npx",
|
|
40
|
+
"args": ["-y", "hypermail-mcp"]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or via the CLI:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
claude mcp add hypermail -- npx -y hypermail-mcp
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### As a hosted HTTP server
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
hypermail-mcp --http --port 3000 --host 0.0.0.0
|
|
56
|
+
# endpoint: http://<host>:3000/mcp (Streamable HTTP transport, session-aware)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
When hosted you **must** set `HYPERMAIL_MCP_KEY` so the account file is
|
|
60
|
+
reproducibly decryptable.
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
| Env var | Purpose | Default |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| `HYPERMAIL_MCP_DATA_DIR` | Where to keep the encrypted accounts blob | `~/.hypermail-mcp` |
|
|
67
|
+
| `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 |
|
|
68
|
+
| `MS_CLIENT_ID` | Azure Entra public client (application) id used for device-code login | placeholder — **set your own for production** |
|
|
69
|
+
| `MS_TENANT_ID` | Tenant for the authority URL | `common` |
|
|
70
|
+
|
|
71
|
+
CLI flags: `--http`, `--port`, `--host`, `--data-dir`, `--read-only`, `--help`.
|
|
72
|
+
|
|
73
|
+
## Tools
|
|
74
|
+
|
|
75
|
+
All "email" tools take an `account` argument — the email address of the inbox
|
|
76
|
+
to operate on. The server resolves the right provider from the encrypted
|
|
77
|
+
account store.
|
|
78
|
+
|
|
79
|
+
| Tool | Inputs | Notes |
|
|
80
|
+
| --- | --- | --- |
|
|
81
|
+
| `list_accounts` | — | Returns registered emails + provider, no secrets. |
|
|
82
|
+
| `add_account` | `provider`, `email?`, `config?` | Starts device-code (Outlook). Returns `{handle, verification:{userCode, verificationUri, expiresAt}}`. |
|
|
83
|
+
| `complete_add_account` | `provider`, `handle` | Returns `pending` / `ready` / `expired` / `error`. |
|
|
84
|
+
| `remove_account` | `email` | Deletes tokens for the account. |
|
|
85
|
+
| `list_emails` | `account`, `folder?`, `limit?`, `unreadOnly?` | Defaults: folder=`inbox`, limit=25. |
|
|
86
|
+
| `search_emails` | `account`, `query`, `limit?` | KQL on Outlook. |
|
|
87
|
+
| `read_email` | `account`, `id` | Returns full body + recipients + attachment metadata. |
|
|
88
|
+
| `send_email` | `account`, `to[]`, `cc?`, `bcc?`, `subject`, `body`, `isHtml?` | Disabled under `--read-only`. |
|
|
89
|
+
|
|
90
|
+
### Add-account flow (Outlook)
|
|
91
|
+
|
|
92
|
+
1. Agent calls `add_account({ provider: "outlook" })`.
|
|
93
|
+
2. Server returns:
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"status": "pending",
|
|
97
|
+
"handle": "…uuid…",
|
|
98
|
+
"verification": {
|
|
99
|
+
"userCode": "ABCD-EFGH",
|
|
100
|
+
"verificationUri": "https://microsoft.com/devicelogin",
|
|
101
|
+
"expiresAt": "2025-…",
|
|
102
|
+
"message": "To sign in, use a web browser to open …"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
3. The user opens the URL and enters the code.
|
|
107
|
+
4. Agent polls `complete_add_account({ provider: "outlook", handle })` until
|
|
108
|
+
it returns `{ "status": "ready", "account": {...} }`.
|
|
109
|
+
5. From then on, any tool can be called with `account: "<that-email>"`.
|
|
110
|
+
|
|
111
|
+
## Roadmap
|
|
112
|
+
|
|
113
|
+
- IMAP provider (interface already in place at `src/providers/imap/index.ts`)
|
|
114
|
+
— `imapflow` + `nodemailer`, password/app-password stored encrypted.
|
|
115
|
+
- Gmail provider via Google OAuth.
|
|
116
|
+
- Folder listing, attachment upload/download, mark-as-read.
|
|
117
|
+
- Threading / conversations.
|
|
118
|
+
|
|
119
|
+
## Project layout
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
src/
|
|
123
|
+
cli.ts # arg parsing + entry
|
|
124
|
+
server.ts # MCP server, stdio + HTTP transports
|
|
125
|
+
version.ts
|
|
126
|
+
store/account-store.ts # encrypted multi-account store (AES-256-GCM)
|
|
127
|
+
providers/
|
|
128
|
+
types.ts # EmailProvider interface + shared DTOs
|
|
129
|
+
registry.ts # routes account email → provider
|
|
130
|
+
outlook/
|
|
131
|
+
auth.ts # msal-node device-code flow
|
|
132
|
+
client.ts # @microsoft/microsoft-graph-client factory
|
|
133
|
+
index.ts # OutlookProvider implementation
|
|
134
|
+
imap/index.ts # stub
|
|
135
|
+
tools/index.ts # MCP tool registrations
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
MIT
|