mcpField
I
imessage

imessage

github.com/letta-ai生产力152206 次安装4 周前更新
代码仓库

关于 imessage

iMessage Integration 是一项使用 `imsg` CLI 在 macOS 上收发 iMessage 和 SMS 的集成说明,面向需要配置消息访问的用户。它涵盖构建工具、系统权限、聊天记录查看、消息发送及新消息监听。

主要功能

  1. 01说明构建与配置 imsg
  2. 02列出聊天并查看消息历史
  3. 03发送文本和附件
  4. 04监听新消息
  5. 05介绍 macOS 所需权限

适用场景

  1. 01配置终端读取消息历史的权限
  2. 02查看近期聊天或指定会话记录
  3. 03发送 iMessage 或 SMS 附件
  4. 04排查授权或 SMS 转发问题

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/letta-ai/skills --skill imessage

安装后在 Claude Code 中输入/imessage确认已加载。

详细介绍

iMessage 集成

使用 macOS 上的 imsg CLI 工具发送和读取 iMessage/SMS。

设置

1. 构建 imsg CLI

克隆并构建该工具:

git clone https://github.com/letta-ai/imsg.git ~/repos/imsg
cd ~/repos/imsg
swift build -c release

二进制文件位于 ~/repos/imsg/.build/release/imsg(如果 ~/repos/imsg/bin/imsg 中有预构建的二进制文件,也可以使用该文件)。

2. 授予权限

所需的 macOS 权限(系统设置 → 隐私与安全性):

权限位置用途
完全磁盘访问权限隐私与安全性 → 完全磁盘访问权限读取消息历史记录
自动化隐私与安全性 → 自动化通过 Messages.app 发送消息
3. 启用 SMS 中继(可选)

若要向非 iMessage 用户发送 SMS(绿色气泡):

  1. 在 iPhone 上:设置 → 信息 → 短信转发
  2. 启用转发到 Mac

命令

列出最近的聊天
imsg chats --limit 10
imsg chats --limit 10 --json

输出格式:[chat_id] (identifier) last=timestamp

查看聊天记录
# View last 20 messages in a chat
imsg history --chat-id <id> --limit 20

# With attachments metadata
imsg history --chat-id <id> --limit 20 --attachments

# Filter by date
imsg history --chat-id <id> --start 2026-01-01T00:00:00Z --json
发送消息
# Send to phone number
imsg send --to "+15555555555" --text "Hello!"

# Send with attachment
imsg send --to "+15555555555" --text "Here's the file" --file /path/to/file.jpg

# Force iMessage or SMS
imsg send --to "+15555555555" --text "Hi" --service imessage
imsg send --to "+15555555555" --text "Hi" --service sms

# Send to existing chat by ID
imsg send --chat-id 86 --text "Hello!"
监听新消息
imsg watch --chat-id <id> --debounce 250ms

最佳实践

电话号码格式
  • 使用 E.164 格式:美国号码使用 +1XXXXXXXXXX
  • 国际号码请包含国家/地区代码
SMS 与 iMessage
  • iMessage(蓝色气泡):Apple 设备用户的默认方式,免费
  • SMS(绿色气泡):需要 iPhone 中继,运营商可能会收费
  • 收件人没有 iMessage 时,使用 --service sms
Agent 消息礼仪
  • 简洁明了——消息应简短清晰
  • 自然得体——写得自然,不要像机器人
  • 说明上下文——跟进时,请提及之前的对话
  • 注意时间——避免在清晨或深夜发送消息

常见用例

安排服务
imsg send --to "+14155551234" --text "Hi! Do you have availability this Saturday for a cleaning?"
跟进
imsg send --to "+14155551234" --text "Just wanted to follow up on my earlier message. Let me know when you have a chance!"
确认预约
imsg send --to "+14155551234" --text "Confirming our appointment for Saturday at 10am. See you then!"

故障排除

问题解决方案
出现“not authorized”错误为终端授予自动化权限
无法读取消息为终端授予完全磁盘访问权限
SMS 无法发送在 iPhone 上启用短信转发
消息一直处于发送状态检查 Messages.app 是否已登录且运行正常

技术说明

  • 使用 AppleScript 发送消息(不使用私有 API)
  • 读取操作只读 Messages SQLite 数据库
  • 需要 macOS 14+,并配置好 Messages.app
  • 二进制文件位置:~/repos/imsg/bin/imsg(请根据需要调整路径)

评论

支持 Markdown