proton-mcp 0.1.0__tar.gz
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.
- proton_mcp-0.1.0/LICENSE +21 -0
- proton_mcp-0.1.0/PKG-INFO +244 -0
- proton_mcp-0.1.0/README.md +219 -0
- proton_mcp-0.1.0/proton_mcp.egg-info/PKG-INFO +244 -0
- proton_mcp-0.1.0/proton_mcp.egg-info/SOURCES.txt +14 -0
- proton_mcp-0.1.0/proton_mcp.egg-info/dependency_links.txt +1 -0
- proton_mcp-0.1.0/proton_mcp.egg-info/entry_points.txt +2 -0
- proton_mcp-0.1.0/proton_mcp.egg-info/requires.txt +8 -0
- proton_mcp-0.1.0/proton_mcp.egg-info/top_level.txt +1 -0
- proton_mcp-0.1.0/proton_mcp.py +832 -0
- proton_mcp-0.1.0/pyproject.toml +48 -0
- proton_mcp-0.1.0/setup.cfg +4 -0
- proton_mcp-0.1.0/tests/test_auth.py +188 -0
- proton_mcp-0.1.0/tests/test_core.py +296 -0
- proton_mcp-0.1.0/tests/test_security.py +153 -0
- proton_mcp-0.1.0/tests/test_server.py +42 -0
proton_mcp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Victor De Abreu
|
|
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.
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: proton-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for Proton Mail through Proton Mail Bridge (local stdio or remote claude.ai connector)
|
|
5
|
+
Author: Victor De Abreu
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/vdeabreu/proton-mcp
|
|
8
|
+
Project-URL: Issues, https://github.com/vdeabreu/proton-mcp/issues
|
|
9
|
+
Keywords: mcp,mcp-server,proton-mail,protonmail,proton-bridge,email,claude
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Communications :: Email
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: mcp==2.3.0
|
|
19
|
+
Provides-Extra: remote
|
|
20
|
+
Requires-Dist: uvicorn>=0.30; extra == "remote"
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
23
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# proton-mcp
|
|
27
|
+
|
|
28
|
+
[](https://pypi.org/project/proton-mcp/)
|
|
29
|
+
[](https://github.com/vdeabreu/proton-mcp/actions/workflows/ci.yml)
|
|
30
|
+
[](https://github.com/vdeabreu/proton-mcp/blob/main/LICENSE)
|
|
31
|
+
|
|
32
|
+
<!-- mcp-name: io.github.vdeabreu/proton-mcp -->
|
|
33
|
+
|
|
34
|
+
An [MCP](https://modelcontextprotocol.io) server that gives Claude (or any MCP
|
|
35
|
+
client) access to your **Proton Mail** mailbox through
|
|
36
|
+
[Proton Mail Bridge](https://proton.me/mail/bridge).
|
|
37
|
+
|
|
38
|
+
- **Read**: list folders, list and search emails, read an email with its attachments list.
|
|
39
|
+
Nothing is ever marked as read, moved or deleted.
|
|
40
|
+
- **Send** (optional): send and reply from any of your Proton addresses, with your
|
|
41
|
+
display name, HTML formatting from light Markdown, proper threading, and the
|
|
42
|
+
original message quoted below replies.
|
|
43
|
+
- Runs **locally** for Claude Desktop (stdio), or **remotely** as a claude.ai
|
|
44
|
+
custom connector (streamable HTTP + OAuth).
|
|
45
|
+
|
|
46
|
+
> Unofficial project, not affiliated with or endorsed by Proton AG.
|
|
47
|
+
|
|
48
|
+
## Why this one
|
|
49
|
+
|
|
50
|
+
Several Proton Mail MCP servers exist. This one is built for a specific use:
|
|
51
|
+
an assistant that reads your mail and drafts replies, without being able to
|
|
52
|
+
damage the mailbox.
|
|
53
|
+
|
|
54
|
+
- **Works in claude.ai on the web and on your phone**, not only in Claude Desktop:
|
|
55
|
+
a remote mode with OAuth, Docker and reverse-proxy configs, and a full
|
|
56
|
+
[deployment guide](https://github.com/vdeabreu/proton-mcp/blob/main/docs/deploy.md).
|
|
57
|
+
- **Can't change your mailbox.** No move, flag or delete tools; folders are opened
|
|
58
|
+
read-only and nothing is marked as read. Sending is opt-in, flagged
|
|
59
|
+
destructive, and refused from any address that isn't yours.
|
|
60
|
+
- **Defends against prompt injection in emails**: hidden HTML text is dropped and
|
|
61
|
+
IMAP arguments can't carry extra commands.
|
|
62
|
+
- **Mail that looks like Proton's**: your display name, the right address when
|
|
63
|
+
replying, threading, and the original quoted the way Proton quotes it.
|
|
64
|
+
|
|
65
|
+
If you want the model to organise your mailbox (labels, bulk moves,
|
|
66
|
+
attachments), a broader server will suit you better.
|
|
67
|
+
|
|
68
|
+
## How it works
|
|
69
|
+
|
|
70
|
+
Proton Mail is end-to-end encrypted, so there is no plain IMAP server to talk to.
|
|
71
|
+
Proton Mail Bridge (paid plans) runs on your machine, decrypts locally and exposes
|
|
72
|
+
IMAP/SMTP on `127.0.0.1`. This server talks to Bridge, and only to a loopback
|
|
73
|
+
address.
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
Claude Desktop ──stdio──> proton_mcp.py ──IMAP/SMTP──> Bridge (127.0.0.1) ──> Proton
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Tools
|
|
80
|
+
|
|
81
|
+
| Tool | What it does |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| `list_folders` | Folder names (labels and system folders included). |
|
|
84
|
+
| `list_emails` | Latest emails of a folder, newest first (headers only). |
|
|
85
|
+
| `search_emails` | Search by sender, recipient, subject, text, date range, unread. |
|
|
86
|
+
| `read_email` | Full email: headers, text body (HTML converted to text), attachments list. |
|
|
87
|
+
| `list_sender_addresses` | The addresses `send_email` can send from, with the display name used for each. |
|
|
88
|
+
| `send_email` | Send or reply, from any of your addresses (`from_address`). Flagged destructive: clients ask before each call. |
|
|
89
|
+
|
|
90
|
+
`send_email` takes a body in light Markdown: blank line = paragraph, `- ` bullets,
|
|
91
|
+
`1. ` numbered lists, `**bold**`, `*italic*`, `[text](https://url)`. It is sent as
|
|
92
|
+
HTML with a plain-text alternative. With `reply_to_uid`, the reply is threaded
|
|
93
|
+
(`In-Reply-To`, `References`) and quotes the original (`include_original=false`
|
|
94
|
+
to skip).
|
|
95
|
+
|
|
96
|
+
The sender is your Bridge login by default. `from_address` picks another address
|
|
97
|
+
of your account, and replies go out from the address the original was sent to,
|
|
98
|
+
like in Proton's own apps. Bridge doesn't add the display name set in Proton's
|
|
99
|
+
settings, so the server takes it from your recent messages in Sent.
|
|
100
|
+
|
|
101
|
+
## Local setup (Claude Desktop)
|
|
102
|
+
|
|
103
|
+
Requirements: [uv](https://docs.astral.sh/uv/) (or Python 3.12+), Proton Mail
|
|
104
|
+
Bridge installed and logged in.
|
|
105
|
+
|
|
106
|
+
In Bridge, open your account and copy the **IMAP/SMTP username and password**
|
|
107
|
+
(generated by Bridge, not your Proton password). Then add the server to
|
|
108
|
+
`claude_desktop_config.json`. Open it from Claude Desktop → Settings → Developer →
|
|
109
|
+
Edit Config, or directly:
|
|
110
|
+
|
|
111
|
+
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
112
|
+
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
113
|
+
- Linux: `~/.config/Claude/claude_desktop_config.json`
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"mcpServers": {
|
|
118
|
+
"proton-mail": {
|
|
119
|
+
"command": "uvx",
|
|
120
|
+
"args": ["proton-mcp"],
|
|
121
|
+
"env": {
|
|
122
|
+
"PROTON_BRIDGE_USER": "you@proton.me",
|
|
123
|
+
"PROTON_BRIDGE_PASSWORD": "password-from-bridge"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Fully quit and restart Claude Desktop after editing the file.
|
|
131
|
+
|
|
132
|
+
Without uv: `pip install proton-mcp`, then use `"command": "proton-mcp"` (the full
|
|
133
|
+
path to that script if it isn't on your `PATH`) and no `args`.
|
|
134
|
+
|
|
135
|
+
### Configuration
|
|
136
|
+
|
|
137
|
+
| Variable | Default | |
|
|
138
|
+
| --- | --- | --- |
|
|
139
|
+
| `PROTON_BRIDGE_USER` | (required) | Username shown by Bridge |
|
|
140
|
+
| `PROTON_BRIDGE_PASSWORD` | (required) | Password generated by Bridge |
|
|
141
|
+
| `PROTON_IMAP_HOST` | `127.0.0.1` | Must be a loopback address (also used for SMTP) |
|
|
142
|
+
| `PROTON_IMAP_PORT` | `1143` | |
|
|
143
|
+
| `PROTON_IMAP_SECURITY` | `starttls` | `starttls` (Bridge default) or `ssl` |
|
|
144
|
+
| `PROTON_SMTP_PORT` | `1025` | |
|
|
145
|
+
| `PROTON_SMTP_SECURITY` | `starttls` | `starttls` or `ssl` |
|
|
146
|
+
| `PROTON_QUOTE_LANG` | `en` | Language of the "On … wrote:" line in replies: `en` or `fr` |
|
|
147
|
+
| `PROTON_SENDER_NAME` | *(from Sent)* | Name shown in `From`, for every address. By default, the name found on your recent messages in Sent from that address; set it empty for the bare address |
|
|
148
|
+
| `PROTON_FROM_ADDRESSES` | *(none)* | Extra addresses of your account allowed as `from_address`, comma-separated. The Bridge login and the addresses you've sent from (found in Sent) are always allowed; any other address is refused |
|
|
149
|
+
| `PROTON_ENABLE_SEND` | `true` | `false` removes `send_email` and `list_sender_addresses`: the server becomes strictly read-only |
|
|
150
|
+
|
|
151
|
+
The config file holds your Bridge password: keep it readable by you only.
|
|
152
|
+
|
|
153
|
+
## Remote setup (claude.ai connector)
|
|
154
|
+
|
|
155
|
+
`remote/server.py` serves the same tools over streamable HTTP, behind a
|
|
156
|
+
single-user OAuth password page, for claude.ai on the web and mobile.
|
|
157
|
+
`send_email` and `list_sender_addresses` are off unless `ENABLE_SEND=true`; the
|
|
158
|
+
`PROTON_*` variables above work the same in `.env`. A Dockerfile and compose file are
|
|
159
|
+
included, plus Apache and Caddy configs that only let Anthropic's IP ranges reach
|
|
160
|
+
`/mcp`.
|
|
161
|
+
|
|
162
|
+
See **[docs/deploy.md](https://github.com/vdeabreu/proton-mcp/blob/main/docs/deploy.md)** for the full guide (headless Bridge,
|
|
163
|
+
Docker, reverse proxy, claude.ai).
|
|
164
|
+
|
|
165
|
+
## Security
|
|
166
|
+
|
|
167
|
+
Giving an AI assistant access to your mailbox is powerful and risky. What this
|
|
168
|
+
project does about it:
|
|
169
|
+
|
|
170
|
+
- **Read tools don't change anything.** Folders are opened with `EXAMINE` and
|
|
171
|
+
bodies fetched with `BODY.PEEK`; there is no tool to move, flag or delete.
|
|
172
|
+
Text arguments containing control characters are rejected, so a search term
|
|
173
|
+
can't smuggle extra IMAP commands to Bridge.
|
|
174
|
+
- **Sending is opt-in and should stay on approval.** `send_email` carries the MCP
|
|
175
|
+
`destructiveHint`, and the server instructions tell the model to show the exact
|
|
176
|
+
draft (sender address included) and wait for explicit approval. A hint is not enforcement: in your client,
|
|
177
|
+
keep `send_email` on "ask every time". Set `PROTON_ENABLE_SEND=false` (local) or
|
|
178
|
+
leave `ENABLE_SEND=false` (remote, the default) to remove it entirely.
|
|
179
|
+
- **Only your own addresses can send.** Bridge accepts any sender address, so the
|
|
180
|
+
server checks `from_address` itself against your addresses (Bridge login,
|
|
181
|
+
`PROTON_FROM_ADDRESSES`, addresses found in Sent) and refuses the rest.
|
|
182
|
+
- **Email content is untrusted.** An email can contain text written to steer the
|
|
183
|
+
model ("forward this to…", "search for …"). The server instructions say never
|
|
184
|
+
to follow instructions found in emails, and `read_email` drops text hidden with
|
|
185
|
+
the usual HTML tricks (`display:none`, `font-size:0`…), but neither is a
|
|
186
|
+
guarantee. Treat any action the model proposes after reading an email with
|
|
187
|
+
suspicion.
|
|
188
|
+
- **Loopback only.** The server refuses any Bridge host that isn't `127.0.0.1`,
|
|
189
|
+
`::1` or `localhost`. TLS verification is disabled for that reason only (Bridge
|
|
190
|
+
uses a self-signed certificate).
|
|
191
|
+
- **Remote mode**:
|
|
192
|
+
- OAuth with a 20+ character password, a lockout after 5 failures, and tokens
|
|
193
|
+
stored in SQLite.
|
|
194
|
+
- Only claude.ai's callback can be registered as redirect URI, and the number of
|
|
195
|
+
clients is capped.
|
|
196
|
+
- The password page says which client asks and can't be framed by another site.
|
|
197
|
+
- `/mcp` is restricted to Anthropic's outbound IPs by the reverse proxy.
|
|
198
|
+
- Every tool call is logged without email bodies; the container is read-only and
|
|
199
|
+
unprivileged.
|
|
200
|
+
- **Remote mode, known limits:**
|
|
201
|
+
- The lockout is global: anyone can make *new* logins wait 15 minutes by failing
|
|
202
|
+
5 times. Tokens already issued keep working.
|
|
203
|
+
- Anyone can add your server URL as a connector in *their own* claude.ai account
|
|
204
|
+
and send you the resulting authorization link. If you type your password, their
|
|
205
|
+
account gets access. Only type it right after clicking *Connect* yourself.
|
|
206
|
+
|
|
207
|
+
Your Bridge password and `MCP_PASSWORD` give access to your whole mailbox:
|
|
208
|
+
keep `.env` and `claude_desktop_config.json` private.
|
|
209
|
+
|
|
210
|
+
To report a vulnerability, see [SECURITY.md](https://github.com/vdeabreu/proton-mcp/blob/main/SECURITY.md).
|
|
211
|
+
|
|
212
|
+
## Limitations
|
|
213
|
+
|
|
214
|
+
- `search_emails` accepts one non-ASCII search field at a time (IMAP `CHARSET UTF-8`
|
|
215
|
+
literal).
|
|
216
|
+
- `read_email` converts HTML to text and drops link targets and hidden elements.
|
|
217
|
+
Hiding detection is a heuristic: white-on-white text or CSS classes get through.
|
|
218
|
+
- Replies quote the original as plain text (its formatting is not kept).
|
|
219
|
+
- Attachments are listed, not downloaded or sent.
|
|
220
|
+
- Bridge must be in *combined* address mode (the default), with one login for
|
|
221
|
+
all addresses. In *split* mode each address has its own login, and the server
|
|
222
|
+
only uses one.
|
|
223
|
+
- Proton rebuilds outgoing messages: recipients get base64-encoded parts and a
|
|
224
|
+
plain-text version that Proton regenerates from the HTML.
|
|
225
|
+
|
|
226
|
+
## Development
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
git clone https://github.com/vdeabreu/proton-mcp && cd proton-mcp
|
|
230
|
+
pip install -e ".[remote,dev]"
|
|
231
|
+
pytest
|
|
232
|
+
ruff check .
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Tests don't need Bridge: they cover IMAP command injection (against a fake
|
|
236
|
+
IMAP server), message building, Markdown rendering, quoting, hidden HTML,
|
|
237
|
+
folder-name encoding, sender address and display name selection, and the OAuth
|
|
238
|
+
flow (redirect allowlist, client cap, lockout, security headers).
|
|
239
|
+
|
|
240
|
+
See [AGENTS.md](https://github.com/vdeabreu/proton-mcp/blob/main/AGENTS.md) for the invariants to keep when changing the code.
|
|
241
|
+
|
|
242
|
+
## License
|
|
243
|
+
|
|
244
|
+
[MIT](https://github.com/vdeabreu/proton-mcp/blob/main/LICENSE)
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# proton-mcp
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/proton-mcp/)
|
|
4
|
+
[](https://github.com/vdeabreu/proton-mcp/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/vdeabreu/proton-mcp/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
<!-- mcp-name: io.github.vdeabreu/proton-mcp -->
|
|
8
|
+
|
|
9
|
+
An [MCP](https://modelcontextprotocol.io) server that gives Claude (or any MCP
|
|
10
|
+
client) access to your **Proton Mail** mailbox through
|
|
11
|
+
[Proton Mail Bridge](https://proton.me/mail/bridge).
|
|
12
|
+
|
|
13
|
+
- **Read**: list folders, list and search emails, read an email with its attachments list.
|
|
14
|
+
Nothing is ever marked as read, moved or deleted.
|
|
15
|
+
- **Send** (optional): send and reply from any of your Proton addresses, with your
|
|
16
|
+
display name, HTML formatting from light Markdown, proper threading, and the
|
|
17
|
+
original message quoted below replies.
|
|
18
|
+
- Runs **locally** for Claude Desktop (stdio), or **remotely** as a claude.ai
|
|
19
|
+
custom connector (streamable HTTP + OAuth).
|
|
20
|
+
|
|
21
|
+
> Unofficial project, not affiliated with or endorsed by Proton AG.
|
|
22
|
+
|
|
23
|
+
## Why this one
|
|
24
|
+
|
|
25
|
+
Several Proton Mail MCP servers exist. This one is built for a specific use:
|
|
26
|
+
an assistant that reads your mail and drafts replies, without being able to
|
|
27
|
+
damage the mailbox.
|
|
28
|
+
|
|
29
|
+
- **Works in claude.ai on the web and on your phone**, not only in Claude Desktop:
|
|
30
|
+
a remote mode with OAuth, Docker and reverse-proxy configs, and a full
|
|
31
|
+
[deployment guide](https://github.com/vdeabreu/proton-mcp/blob/main/docs/deploy.md).
|
|
32
|
+
- **Can't change your mailbox.** No move, flag or delete tools; folders are opened
|
|
33
|
+
read-only and nothing is marked as read. Sending is opt-in, flagged
|
|
34
|
+
destructive, and refused from any address that isn't yours.
|
|
35
|
+
- **Defends against prompt injection in emails**: hidden HTML text is dropped and
|
|
36
|
+
IMAP arguments can't carry extra commands.
|
|
37
|
+
- **Mail that looks like Proton's**: your display name, the right address when
|
|
38
|
+
replying, threading, and the original quoted the way Proton quotes it.
|
|
39
|
+
|
|
40
|
+
If you want the model to organise your mailbox (labels, bulk moves,
|
|
41
|
+
attachments), a broader server will suit you better.
|
|
42
|
+
|
|
43
|
+
## How it works
|
|
44
|
+
|
|
45
|
+
Proton Mail is end-to-end encrypted, so there is no plain IMAP server to talk to.
|
|
46
|
+
Proton Mail Bridge (paid plans) runs on your machine, decrypts locally and exposes
|
|
47
|
+
IMAP/SMTP on `127.0.0.1`. This server talks to Bridge, and only to a loopback
|
|
48
|
+
address.
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Claude Desktop ──stdio──> proton_mcp.py ──IMAP/SMTP──> Bridge (127.0.0.1) ──> Proton
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Tools
|
|
55
|
+
|
|
56
|
+
| Tool | What it does |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `list_folders` | Folder names (labels and system folders included). |
|
|
59
|
+
| `list_emails` | Latest emails of a folder, newest first (headers only). |
|
|
60
|
+
| `search_emails` | Search by sender, recipient, subject, text, date range, unread. |
|
|
61
|
+
| `read_email` | Full email: headers, text body (HTML converted to text), attachments list. |
|
|
62
|
+
| `list_sender_addresses` | The addresses `send_email` can send from, with the display name used for each. |
|
|
63
|
+
| `send_email` | Send or reply, from any of your addresses (`from_address`). Flagged destructive: clients ask before each call. |
|
|
64
|
+
|
|
65
|
+
`send_email` takes a body in light Markdown: blank line = paragraph, `- ` bullets,
|
|
66
|
+
`1. ` numbered lists, `**bold**`, `*italic*`, `[text](https://url)`. It is sent as
|
|
67
|
+
HTML with a plain-text alternative. With `reply_to_uid`, the reply is threaded
|
|
68
|
+
(`In-Reply-To`, `References`) and quotes the original (`include_original=false`
|
|
69
|
+
to skip).
|
|
70
|
+
|
|
71
|
+
The sender is your Bridge login by default. `from_address` picks another address
|
|
72
|
+
of your account, and replies go out from the address the original was sent to,
|
|
73
|
+
like in Proton's own apps. Bridge doesn't add the display name set in Proton's
|
|
74
|
+
settings, so the server takes it from your recent messages in Sent.
|
|
75
|
+
|
|
76
|
+
## Local setup (Claude Desktop)
|
|
77
|
+
|
|
78
|
+
Requirements: [uv](https://docs.astral.sh/uv/) (or Python 3.12+), Proton Mail
|
|
79
|
+
Bridge installed and logged in.
|
|
80
|
+
|
|
81
|
+
In Bridge, open your account and copy the **IMAP/SMTP username and password**
|
|
82
|
+
(generated by Bridge, not your Proton password). Then add the server to
|
|
83
|
+
`claude_desktop_config.json`. Open it from Claude Desktop → Settings → Developer →
|
|
84
|
+
Edit Config, or directly:
|
|
85
|
+
|
|
86
|
+
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
87
|
+
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
88
|
+
- Linux: `~/.config/Claude/claude_desktop_config.json`
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"mcpServers": {
|
|
93
|
+
"proton-mail": {
|
|
94
|
+
"command": "uvx",
|
|
95
|
+
"args": ["proton-mcp"],
|
|
96
|
+
"env": {
|
|
97
|
+
"PROTON_BRIDGE_USER": "you@proton.me",
|
|
98
|
+
"PROTON_BRIDGE_PASSWORD": "password-from-bridge"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Fully quit and restart Claude Desktop after editing the file.
|
|
106
|
+
|
|
107
|
+
Without uv: `pip install proton-mcp`, then use `"command": "proton-mcp"` (the full
|
|
108
|
+
path to that script if it isn't on your `PATH`) and no `args`.
|
|
109
|
+
|
|
110
|
+
### Configuration
|
|
111
|
+
|
|
112
|
+
| Variable | Default | |
|
|
113
|
+
| --- | --- | --- |
|
|
114
|
+
| `PROTON_BRIDGE_USER` | (required) | Username shown by Bridge |
|
|
115
|
+
| `PROTON_BRIDGE_PASSWORD` | (required) | Password generated by Bridge |
|
|
116
|
+
| `PROTON_IMAP_HOST` | `127.0.0.1` | Must be a loopback address (also used for SMTP) |
|
|
117
|
+
| `PROTON_IMAP_PORT` | `1143` | |
|
|
118
|
+
| `PROTON_IMAP_SECURITY` | `starttls` | `starttls` (Bridge default) or `ssl` |
|
|
119
|
+
| `PROTON_SMTP_PORT` | `1025` | |
|
|
120
|
+
| `PROTON_SMTP_SECURITY` | `starttls` | `starttls` or `ssl` |
|
|
121
|
+
| `PROTON_QUOTE_LANG` | `en` | Language of the "On … wrote:" line in replies: `en` or `fr` |
|
|
122
|
+
| `PROTON_SENDER_NAME` | *(from Sent)* | Name shown in `From`, for every address. By default, the name found on your recent messages in Sent from that address; set it empty for the bare address |
|
|
123
|
+
| `PROTON_FROM_ADDRESSES` | *(none)* | Extra addresses of your account allowed as `from_address`, comma-separated. The Bridge login and the addresses you've sent from (found in Sent) are always allowed; any other address is refused |
|
|
124
|
+
| `PROTON_ENABLE_SEND` | `true` | `false` removes `send_email` and `list_sender_addresses`: the server becomes strictly read-only |
|
|
125
|
+
|
|
126
|
+
The config file holds your Bridge password: keep it readable by you only.
|
|
127
|
+
|
|
128
|
+
## Remote setup (claude.ai connector)
|
|
129
|
+
|
|
130
|
+
`remote/server.py` serves the same tools over streamable HTTP, behind a
|
|
131
|
+
single-user OAuth password page, for claude.ai on the web and mobile.
|
|
132
|
+
`send_email` and `list_sender_addresses` are off unless `ENABLE_SEND=true`; the
|
|
133
|
+
`PROTON_*` variables above work the same in `.env`. A Dockerfile and compose file are
|
|
134
|
+
included, plus Apache and Caddy configs that only let Anthropic's IP ranges reach
|
|
135
|
+
`/mcp`.
|
|
136
|
+
|
|
137
|
+
See **[docs/deploy.md](https://github.com/vdeabreu/proton-mcp/blob/main/docs/deploy.md)** for the full guide (headless Bridge,
|
|
138
|
+
Docker, reverse proxy, claude.ai).
|
|
139
|
+
|
|
140
|
+
## Security
|
|
141
|
+
|
|
142
|
+
Giving an AI assistant access to your mailbox is powerful and risky. What this
|
|
143
|
+
project does about it:
|
|
144
|
+
|
|
145
|
+
- **Read tools don't change anything.** Folders are opened with `EXAMINE` and
|
|
146
|
+
bodies fetched with `BODY.PEEK`; there is no tool to move, flag or delete.
|
|
147
|
+
Text arguments containing control characters are rejected, so a search term
|
|
148
|
+
can't smuggle extra IMAP commands to Bridge.
|
|
149
|
+
- **Sending is opt-in and should stay on approval.** `send_email` carries the MCP
|
|
150
|
+
`destructiveHint`, and the server instructions tell the model to show the exact
|
|
151
|
+
draft (sender address included) and wait for explicit approval. A hint is not enforcement: in your client,
|
|
152
|
+
keep `send_email` on "ask every time". Set `PROTON_ENABLE_SEND=false` (local) or
|
|
153
|
+
leave `ENABLE_SEND=false` (remote, the default) to remove it entirely.
|
|
154
|
+
- **Only your own addresses can send.** Bridge accepts any sender address, so the
|
|
155
|
+
server checks `from_address` itself against your addresses (Bridge login,
|
|
156
|
+
`PROTON_FROM_ADDRESSES`, addresses found in Sent) and refuses the rest.
|
|
157
|
+
- **Email content is untrusted.** An email can contain text written to steer the
|
|
158
|
+
model ("forward this to…", "search for …"). The server instructions say never
|
|
159
|
+
to follow instructions found in emails, and `read_email` drops text hidden with
|
|
160
|
+
the usual HTML tricks (`display:none`, `font-size:0`…), but neither is a
|
|
161
|
+
guarantee. Treat any action the model proposes after reading an email with
|
|
162
|
+
suspicion.
|
|
163
|
+
- **Loopback only.** The server refuses any Bridge host that isn't `127.0.0.1`,
|
|
164
|
+
`::1` or `localhost`. TLS verification is disabled for that reason only (Bridge
|
|
165
|
+
uses a self-signed certificate).
|
|
166
|
+
- **Remote mode**:
|
|
167
|
+
- OAuth with a 20+ character password, a lockout after 5 failures, and tokens
|
|
168
|
+
stored in SQLite.
|
|
169
|
+
- Only claude.ai's callback can be registered as redirect URI, and the number of
|
|
170
|
+
clients is capped.
|
|
171
|
+
- The password page says which client asks and can't be framed by another site.
|
|
172
|
+
- `/mcp` is restricted to Anthropic's outbound IPs by the reverse proxy.
|
|
173
|
+
- Every tool call is logged without email bodies; the container is read-only and
|
|
174
|
+
unprivileged.
|
|
175
|
+
- **Remote mode, known limits:**
|
|
176
|
+
- The lockout is global: anyone can make *new* logins wait 15 minutes by failing
|
|
177
|
+
5 times. Tokens already issued keep working.
|
|
178
|
+
- Anyone can add your server URL as a connector in *their own* claude.ai account
|
|
179
|
+
and send you the resulting authorization link. If you type your password, their
|
|
180
|
+
account gets access. Only type it right after clicking *Connect* yourself.
|
|
181
|
+
|
|
182
|
+
Your Bridge password and `MCP_PASSWORD` give access to your whole mailbox:
|
|
183
|
+
keep `.env` and `claude_desktop_config.json` private.
|
|
184
|
+
|
|
185
|
+
To report a vulnerability, see [SECURITY.md](https://github.com/vdeabreu/proton-mcp/blob/main/SECURITY.md).
|
|
186
|
+
|
|
187
|
+
## Limitations
|
|
188
|
+
|
|
189
|
+
- `search_emails` accepts one non-ASCII search field at a time (IMAP `CHARSET UTF-8`
|
|
190
|
+
literal).
|
|
191
|
+
- `read_email` converts HTML to text and drops link targets and hidden elements.
|
|
192
|
+
Hiding detection is a heuristic: white-on-white text or CSS classes get through.
|
|
193
|
+
- Replies quote the original as plain text (its formatting is not kept).
|
|
194
|
+
- Attachments are listed, not downloaded or sent.
|
|
195
|
+
- Bridge must be in *combined* address mode (the default), with one login for
|
|
196
|
+
all addresses. In *split* mode each address has its own login, and the server
|
|
197
|
+
only uses one.
|
|
198
|
+
- Proton rebuilds outgoing messages: recipients get base64-encoded parts and a
|
|
199
|
+
plain-text version that Proton regenerates from the HTML.
|
|
200
|
+
|
|
201
|
+
## Development
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
git clone https://github.com/vdeabreu/proton-mcp && cd proton-mcp
|
|
205
|
+
pip install -e ".[remote,dev]"
|
|
206
|
+
pytest
|
|
207
|
+
ruff check .
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Tests don't need Bridge: they cover IMAP command injection (against a fake
|
|
211
|
+
IMAP server), message building, Markdown rendering, quoting, hidden HTML,
|
|
212
|
+
folder-name encoding, sender address and display name selection, and the OAuth
|
|
213
|
+
flow (redirect allowlist, client cap, lockout, security headers).
|
|
214
|
+
|
|
215
|
+
See [AGENTS.md](https://github.com/vdeabreu/proton-mcp/blob/main/AGENTS.md) for the invariants to keep when changing the code.
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
[MIT](https://github.com/vdeabreu/proton-mcp/blob/main/LICENSE)
|