# imsg: a Swift command line that reads, streams and sends iMessage from a Mac

slug: imsg · https://miscsubjects.com/a/imsg · category: reference · tags: reference, imessage, mac, messaging · updated 2026-09-08T20:13:06.672Z

imsg is an open-source command-line program for a Mac that reads, streams and sends iMessage and SMS through the Messages app already signed in on that Mac. Its README states the scope in one line: it "is a Swift CLI for reading, watching, and sending iMessage and SMS from macOS". It is written in Swift 6, licensed MIT, requires macOS 14 or newer, and installs with one Homebrew command, `brew install steipete/tap/imsg`. On 2026-09-08 the repository showed about 1,300 stars and its latest release, 0.15.3, was published the day before.

**Where the messages come from.** Every iMessage and SMS a Mac has ever received or sent sits in one SQLite file, the Messages database at `~/Library/Messages/chat.db`. imsg opens that file directly. The README is precise about the mode: "Read commands open the database in SQLite read-only mode." Nothing is written to the database; the program decodes what Messages already stored. That decoding is the reason the tool exists rather than a plain SQL query: since 2026 Messages stores most message bodies not in the plain `text` column but in a binary `attributedBody` blob, and imsg decodes those blobs back into text, reactions, reply context, attachment records and scheduled messages.

**Streaming.** The `watch` command emits one JSON object per new message as it arrives. It follows filesystem events on the database and its write-ahead log, with a polling fallback for the cases where macOS drops an event, and it can start from a saved row id so a consumer that was offline replays exactly what it missed. Output discipline is explicit: the flag "emits one JSON object per line. Human progress and warnings stay on stderr, so stdout remains safe to stream."

**Sending.** `send` asks the Messages app to send, through Apple's own automation surface (AppleScript), and then confirms the outgoing row appeared in the database, returning its id and guid. A separate `message.send_status` method reports whether that row was later marked delivered or read. Text, files and audio go through the same path. For SMS the README requires Text Message Forwarding on the paired iPhone and states the limit plainly: the send path "cannot force a particular outgoing number when several numbers share one Apple ID".

**A long-running interface for programs.** `imsg rpc` speaks JSON-RPC 2.0 over standard input and output, with no network port: initialize, chats.list, messages.history, messages.search, messages.after (a cursor over everything newer than a row id), messages.stats, watch.subscribe, send, send.tracked (idempotent, caller-supplied id), message.send_status and typing, plus a set of methods that only work with the optional helper described below.

**Permissions.** Three macOS grants govern what works. "Full Disk Access is required for local database reads." Sending and the six standard tapbacks additionally need Automation for Messages, and Contacts access is optional and only adds names to handles. Grants attach to the parent process that launches imsg, not to imsg itself.

**The two tiers.** Everything above runs with System Integrity Protection on. The README states that the normal commands "do not use private frameworks or process injection". A second tier, called Advanced IMCore, injects a helper into the Messages app to reach read receipts, typing indicators, rich sends, editing, unsending, stickers, polls and group management; those features "require SIP to be disabled and may be blocked by library validation or private-entitlement checks" on current macOS. With SIP on, `imsg status` reports those methods as unavailable and the first tier keeps working.

**What it does not do.** No HTTP server, no webhooks, no push notifications, no FaceTime, no multi-account support. Reactions on the first tier reach only the most recent incoming message of a chat and are performed through UI automation of the Messages window, which needs the Accessibility grant.

**Verdict.** For a Mac that is signed in to Messages and stays awake, imsg is the most complete SIP-on program for turning that Mac's own message history and identity into something a script can call: decoded history, a replayable stream, verified sends, and a stdio API. Its ceiling is Apple's: anything Messages will not do through AppleScript needs the SIP-off helper, and that helper is explicitly research-grade.


## Sources

1. openclaw/imsg README — https://github.com/openclaw/imsg
2. openclaw/imsg README, Permissions and Advanced IMCore — https://github.com/openclaw/imsg#permissions

