mcp-hey
mcp-hey
一个本地模型上下文协议 (MCP) 服务器,通过逆向工程的 Web API 为 Claude 提供对 Hey.com 收件箱的读/写访问权限。
mcp-hey 由两个部分组成:一个通过 stdio 公开 Hey 工具的 Bun/TypeScript MCP 服务器,以及一个使用系统 Webview 在登录时捕获会话 Cookie 的小型 Python 辅助程序。所有内容均在本地运行——没有云中继,不存储凭据,仅在磁盘上存储会话 Cookie。
警告 — 非官方 API。 Hey.com 不发布公共 API;mcp-hey 对其 Web 端点进行了逆向工程,并将其与浏览器相同的 HTTP 请求配对。功能可能会在没有通知的情况下中断。当前记录的接口位于
docs/API.md。
功能
读取来自 Imbox、Feed、Paper Trail、Set Aside、Reply Later、Drafts、Trash 和 Spam 的电子邮件
下载附件并解析电子邮件中的日历邀请
发送和回复电子邮件线程
跨邮箱搜索电子邮件
整理邮件(搁置、稍后回复、筛选进/出、置顶)
本地 SQLite 缓存,可实现更快的重复读取和全文搜索
轻量级 — 空闲内存占用约 30 MB
浏览器相同的标头和 TLS 配置,以避免被检测
完全在您的机器上运行;使用 stdio 传输,无网络暴露
Related MCP server: Outlook MCP
设置
先决条件
Bun 1.1 或更高版本
Hey.com 账户
平台:在 macOS 和 Linux 上开发和测试。Windows 用户可能需要 WSL — pywebview 的 Windows 后端目前尚未经过测试。
安装
克隆此仓库
git clone https://github.com/Sealjay/mcp-hey.git cd mcp-hey安装依赖项
bun install uv pip install -r auth/requirements.txt首次运行 — 身份验证
bun run dev系统 Webview 将打开 Hey.com 的登录页面。正常登录。
辅助程序将会话 Cookie 捕获到
data/hey-cookies.json(权限600)并退出。按 Ctrl+C — 您的 MCP 客户端将从现在开始启动自己的服务器实例。
后续运行将重复使用存储的会话,直到其过期。
MCP 客户端配置
以下所有客户端都使用相同的 command/args 格式。在 macOS 上,您几乎肯定需要 bun 的绝对路径 — 请参阅下方的 macOS: bun PATH。
Claude Code
最快的方法是使用 CLI:
claude mcp add --transport stdio hey --scope user -- bun run /absolute/path/to/mcp-hey/src/index.ts服务器在当前会话中立即可用。
或者,将其添加到项目根目录的 .mcp.json(或用户范围服务器的 ~/.claude.json)中:
{
"mcpServers": {
"hey": {
"type": "stdio",
"command": "bun",
"args": ["run", "/absolute/path/to/mcp-hey/src/index.ts"]
}
}
}如果您直接编辑该文件,请重启 Claude Code 会话以使其生效。
Claude Desktop
添加到 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"hey": {
"command": "bun",
"args": ["run", "/absolute/path/to/mcp-hey/src/index.ts"]
}
}
}重启 Claude Desktop。您应该会看到 hey 列为可用的集成。
Cursor
添加到 ~/.cursor/mcp.json:
{
"mcpServers": {
"hey": {
"command": "bun",
"args": ["run", "/absolute/path/to/mcp-hey/src/index.ts"]
}
}
}重启 Cursor。
Docker
包含一个用于容器化部署和 Glama 兼容性的 Dockerfile。
构建镜像:
docker build -t mcp-hey .冒烟测试服务器(应返回列出可用工具的 JSON-RPC 响应):
printf '{"jsonrpc":"2.0","id":1,"method":"tools/list"}\n' | docker run -i mcp-hey注意: Docker 镜像仅运行 MCP 服务器。Python 身份验证辅助程序和 Webview 登录在容器内不可用。您必须通过卷挂载将预先存在的会话 Cookie 提供给
data/hey-cookies.json以进行身份验证操作。
macOS: bun PATH
GUI 应用程序(Claude Desktop、Cursor)和由 Claude Code 启动的 Shell 并不总是从您的交互式终端继承 PATH,因此通过 Homebrew 安装的 bun 可能会因 spawn bun ENOENT 而失败,或者根本无法连接。通过在 command 中使用 bun 的绝对路径来修复:
Apple Silicon Homebrew —
/opt/homebrew/bin/bunIntel Homebrew —
/usr/local/bin/bun手动安装 — 在终端中运行
which bun以找到它
示例:
{
"mcpServers": {
"hey": {
"command": "/opt/homebrew/bin/bun",
"args": ["run", "/absolute/path/to/mcp-hey/src/index.ts"]
}
}
}架构
组件 | 描述 |
MCP 服务器 | Bun/TypeScript,stdio 传输,空闲内存约 30 MB |
身份验证辅助程序 | Python/pywebview,按需启动以通过系统 Webview 进行登录 |
缓存 | 用于消息、线程和搜索索引的本地 SQLite 存储 |
通信 | 通过 |
数据流
MCP 客户端(Claude Code、Claude Desktop、Cursor 等)通过 stdio 启动
bun run src/index.ts。启动时,服务器会验证
data/hey-cookies.json。如果缺失或过期,它会启动auth/hey-auth.py,该程序会在系统 Webview 中打开 Hey 并写入新的 Cookie。工具调用直接使用浏览器真实的标头访问 Hey.com;响应被解析(HTML 通过
node-html-parser)并缓存在 SQLite 中。写操作在提交前会获取新的 CSRF 令牌。
项目结构
mcp-hey/
src/
index.ts # MCP server entry point
hey-client.ts # HTTP client with cookie injection
session.ts # Session management and validation
errors.ts # Error classes and sanitisation
cache/ # SQLite cache (db, schema, messages, search)
tools/ # MCP tool implementations
read.ts # Reading and listing
send.ts # Send, reply, forward
organise.ts # Triage, labels, bubble up, etc.
http-helpers.ts # Shared CSRF retry and endpoint fallback
attachments.ts # Download attachments, parse calendar invites
__tests__/ # Test suites
auth/
hey-auth.py # Python auth helper (pywebview)
requirements.txt
data/
hey-cookies.json # Session storage (gitignored, chmod 600)
docs/
API.md # Hey.com API surface documentation
TOOLS.md # MCP tool reference (33 tools)
hey-features-doc.md # Hey.com feature mapping可用工具
按功能分组的 33 个工具。有关参数、返回形状和错误行为,请参阅 docs/TOOLS.md。
类别 | 工具 |
读取 |
|
标签与集合 |
|
发送 |
|
分类 |
|
置顶 |
|
筛选器 |
|
搜索 |
|
缓存 |
|
隐私与安全
绝不存储凭据 — 仅存储会话 Cookie,并以
600权限写入。身份验证完全在 Hey 自己的登录页面(系统 Webview)内进行。
所有数据都保留在您的机器上。本项目不发出任何遥测数据。
MCP 使用 stdio 传输 — 服务器从不打开网络监听器。
会话有效性在启动时和敏感操作前进行检查。
请参阅 SECURITY.md 了解如何报告漏洞。
限制
提示注入风险:与许多 MCP 服务器一样,此服务器也受到 致命三要素 的影响。到达您收件箱的恶意电子邮件可能会尝试指示 Claude 窃取其他消息。请相应地对待工具界面,并在批准风险操作之前进行审查。
非官方 API:Hey.com 的前端可能会在没有通知的情况下更改并导致功能中断。请预料到偶尔会发生中断,并查看
docs/API.md以了解已知的差异。无实时通知:仅轮询。
尚不支持附件上传。
每个 MCP 服务器实例仅限一个账户。
账户风险:激进或异常的访问模式理论上可能会触发 Hey 的反滥用系统。服务器会尊重
x-ratelimit标头并进行指数退避,但无法保证。仅限英语 UI:服务器解析 Hey.com 的 HTML 响应并匹配英语字符串(例如“You ignored this thread”、标签名称、按钮文本)。如果 Hey.com 设置为非英语语言环境,它将无法正常工作。
故障排除
身份验证 Webview 未打开 — 确认 Python 3.10+ 在
PATH中,并且uv pip install -r auth/requirements.txt已成功执行。在 Linux 上,确保 Webview 后端可用(python -c "import webview"不应报错)。使用数周后出现
401/403响应 — 您的 Hey 会话已过期。删除data/hey-cookies.json并再次运行bun run dev以重新进行身份验证。速率限制 (
429) — 客户端尊重x-ratelimit标头并进行退避。如果您看到持续的 429 错误,请减少并发工具的使用或等待几分钟。MCP 客户端无法启动服务器 —
args必须是绝对路径,而不是相对路径。如果bun本身因spawn bun ENOENT而失败,请参阅 macOS:bunPATH。Cookie 名称已更改 — Hey 之前曾重命名过会话 Cookie(例如
_hey_session→session_token,请参阅docs/API.md更新日志)。如果 Hey 更新后身份验证静默失败,请捕获新的 Cookie 并进行比较。
贡献
欢迎通过 Pull Request 贡献。请:
使用约定式提交 (
feat,fix,docs,refactor,test,perf,cicd,revert,WIP)。在推送前运行
bun run format和bun run lint(由 Biome 提供支持)。确保
bun test通过。如果您发现或更改了任何 Hey.com API 行为,请更新
docs/API.md。
请参阅 CLAUDE.md 了解完整的开发工作流程。
许可证
MIT 许可证 — 请参阅 LICENCE。
Available Tools
37 toolshey_bubble_upAIdempotent
Schedule an email thread to bubble up (reappear) at a specific time. Returns {success, error?}. Reversible via hey_pop_bubble. Requires the thread's topic_id (use topic_id from any list operation); posting IDs are not accepted and will 404.
Inputs: slot (required), topic_id (required), date.
hey_bubble_up_if_no_replyAIdempotent
Schedule an email thread to bubble up ONLY if there's no reply by a deadline date. Returns {success, error?}. The thread only reappears if no reply arrives. Reversible via hey_pop_bubble. Requires the thread's topic_id (use topic_id from any list operation); posting IDs are not accepted.
Inputs: date (required), topic_id (required).
hey_cache_statusARead-only
Get local cache statistics: message counts, cache age, and storage estimate. Read-only with no side effects. Pass folder to scope message/unread counts to one cached view. Use before deciding whether to pass force_refresh on other list tools.
Inputs: folder.
hey_collectionAIdempotent
Add or remove an email thread from a collection. Returns {success, error?}. Reversible by calling again with the opposite action. Use hey_list_collections to discover collection IDs.
Inputs: action (required), topic_id (required), collection_id (required).
hey_delete_draftADestructiveIdempotent
Permanently delete a draft by ID. This does not move it to Trash — it is gone immediately, same as the trash icon in Hey's Drafts list. Returns {success, draftId, error?}. Irreversible; there is no hey_restore_draft. Use hey_list_emails(folder='drafts') first if you don't already have the draftId from hey_save_draft or hey_edit_draft.
Inputs: draft_id (required).
hey_download_attachmentA
Download a single attachment from an email and save it to disk. First call hey_read_email to get the attachments[] array with IDs, filenames, and sizes, then call this tool with the attachment_id to save the file. Returns {local_path, filename, size, mime}.
Inputs: email_id (required), attachment_id (required), save_path.
hey_edit_draftAIdempotent
Update an existing draft's recipients, subject, or body. Every field you pass replaces the draft's current value outright (no merging) — omit a field to leave it as Hey last saved it. Returns {success, draftId, error?}. Previous field values are not recoverable once overwritten, so re-fetch via hey_list_emails(folder='drafts') first if you need to preserve them. Use hey_save_draft to create a draft before calling this, and hey_delete_draft to remove one instead of blanking it out.
Inputs: draft_id (required), cc, to, body, +1 more.
hey_forwardA
Forward an existing email to new recipients immediately. The original thread remains unchanged. Returns {success, error?}. Use instead of hey_send_email when sharing existing content; use hey_reply for responding within a thread.
Inputs: to (required), entry_id (required), cc, bcc, +1 more.
hey_get_calendar_inviteARead-only
Extract and parse a calendar invite (.ics) from an email. First call hey_read_email — if calendar_invites[] is present, call this tool to get full details: title, start, end, location, attendees, organizer, description, and raw_ics. To save the .ics file to disk, use hey_download_attachment instead.
Inputs: email_id (required), attachment_id.
hey_imbox_summaryARead-only
Get a complete Imbox summary including screener count, bubbled up emails, and new emails. Use this for a comprehensive view of the inbox state.
Inputs: force_refresh.
hey_labelAIdempotent
Add or remove a label on an email thread. Returns {success, error?}. Reversible by calling again with the opposite action. Use hey_list_labels to discover available label IDs.
Inputs: action (required), label_id (required), topic_id (required).
hey_list_collection_emailsARead-only
List emails in a specific collection. Returns cached results unless force_refresh=true.
Inputs: collection_id (required), page, limit, force_refresh.
hey_list_collectionsARead-only
List all collections in Hey.com. Returns array of {id, name}. Use the id with hey_collection or hey_list_collection_emails.
Inputs: no named parameters.
hey_list_emailsARead-only
List emails in a Hey.com folder/view. Returns cached results unless force_refresh=true. Each email includes id, topicId, postingId, entryId, from, subject, date, and unread status. For folder=sent, from is always "Me" and the recipient (unverified against a live Sent page) is under to/toEmail instead.
Inputs: folder (required), page, limit, force_refresh.
hey_list_label_emailsARead-only
List emails with a specific label. Returns cached results unless force_refresh=true.
Inputs: label_id (required), page, limit, force_refresh.
hey_list_labelsARead-only
List all labels/folders in Hey.com. Returns array of {id, name}. Use the id with hey_label or hey_list_label_emails.
Inputs: no named parameters.
hey_list_reply_laterARead-only
List emails currently in the Reply Later stack. Returns cached results (same shape as hey_list_emails) unless force_refresh=true. Use hey_remove_reply_later with the returned postingId to remove an item.
Inputs: force_refresh.
hey_list_screenerARead-only
List senders waiting in the Screener for approval. Returns cached results (same shape as hey_list_emails, plus clearanceId) unless force_refresh=true. Use hey_screen_by_id with the returned clearanceId to approve or reject.
Inputs: force_refresh.
hey_list_set_asideARead-only
List emails currently in the Set Aside stack. Returns cached results (same shape as hey_list_emails) unless force_refresh=true. Use hey_unset_aside with the returned postingId to remove an item.
Inputs: force_refresh.
hey_mark_seenAIdempotent
Clear the orange 'New for you' tray dot — mirrors Hey's 'Mark all as seen' UI affordance. Returns {success, error?}. Pass a posting_id to clear just that one item (POST /postings/seen); omit posting_id to clear the entire Imbox tray in one call (POST /boxes/{imboxId}/observation). Reversible per-item via hey_mark_unseen. Use after triaging or skimming a batch to keep the tray tidy without re-marking threads unread.
Inputs: posting_id.
hey_mark_unseenAIdempotent
Mark a thread as unseen/unread to reset its read status. Returns {success, error?}. Reading the email via hey_read_email implicitly marks it as seen again. To clear the orange 'New for you' tray dot without re-marking unseen, use hey_mark_seen.
Inputs: id (required).
hey_move_toAIdempotent
Move an email thread between Hey.com views: imbox, feed, or paper_trail. Returns {success, error?}. Use paper_trail for receipts/automated mail, feed for newsletters, imbox to restore. Reversible by moving to a different destination. Does not affect trash, spam, or screener — use hey_set_status or hey_screen for those.
Inputs: id (required), destination (required).
hey_pop_bubbleAIdempotent
Pop (dismiss) a bubbled-up email thread so it sinks back into the Imbox. The thread is not deleted — it just stops being pinned at the top. Returns {success, error?}. Requires the thread's topic_id (use topic_id from any list operation); posting IDs are not accepted.
Inputs: topic_id (required).
hey_read_emailARead-only
Read an email thread's full content. Returns all messages in the thread via entries[] array (each with entryId, from, to, cc, date, body). Also returns attachments[] metadata and calendar_invites[] when present — use hey_download_attachment to save files to disk, or hey_get_calendar_invite to parse .ics details. Use format='html' (default) for rich content with thread entries, or format='text' for decoded RFC822 plain text of the first message.
Inputs: id (required), format, force_refresh.
hey_read_statusAIdempotent
Set the read/unread status of an email entry. Returns {success, error?}. Reversible by calling again with the opposite status. Operates on individual entries (use entryId), not whole threads. For marking an entire thread as unseen, use hey_mark_unseen instead.
Inputs: id (required), status (required).
hey_remove_reply_laterAIdempotent
Remove an email from Reply Later, marking it "Done" and moving it back to the Imbox. Returns {success, error?}. Requires the posting_id from hey_list_reply_later. Reversible by calling hey_reply_later again with the thread's topic_id.
Inputs: posting_id (required).
hey_replyA
Reply to an email thread, preserving threading on both ends. Returns {success, error?}. By default the reply goes to the other thread participants (your own address is automatically excluded); pass to to redirect to specific recipients — e.g. chasing your own thread without looping back to yourself, or redirecting off a mailing-list address. Prefer this over hey_send_email when responding to an existing thread; use hey_send_email only for new conversations.
Inputs: body (required), thread_id (required), cc, to.
hey_reply_laterAIdempotent
Move an email thread to Reply Later. Reversible via hey_remove_reply_later (requires postingId from hey_list_reply_later). Returns {success, error?}. Use for emails you intend to respond to but not right now — if no reply is planned, use hey_set_aside instead.
Inputs: id (required).
hey_save_draftA
Save a new draft email without sending it. Creates an entry in Hey's Drafts folder; recipients, subject, and body are all optional so a partially-written draft can be saved. Returns {success, draftId?, error?}. Sending isn't available via MCP yet — finish and send the draft from the Hey web/app UI, or use hey_edit_draft to keep revising it. Use hey_send_email/hey_reply instead when you want to send immediately rather than draft first.
Inputs: cc, to, body, subject.
hey_screenADestructiveIdempotent
Approve or reject a sender by email address. Approve: routes the sender's current and future emails into the chosen destination (defaults to imbox). Reject (a.k.a. screen out): blocks the sender from sending you further emails — works for both pending screener entries AND already-approved senders (falls back to the contact-page 'Screened Out' affordance via /contacts/{id}/clearance). Reject does NOT flag emails as spam; existing emails are left untouched. Reversible from the Hey UI by visiting the contact page; not yet exposed via MCP. Returns {success, error?}. Use hey_list_screener to see pending senders, or hey_screen_by_id for clearance IDs.
Inputs: action (required), sender_email (required), destination.
hey_screen_by_idADestructiveIdempotent
Approve or reject a first-time sender from the Screener by clearance ID. Approve: allows future emails from this sender into the chosen destination (defaults to imbox). Reject: blocks future emails from this sender via the screener. Reversible from the Hey UI's contact page (not yet via MCP). Returns {success, error?}. Use hey_list_screener to get clearance IDs; for senders that have already left the screener, use hey_screen by email instead.
Inputs: action (required), clearance_id (required), destination.
hey_searchARead-only
Search emails by query. Uses local FTS cache first, then network. Use force_refresh for real-time results.
Inputs: query (required), limit, force_refresh.
hey_send_emailA
Send a new email immediately (no draft stage). Returns {success, error?}. Use for standalone outbound messages; use hey_reply for thread responses, or hey_forward to share existing emails with new recipients.
Inputs: to (required), body (required), subject (required), cc.
hey_set_asideAIdempotent
Move an email thread to Set Aside for later. Reversible via hey_unset_aside (requires postingId from hey_list_set_aside). Returns {success, error?}. Use for emails you plan to revisit but don't need to reply to — for emails needing a reply, use hey_reply_later instead. Does not affect future emails from the sender.
Inputs: id (required).
hey_set_statusADestructiveIdempotent
Change an email thread's status. Returns {success, error?}. Trash and spam are reversible via restore and unspam actions respectively. DESTRUCTIVE: trash removes from Imbox, spam blocks the sender. Paper Trail bundles (postingId-only items with no thread) support action=trash only; spam/restore/unspam on a bundle return an explicit error pointing to the bundle's individual entries.
Inputs: id (required), action (required).
hey_thread_muteAIdempotent
Mute or unmute a thread (called 'Ignore' in Hey.com's UI). Muting stops notifications for the thread but keeps it in its current view — the thread is not moved or deleted. Returns {success, error?}. Reversible by calling with the opposite action. To check if a thread is currently muted, use hey_read_email — the response includes a 'muted' field.
Inputs: action (required), posting_id (required).
hey_unset_asideAIdempotent
Remove an email from Set Aside, moving it back to the Imbox or its original location. Returns {success, error?}. Requires the posting_id from hey_list_set_aside. Reversible by calling hey_set_aside again with the thread's topic_id.
Inputs: posting_id (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 37 tools
Most tools target clearly distinct actions, and descriptions explicitly guide choice between similar pairs (hey_screen vs hey_screen_by_id, hey_set_aside vs hey_reply_later, hey_bubble_up vs hey_bubble_up_if_no_reply). The main soft spot is the read-state trio (hey_mark_seen, hey_mark_unseen, hey_read_status), which is subtly differentiated (tray dot vs thread vs entry) and could trip up an agent, but the descriptions do address it.
Every tool uses a consistent hey_ snake_case prefix, which makes the set scan cleanly. Minor deviation: some names are verb_noun (hey_list_emails, hey_send_email) while others are state-noun or ad hoc (hey_imbox_summary, hey_cache_status, hey_thread_mute), but the convention is stable and readable throughout.
At 37 tools this is on the heavy side and pushes past the comfortable 3-15 band. The email-client domain justifies breadth, but several clusters could be consolidated (three read-state tools, three bubble-up tools, separate list/view tools) rather than expanded separately.
Coverage is broad: listing across views, search, read, reply/forward/send, drafts, labels, collections, screener, set-aside/reply-later, bubbling, muting, moving, and status changes. Explicit gaps are acknowledged (drafts can't be sent via MCP, screener reversals are UI-only), which are minor relative to the surface.
Maintenance
Related MCP Connectors
Your IMAP mailbox as an MCP server: read, search and (if you allow it) organize mail. Open source.
MCP server for Nylas — read email, calendars, events and contacts, and send email or create events.
MCP server for MailTempo's public free temporary email inboxes.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Related MCP Servers
- MIT
- AlicenseNot gradedqualityDmaintenanceEnables semantic search and AI-powered analysis of Outlook emails using RAG-based natural language queries and Vision AI for architectural documents, with specialized support for AEC workflows.MIT
- AlicenseAqualityDmaintenanceLocal MCP server for multi-account IMAP/SMTP email (iCloud + Gmail via app-specific passwords). Never marks mail read. Cross-folder search, idempotent sends, TLS verified.822 PyPIMIT
- AlicenseAqualityCmaintenanceAn MCP server that exposes a local notmuch email database to an LLM client such as Claude. It is read-first: searching, reading, and understanding mail is always available; writing anything (drafts, tags, exported files) requires an explicit opt-in flag and is confined to clearly bounded locations.133MIT