ProtonMail MCP服务器
ProtonMail Bridge的非官方IMAP支持的MCP(模型上下文协议)服务器。将邮箱操作公开为MCP工具,以便AI助手可以通过本地网桥连接列出、搜索和检索邮件。
新闻
v2026.2.2-重大变更
search_emails 命名至 get_inbox_items -老人 search_emails 该工具(列出了带有可选日期过滤的电子邮件)已重命名为 get_inbox_items 以更好地反映其目的。
新 search_emails 使用关键字搜索 -一个新的 search_emails 该工具现在提供实际的基于关键字的搜索和字段选择:
{
"mailbox": "INBOX",
"query": "meeting notes",
"fields": ["subject", "from"],
"since_date": "2025-01-01T00:00:00Z",
"limit": 30
}| 参数 | 必填 | 说明 |
|---|---|---|
query | 是 | 搜索关键字 |
fields | 无 | 要搜索的字段: text (任何地方), subject, from, to, body.默认为 text. |
since_date | 否 | ISO 8601日期过滤器 |
mailbox | 否 | 默认为 INBOX |
limit | 否 | 默认为30 |
快速入门
安装
预构建二进制文件(推荐):
Linux:
curl -LO https://github.com/TensorTemplar/protonmail-mcp-server/releases/latest/download/protonmail-mcp-server-x86_64-unknown-linux-gnu.tar.gz
tar xzf protonmail-mcp-server-x86_64-unknown-linux-gnu.tar.gz
chmod +x protonmail-mcp-server
sudo mv protonmail-mcp-server /usr/local/bin/macOS(苹果硅):
curl -LO https://github.com/TensorTemplar/protonmail-mcp-server/releases/latest/download/protonmail-mcp-server-aarch64-apple-darwin.tar.gz
tar xzf protonmail-mcp-server-aarch64-apple-darwin.tar.gz
chmod +x protonmail-mcp-server
sudo mv protonmail-mcp-server /usr/local/bin/macOS(英特尔):
curl -LO https://github.com/TensorTemplar/protonmail-mcp-server/releases/latest/download/protonmail-mcp-server-x86_64-apple-darwin.tar.gz
tar xzf protonmail-mcp-server-x86_64-apple-darwin.tar.gz
chmod +x protonmail-mcp-server
sudo mv protonmail-mcp-server /usr/local/bin/Windows(PowerShell):
Invoke-WebRequest -Uri "https://github.com/TensorTemplar/protonmail-mcp-server/releases/latest/download/protonmail-mcp-server.exe-x86_64-pc-windows-msvc.zip" -OutFile "protonmail-mcp-server.zip"
Expand-Archive protonmail-mcp-server.zip -DestinationPath .通过货物:
# From crates.io
cargo install protonmail-mcp-server --features http
# Or from source
git clone https://github.com/TensorTemplar/protonmail-mcp-server
cd protonmail-mcp-server
cargo install --path . --features http验证下载(可选)
所有发布的二进制文件都包含用签名的SHA256校验和 Sigstore.
校验和验证:
# Download the checksums file
curl -LO https://github.com/TensorTemplar/protonmail-mcp-server/releases/latest/download/SHA256SUMS.txt
# Verify your downloaded binary (run in same directory as the .tar.gz/.zip)
sha256sum -c SHA256SUMS.txt --ignore-missing
# Expected output: protonmail-mcp-server-x86_64-unknown-linux-gnu.tar.gz: OK签名验证(需要 联署):
# Download the signature bundle
curl -LO https://github.com/TensorTemplar/protonmail-mcp-server/releases/latest/download/SHA256SUMS.txt.bundle
# Verify the checksums file was signed by this repo's GitHub Actions
cosign verify-blob \
--certificate-identity-regexp "github.com/TensorTemplar/protonmail-mcp-server" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--bundle SHA256SUMS.txt.bundle \
SHA256SUMS.txt
# Expected output: Verified OK配置并运行
# Set environment variables
export IMAP_HOST=127.0.0.1
export IMAP_PORT=1143
export IMAP_USERNAME=your@email.com
export IMAP_PASSWORD=your-bridge-password
export MCP_TRANSPORT=http
export MCP_AUTH_TOKEN=your-secret-token
# Run
protonmail-mcp-server或者复制并编辑示例env文件:
cp .env.example .env
# Edit .env with your settings
protonmail-mcp-serverHTTP传输部署
建筑
┌─────────────┐ HTTPS/SSE ┌──────────────────┐ IMAP
│ Agent 1 │◄──────────────────►│ │◄──────────►┌────────────────┐
├─────────────┤ │ MCP Server │ │ ProtonMail │
│ Agent 2 │◄──────────────────►│ (HTTP+SSE) │◄──────────►│ Bridge │
├─────────────┤ │ │ │ │
│ Agent N │◄──────────────────►│ Per-session IMAP │◄──────────►│ localhost:1143 │
└─────────────┘ └──────────────────┘ └────────────────┘- 每个MCP会话都有自己的IMAP连接
- 需要承载令牌身份验证
- SSE(服务器发送事件)用于流式响应
配置
| 变量 | 默认值 | 描述 |
|---|---|---|
MCP_TRANSPORT | stdio | 运输方式: stdio 或 http |
MCP_HTTP_BIND | 127.0.0.1:8080 | HTTP服务器绑定地址 |
MCP_AUTH_TOKEN | (http需要) | 身份验证的承载令牌 |
MCP_SSE_KEEPALIVE | true | 启用SSE保持活动ping(见下面的注释) |
注: 如果使用Python MCP SDK\ 旧的SDK无法处理作为保活ping发送的空SSE数据字段。 请参阅: python sdk#1672
正在运行HTTP服务器
# Via environment
MCP_TRANSPORT=http MCP_AUTH_TOKEN=secret123 ./target/release/protonmail-mcp-server
# Via CLI override
./target/release/protonmail-mcp-server --transport http --bind 0.0.0.0:8080客户端使用情况
# Initialize session
curl -X POST http://localhost:8080/mcp \
-H "Authorization: Bearer secret123" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"my-agent","version":"1.0"}}}'安全注意事项
- 网络绑定:默认值
127.0.0.1(仅限本地主机)。使用0.0.0.0用于远程访问。 - 认证:
MCP_AUTH_TOKEN对于HTTP模式是必需的。 - 传输层安全:对于生产环境,使用HTTPS在反向代理(nginx、Caddy)后面部署。
可用的MCP工具
| 工具 | 说明 | 注释 |
|---|---|---|
list_mailboxes | 列出可用邮箱 | 只读 |
get_inbox_items | 从具有可选日期筛选功能的邮箱获取电子邮件 | 只读 |
search_emails | 在指定字段中按关键字搜索电子邮件 | 只读 |
get_email | 按ID获取完整的电子邮件内容 | 只读 |
get_current_date | 获取当前UTC时间戳 | 只读 |
list_tags | 列出邮箱的可用标志 | 只读 |
get_email_tags | 获取特定电子邮件上的标志 | 只读 |
apply_tag | 将标记应用于电子邮件 | 幂等 |
remove_tag | 从电子邮件中删除标志 | 破坏性 |
move_email | 将电子邮件移动到另一个文件夹 | 破坏性 |
move_emails | 将多封电子邮件移动到另一个文件夹 | 破坏性 |
get_attachment | 下载附件(文件或base64) | 破坏性,开放世界 |
赞助商
如果您觉得这个项目有用,请考虑支持我们:
 
请在SPONSORS.md中列出的付款单中注明您的姓名和项目。
