multimodal-imessage-mcp
多模态 iMessage MCP
最完整的 iMessage MCP 服务器,专为 Claude 设计。在 Claude Desktop 或 Claude Code 中,即可读取完整对话、搜索消息、查看图片附件、发送消息、查找联系人以及对消息做出反应。
为何存在
其他 iMessage MCP 工具都查询 Apple 的 chat.db 中的 text 列。问题在于:在最新的 macOS(14+)上,93% 的消息存储在 attributedBody 中,而非 text。 那些工具会静默地返回空或不完整的对话。
本服务器逆向工程了 Apple 的 NSAttributedString 二进制格式,以提取实际的消息内容,让您能够访问完整的消息历史。
Related MCP server: jons-mcp-imessage
功能
工具 | 描述 |
| 读取所有对话中的最新消息 |
| 在所有消息、联系人和群组名称中进行全文搜索 |
| 获取与任何联系人(按姓名或号码)的完整对话线程 |
| 以 JSON 格式获取聊天 ID、句柄、最后发送者、预览和群组状态 |
| 通过聊天 ID 获取可靠的结构化线程 |
| 为外发的 1:1 iMessage/RCS 消息添加尽力而为的已读回执元数据 |
| 查找需要跟进审查的 SMS 外联线程 |
| 查看消息中的图片和文件 —— Claude 可以查看和分析照片 |
| 发送 iMessage 或 SMS/RCS,带有确认安全机制和可选验证回退 |
| 检查线程并在发送前推荐 iMessage、SMS/RCS 或自动模式 |
| 预览并发送经过审查的批次,需提供批准令牌 |
| 列出红色气泡发送失败、待发送和 SMS/RCS 恢复情况 |
| 以备份优先的数据库清理方式删除精确的本地消息行 |
| 预览并删除完整的本地线程,需提供一个精确批次的批准令牌 |
| 实验性地通过 Messages UI 自动化编辑最近发出的 iMessage |
| 实验性地通过 Messages UI 自动化撤销发送最近发出的 iMessage |
| 查看您最活跃的对话 |
| 从您的通讯录中查找电话号码和电子邮件 |
| 向消息添加轻点回应 |
多模态:Claude 可以查看您的照片
当您使用 get_attachment 时,图像会以 base64 内容块的形式返回,Claude 可以实际查看它们。HEIC 照片(iPhone 默认格式)会自动转换为 JPEG。这意味着 Claude 可以:
描述别人发给您的照片内容
读取图像中的文字/截图
分析对话中的视觉内容
要求
macOS(此工具读取本地 iMessage 数据库)
Node.js >= 18 且 < 26。推荐使用 Node 24 LTS,因为锁定的原生 SQLite 依赖与 Node 26 不兼容。
完全磁盘访问权限已授予您的终端应用(系统设置 > 隐私与安全性 > 完全磁盘访问权限)。这涵盖了 iMessage 数据库和用于联系人姓名解析的 AddressBook 数据库——无需运行通讯录应用。
安装
git clone https://github.com/tszaks/imessage-mcp.git
cd imessage-mcp
npm install配置
Claude Desktop
添加到您的 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"imessage": {
"command": "/opt/homebrew/bin/node",
"args": ["/path/to/imessage-mcp/index.js"]
}
}
}重要: 请使用 Node.js 二进制文件的完整路径(例如
/opt/homebrew/bin/node),而不仅仅是node。macOS 桌面应用不会继承您 shell 的 PATH,使用裸node命令通常会解析到较旧的系统 Node,导致原生模块崩溃。
Claude Code
添加到您的 .mcp.json:
{
"mcpServers": {
"imessage": {
"command": "node",
"args": ["/path/to/imessage-mcp/index.js"]
}
}
}在 Claude Code 中,
node通常能正确解析,因为它继承了您的 shell 环境。
使用示例
“显示我最近的消息” —— 读取您最新的对话
“妈妈今天给我发了什么短信?” —— 通过您的 AddressBook 将“妈妈”解析为电话号码,拉取对话
“搜索我的消息中的‘航班确认’” —— 在所有消息中进行全文搜索
“查找过去 7 天内回复过且需要跟进的外联对象” —— 返回带有风险标签的结构化外联候选
“预览这 10 条跟进短信的批次” —— 在发送前返回精确的收件人、消息、警告和批准令牌
“显示最近的发送失败” —— 报告 Messages 标记为失败或待发送的外发消息,包括后续 SMS/RCS 发送是否恢复了线程
“显示消息 538516 中的照片” —— 返回实际图像供 Claude 查看和描述
“向 +1234567890 发送‘晚到 10 分钟’” —— 发送 iMessage(需要确认)
发布标志
发布标志通过 MCP 服务器环境选择加入:
{
"mcpServers": {
"imessage": {
"command": "node",
"args": ["/path/to/imessage-mcp/index.js"],
"env": {
"IMESSAGE_MCP_RELEASES": "auto_sms_fallback,cleanup_failed_imessage_after_sms_fallback,message_mutation_tools,experimental_message_ui_actions,read_receipts"
}
}
}
}标志 | 行为 |
|
|
| 在 |
| 暴露 |
| 暴露 |
| 向结构化对话结果添加已读回执字段,并向 |
修改工具
delete_messages 接受精确的消息 ROWID:
{ "message_ids": ["538516", "538517"] }它不需要确认。它会报告已删除的 ID、缺失的 ID、备份位置以及在验证过程中发现的任何剩余行。
delete_threads 是一个两步精确批次流程:
{ "chat_ids": [101, 102] }预览会为该有序列表和预览中显示的线程元数据返回一个 approval_token。要删除,请发送相同的排序 chat_ids、confirm: true 和该令牌:
{ "chat_ids": [101, 102], "confirm": true, "approval_token": "..." }更改顺序、列表或令牌会导致请求失败。
edit_message 和 undo_send_message 是实验性的,因为 Messages 没有为这些操作暴露一流的 AppleScript 命令。它们会打开对话,通过文本片段找到可见的外发气泡,使用上下文菜单,然后验证结果。它们旨在影响实际的 Messages 行为,而不是伪造仅限本地的数据库编辑。
可选调优:
IMESSAGE_MCP_SEND_VERIFY_DELAY_MS=2500这控制 MCP 在检查本地 Messages 数据库以获取新外发行之前等待的时间。
工作原理
attributedBody 修复
Apple 的 iMessage 数据库(~/Library/Messages/chat.db)有两个用于消息内容的列:
text—— 传统的纯文本列(由较旧的 macOS 版本使用)attributedBody—— 序列化的NSAttributedString二进制大对象(由 macOS 14+ 使用)
在最新的 macOS 上,Apple 逐渐将消息存储迁移到 attributedBody,以支持富文本、提及和格式。text 列越来越只是一个通常为 NULL 的旧版回退。
本服务器检测到 text 为 NULL 的消息,并通过解析二进制 NSTypedStream 格式从 attributedBody 中提取内容:
在二进制大对象中找到
NSString标记读取类型头部字节(
01 94 84 01 2b)之后的内容解码长度前缀(短消息为单字节,较长消息为多字节)
提取 UTF-8 文本负载
附件处理
iMessage 附件存储在 ~/Library/Messages/Attachments/ 中,路径在 attachment 表中跟踪。get_attachment 工具:
查询给定消息 ID 的附件元数据
将
~/Library/Messages/...路径解析为绝对路径对于 JPEG/PNG/GIF/WebP:读取文件并返回 base64 图像内容
对于 HEIC(iPhone 默认格式):在返回前使用 macOS
sips转换为 JPEG对于其他文件:返回元数据和文件路径
故障排除
“无法打开 iMessage 数据库” 向您的终端应用授予完全磁盘访问权限:系统设置 > 隐私与安全性 > 完全磁盘访问权限。
联系人查找无结果 联系人解析直接读取 macOS AddressBook SQLite 数据库(无需通讯录应用)。确保已授予完全磁盘访问权限。如果刚刚添加了联系人,请重启 MCP 服务器以刷新缓存。
原生模块崩溃 / “NODE_MODULE_VERSION 不匹配”
重建原生依赖:npm rebuild。当您的 Node.js 版本更改时会发生这种情况。同时确保您的 Claude Desktop 配置使用 node 的完整路径(请参阅上面的配置)。
对话中缺少消息
这正是本服务器修复的错误。请确保您运行的是包含 attributedBody 提取功能的最新版本。
许可证
MIT
快速入门 TL;DR
npm install
node index.js然后将服务器添加到您的MCP客户端配置中,并授予终端应用完整磁盘访问权限。
工作原理(TL;DR)
读取macOS iMessage SQLite数据库
解码现代
attributedBody载荷以获取完整消息文本通过MCP暴露对话/搜索/附件工具
使用AppleScript进行消息发送/反应操作,并带有明确确认
LLM快速复制
在GitHub上使用此代码块上的复制按钮。
Repo: imessage-mcp
Goal: Full iMessage MCP including attachments and send/reaction actions.
Setup:
1) npm install
2) Grant Full Disk Access to terminal app
3) Add MCP config entry for index.js
Use:
- read_recent_messages, search_messages, get_conversation
- list_chats_structured, get_conversation_by_chat_id, find_outreach_followups
- get_attachment for image/file analysis
- send_message/send_message_batch/react_to_message with explicit confirm flag
How it works:
- SQLite + attributedBody decoding + AppleScript actions wrapped as MCP toolsAvailable Tools
14 toolsdetect_message_serviceA
Inspect local Messages history for a recipient and recommend iMessage, SMS/RCS, or auto before sending. This is best-effort because Apple does not expose a direct preflight availability API.
Inputs: to (required), limit.
find_outreach_followupsA
Find SMS outreach conversations that need agent review or follow-up. Returns structured candidates with status, risk labels, and evidence snippets.
Inputs: limit, hours_ago, max_results, outreach_terms.
get_attachmentA
Get an attachment (image, file) from a message. Returns images directly so Claude can view and analyze them. Use message IDs from get_conversation results.
Inputs: message_id (required).
get_conversationA
Get full conversation thread with a specific contact or phone number, optionally filtered by time. Shows text content and indicates attachments.
Inputs: limit, contact, hours_ago, phone_number.
get_conversation_by_chat_idA
Get a conversation by iMessage chat_id as structured JSON. Use chat_id from list_chats_structured or find_outreach_followups.
Inputs: chat_id (required), limit, hours_ago.
list_chats_structuredB
List recent chats as structured JSON with chat IDs, handles, last sender, last message preview, group status, and message counts.
Inputs: limit, hours_ago.
list_delivery_failuresA
List recent outgoing messages that Messages marked failed, pending, or potentially recovered by SMS/RCS fallback. Use this to find red Not Delivered bubbles.
Inputs: limit, hours_ago, include_pending.
list_recent_chatsB
List recent active conversations, sorted by most recent activity
Inputs: limit, hours_ago.
lookup_contactA
Look up a contact name in macOS Contacts to find their phone number or email
Inputs: name (required).
react_to_messageA
React to a message with an emoji (❤️, 👍, 👎, 😂, ‼️, ❓). IMPORTANT: Always show the user which message and reaction before sending, and get explicit confirmation.
Inputs: confirm (required), reaction (required), message_id (required).
read_recent_messagesB
Read recent iMessages from your Messages app
Inputs: limit, include_group_chats.
search_messagesA
Search for messages by contact name, phone number, or message content
Inputs: query (required), limit.
send_messageA
Send an iMessage or SMS/RCS to a contact (uses AppleScript). Supports iMessage (blue bubble), SMS/RCS (green bubble), or auto-detection with verified fallback when the auto_sms_fallback release flag is enabled. IMPORTANT: Always show the user the message content and recipient before sending, and get explicit confirmation.
Inputs: to (required), confirm (required), message (required), service.
send_message_batchA
Preview or send a reviewed SMS/iMessage batch. Preview returns an approval token. Sending requires the same exact batch, confirm=true, and the token.
Inputs: items (required), confirm, service, approval_token.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Several tools overlap significantly: read_recent_messages, list_chats_structured, and list_recent_chats all list conversations with varying formats. get_conversation and get_conversation_by_chat_id retrieve threads but differ only in ID type, which could confuse agents. send_message and send_message_batch have overlapping purposes (sending messages) with subtle differences in batching.
Most tools follow a verb_noun pattern (read_recent_messages, search_messages, send_message, list_delivery_failures), but there are inconsistencies: get_conversation vs get_conversation_by_chat_id (one is specific, one generic), and list_chats_structured vs list_recent_chats (both list chats but with different modifiers). The style is consistent snake_case, but the verbs (read, search, get, list, send, detect, find, lookup, react) vary without a clear hierarchy.
14 tools is within the well-scoped range for a messaging server. The count is slightly high but justified by the need to handle message reading, searching, sending, attachments, and delivery status. Each tool serves a distinct function (though some overlap), so the count is reasonable.
The server covers core iMessage workflows: listing, searching, reading conversations, sending (including batch), reactions, attachments, and delivery failures. However, it lacks obvious lifecycle operations like deleting messages, marking as read/unread, or editing sent messages. There's also no tool to create a new conversation with a new contact, only sending to existing/known contacts. These gaps are not fatal as most agents would work around them, but they are notable for a comprehensive messaging tool.
Maintenance
Related MCP Connectors
Send and read iMessages from your own Mac and Apple ID — drafts, history and contacts.
Send and receive iMessage, SMS, RCS, and WhatsApp, and manage contacts, chats, and numbers.
MCP connector for iMessage & Contacts via a local Mac agent + Vercel relay
Explore your Messages SQLite database to browse tables and inspect schemas with ease. Run flexible…
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables reading, searching, and sending iMessages directly from MCP-compatible clients by accessing the local macOS iMessage database, supporting conversations, attachments, and both individual and group chats.10MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to read iMessage history and send messages on macOS. Supports conversation listing, message search with keyword and semantic modes, contact lookup, and sending messages to existing conversations.1311MIT
- FlicenseAqualityDmaintenanceEnables reading, searching, and sending iMessages on macOS by accessing the local messages database and utilizing AppleScript. Users can list conversations, search message history, and send messages to individuals or group chats directly through the Model Context Protocol.6-
- AlicenseNot gradedqualityCmaintenanceEnables reading, sending, and managing iMessage conversations on macOS through MCP.1MIT