
imsg
CLI在 macOS 上读取、实时监听和发送 iMessage 与短信:直接读本地 Messages 数据库,通过 Messages.app 发送,输出 NDJSON 与 JSON-RPC 供 agent 调用。需要 macOS 14 及以上,并给终端授予完全磁盘访问权限。
imsg 💬 — Messages, piped.

imsg is a Swift CLI for reading, watching, and sending iMessage and SMS from macOS. It reads the local Messages database, sends through Messages.app automation, and exposes NDJSON and JSON-RPC for scripts and agents.
imsg chats --limit 10 --json | jq -s
imsg history --chat-id 42 --limit 20 --attachments --json | jq -s
imsg watch --chat-id 42 --reactions --json
imsg send --to "+14155551212" --text "on my way"
That's the whole pitch: read directly, stream updates, and ask Messages.app to send.
Install
Homebrew is the smallest path on macOS:
brew install steipete/tap/imsg
imsg --version
imsg requires macOS 14 or newer. Signed macOS builds and Linux x86_64 read-only builds are also available from GitHub Releases. Linux reads a chat.db copied from macOS; it does not connect to iMessage or send messages. See the Linux guide.
Quick start
Grant your terminal Full Disk Access in System Settings → Privacy & Security, then reopen it. imsg needs that permission to read ~/Library/Messages/chat.db.
# Find a chat and note its id.
imsg chats --limit 3
# Read its ten most recent messages.
imsg history --chat-id 42 --limit 10
Use an id from the first command in place of 42. The five-minute quickstart continues with live watching and sending.
Core workflows
| Goal | Start here |
|---|---|
| List chats and inspect their identifiers | Chats and groups |
| Read or search local history | History |
| Stream new messages and tapbacks | Watch |
| Send text, files, and standard tapbacks | Send and attachments |
| Count messages and media | Statistics |
| Consume stable NDJSON or a long-running stdio API | JSON schema and JSON-RPC |
| Generate shell completions or model-ready CLI help | Completions |
Read commands open the database in SQLite read-only mode. watch follows database and WAL filesystem events, with a polling fallback when macOS drops an event or rotates a sidecar file.
Permissions
Full Disk Access is required for local database reads. Sending and standard tapbacks also require Automation → Messages; Contacts access is optional and only adds resolved names. The permissions guide covers parent-process grants and stale TCC entries, while troubleshooting maps common failures to their likely gate.
SSH sessions can also resolve contact names through the Mac’s read-only AddressBook database when the SSH service has Full Disk Access and Contacts.framework is unavailable. See Contacts over SSH.
For SMS, enable Text Message Forwarding on the paired iPhone. imsg send uses Messages.app's AppleScript surface and cannot force a particular outgoing number when several numbers share one Apple ID.
JSON and automation
--json emits one JSON object per line. Human progress and warnings stay on stderr, so stdout remains safe to stream. Pipe finite commands through jq -s when you want one array.
Numeric selectors are validated before work starts: chat IDs, limits, and poll option indices must be positive integers; message-part indices can also be zero. Malformed or overflowing values produce an error instead of selecting a default target. Defaults apply only when an option is omitted.
imsg chats --json | jq -s
imsg rpc
imsg completions llm
The JSON schema documents chats, messages, attachments, reactions, polls, scheduled messages, and statistics. The JSON-RPC reference covers the long-running stdio transport used by agents and gateways.
Advanced IMCore
Normal chats, history, watch, send, react, and read-only RPC workflows do not use private frameworks or process injection.
Read receipts, typing indicators, rich sends, message mutation, stickers, polls, and chat management use an injected helper inside Messages.app. They require SIP to be disabled and may be blocked by library validation or private-entitlement checks on current macOS releases. Start with Advanced IMCore, then use the bridge command reference for the full CLI surface and IPC layout.
imsg chat-create accepts phone numbers and email addresses you have never contacted. It creates missing handles through the active iMessage account and checks every recipient with IDS before creating the chat. You do not need to type recipients into Messages first.
Documentation
The complete guide lives at imsg.sh. Useful entry points include install, permissions, history, watch, send, attachments, Linux, and troubleshooting.
Development
make lint
make test
make build
IMsgCore contains the reusable Swift core, imsg contains the CLI, and IMsgHelper contains the optional injected helper. The package uses Swift 6 and targets macOS 14 or newer.
CI pins Xcode 26.6 on macOS, Swift 6.4.0 on Linux, Node 26.12.0 for docs tests, and SwiftLint 0.65.1. make lint treats formatting and lint findings as errors. scripts/check-linux.sh runs Linux tests and builds in the pinned Swift container, checks the standalone release archive in Ubuntu without Swift, and runs docs tests with the host's Node installation. Crabbox hydration installs the pinned Node version.
License
MIT. See LICENSE. Not affiliated with Apple; iMessage and SMS are trademarks of their respective owners.
相關資源

OpenClaw
CLI开源的个人 AI 助手,运行在自己的电脑上,经 Telegram、Slack、iMessage 等 20 多个聊天渠道与你对话;openclaw 命令负责网关、渠道配对与插件管理,模型可在 Claude、Codex 与本地模型间切换。
openclaw/openclaw392k
lark-cli(飞书 CLI)
CLI飞书官方命令行,200 多条命令覆盖消息、文档、多维表格、电子表格、日历、邮件、审批、OKR、会议与妙记,自带 20 多个 lark-* Agent Skill,输出结构化;需先创建飞书应用并登录授权。
larksuite/cli17.7k
DingTalk Workspace CLI (dws)
CLI钉钉官方开源命令行 dws,覆盖 AI 表格、日程、通讯录、群聊与机器人、待办、审批、考勤、日志、文档、听记与邮箱,输出结构化 JSON 并自带 Agent Skills;需企业管理员开通 CLI 访问后登录授权。
DingTalk-Real-AI/dingtalk-workspace-cli3.7k
wecom-cli(企业微信 CLI)
CLI企业微信官方命令行,覆盖消息、邮件、文档、在线表格与智能表格、待办、日程、会议纪要、微盘与通讯录,配套 Agent Skills;需 Node.js 18+ 与企业微信账号扫码授权。
WecomTeam/wecom-cli3.2k
Basecamp CLI
CLIBasecamp 官方命令行,可管理项目、待办、看板卡片、消息与文件,在项目群聊发言、跨项目搜索,输出带下一步提示的 JSON,自带 Agent Skill 与 Claude Code、Codex 插件。需 Basecamp 账号,安装脚本会引导浏览器授权。
basecamp/basecamp-cli290
persona-exec-assistant
Skillgws CLI 自带的行政助理角色技能:让 agent 替领导出每日简报、会前准备和每周摘要,分拣 Gmail 收件箱,先查冲突再排日程并起草回复;需安装 gws、用自建的 Google Cloud 项目授权 Google 账号,并同时装上 Gmail、日历、云端硬盘、Chat 技能。
googleworkspace/cli31.6k