Skip to main content

Fast, local iMessage for your terminal + MCP — Rust-accelerated read/search, AppleScript send. macOS only.

Project description

imsg — fast, local iMessage for your terminal & MCP

PyPI Python Built with Rust License: MIT macOS only

Read, search, and send iMessage from your terminal — or expose it to Claude, Cursor, VS Code, or any MCP client. Everything runs locally on your Mac: no cloud, no login, no account. Reads open ~/Library/Messages/chat.db read-only; sends go through Messages.app.

Why another one? The hot path — decoding tens of thousands of attributedBody typedstream blobs — is written in Rust (PyO3 + rusqlite), so reads and searches over a large history are several times faster than the pure-Python equivalent that other Messages servers use. Pure Python still ships as a zero-dependency fallback, so it works even where the wheel doesn't.

Benchmark

Full-history search over a synthetic 50,000-message database (70% stored as attributedBody blobs), best-of-5, Apple Silicon (16 cores):

operation pure-Python Rust core speedup
full-history search (decodes every message) 120.9 ms 35.7 ms 3.4×
batched blob decode (allocation-bound) 19.1 ms 19.6 ms 1.0×

Two honest caveats, stated up front:

  • Raw blob decoding is ~a wash — it's bound by allocating result strings, not CPU, so native code doesn't help. The win is in search, where Rust decodes and filters across all cores and returns only the matches.
  • It's 3.4×, not 16×, because the SQLite read and result marshalling are serial on both sides; only the decode+match parallelizes. The gap widens on larger histories.

Reproduce: python bench/benchmark.py. Bonus: this search also finds messages whose text lives in an attributedBody blob — which a plain text LIKE query (used by Python-only Messages servers) silently misses.

Install

# with uv (recommended) — provisions Python + the prebuilt wheel
# PyPI package name is mac-imsg (imsg was too similar to an existing project);
# the installed CLIs are still `imsg` and `imsg-mcp`.
uv tool install mac-imsg

# or pip
pip install mac-imsg

# or Homebrew
brew install ml-lubich/tap/imsg

Requirements

  • macOS (reads the local Messages database; sends via Messages.app).
  • Full Disk Access for the app that runs imsg — Terminal/iTerm/Ghostty for the CLI, or your MCP client (Claude Desktop, Cursor, VS Code…) for the server. System Settings → Privacy & Security → Full Disk Access → add it, then fully quit and reopen it.
  • Messages.app signed in and able to send a normal message.

Run imsg doctor to check access and see which engine (Rust or Python) is live.

Specs live under docs/ (overview, architecture, design, API, testing).

CLI

imsg -h                           # commands (also: imsg <cmd> -h)
imsg doctor                       # check Full Disk Access + engine
imsg chats                        # recent conversations + their ids
imsg contacts                     # handles (numbers / emails) seen
imsg contacts -q 415              # filter handles by substring
imsg read -c +14155551234         # recent messages with a contact
imsg read --chat 42 --limit 100   # a specific conversation
imsg search "dinner"              # search message text
imsg send +14155551234 "on my way"

Every command accepts -h / --help with options, arguments, and examples (agent-friendly).

MCP server

The imsg-mcp entry point speaks MCP over stdio. Add it to any client:

Claude Code

claude mcp add --transport stdio --scope user imsg -- imsg-mcp

Claude Desktop / Cursor (mcpServers) · VS Code (servers):

{ "mcpServers": { "imsg": { "command": "imsg-mcp" } } }

Tools exposed: check_access, get_recent_messages, search_messages, list_chats, list_contacts, send_message (the only one with a side effect).

How it works

There is no official iMessage API. Every tool in this space does the same two local things; imsg just does the heavy half in Rust:

Operation Mechanism Engine
read / search / list chat.db (SQLite, read-only) + typedstream decode Rust (imsgcore), Python fallback
send AppleScript → Messages.app Python (osascript)

SQLite is the same C library everywhere, so the read speedup comes from doing the per-message attributedBody decode and row marshalling natively instead of in a Python loop. See bench/benchmark.py for the methodology — both engines run identical queries over an identical synthetic database, and the pure-Python column is the same algorithm Python-only servers use.

Privacy & security

  • All database connections are opened read-only (mode=ro).
  • Nothing is uploaded, mirrored, or indexed off-device.
  • Sending is isolated in one function, escapes its AppleScript inputs, and is the only operation that writes anything anywhere.
  • Full Disk Access is broad — grant it only to apps you trust.

Development

git clone https://github.com/ml-lubich/imsg.git && cd imsg
uv venv && source .venv/bin/activate
uv pip install maturin
maturin develop            # builds the Rust core + installs the package
uv pip install -e ".[dev]"
pytest                     # tests run on the pure-Python path (and Rust if built)
python bench/benchmark.py  # regenerate the benchmark

License

MIT © ml-lubich. Not affiliated with Apple. Use responsibly and only with accounts and conversations you own.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mac_imsg-0.1.2.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mac_imsg-0.1.2-cp310-abi3-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file mac_imsg-0.1.2.tar.gz.

File metadata

  • Download URL: mac_imsg-0.1.2.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mac_imsg-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6d4841777719dbe7b3368de1db956e0a59aaa7e4f5f01e1b25166c177ddac4d0
MD5 cf758bd53858b06b4bf950fea4f36e07
BLAKE2b-256 a23c9ba81dbb63f8dbb020034a240728e30396b00c8bb346a1903144ca3ffcf8

See more details on using hashes here.

File details

Details for the file mac_imsg-0.1.2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: mac_imsg-0.1.2-cp310-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.10+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mac_imsg-0.1.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30e29db03ac612cf76aa22367658f3d682e3541b0b7a41f5972a292c76618c42
MD5 de2f046db73126a56d3d5715547058d2
BLAKE2b-256 bccf72c8e07433ffad4613cfc414ed41535be2f732eb37d72a2805a85c7bf920

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page