macos-messages
macos-messages is a Python library and CLI for reading your macOS Messages.app data. It gives you quick, easy, read-only access to your iMessage and SMS history.
Why would I want this?
I built this primarily so AI agents (like Claude running in a terminal) can read my messages on my behalf. When I'm working with an AI assistant and I say "find that restaurant recommendation someone texted me last week," I want it to actually be able to go look.
But it's useful for plenty of other things too:
- Search your messages for something you know someone sent you
- Export conversations for safekeeping
- Build tools that analyze your messaging patterns
- Pipe message data into other scripts
The key thing is that it's read-only. macos-messages can't send messages, modify anything, or access your Apple ID. It just reads what's already on your Mac.
What it looks like
From the command line:
# List your conversations
messages chats
# Get messages from a chat
messages --chat 42
messages --chat "Mom"
# Get messages with a contact
messages --with "Mom"
# Search across everything
messages --search "dinner tomorrow"
# Include messages in "Unknown Senders" (excluded by default)
messages --search "discount" --include-unknown-senders
# List only unread messages
messages --unread
Or in Python:
import messages
db = messages.get_db()
# Get your recent conversations
for chat in db.chats(limit=5):
print(f"{chat.display_name}: {chat.message_count} messages")
# Read messages from a specific chat
for msg in db.messages(chat_id=42, limit=10):
sender = "me" if msg.is_from_me else msg.sender.display_name
print(f"{sender}: {msg.text}")
Installation
uv tool install macos-messages
You'll need to grant Full Disk Access to your terminal app before this will work. See the Permissions guide for instructions.
Documentation
Full documentation is available at macos-messages.readthedocs.io, including:
- Installation - Getting set up
- Quickstart - Your first queries
- CLI Reference - All the commands
- Python Library - Full API docs
- Permissions - macOS permissions explained
Requirements
- macOS
- Python 3.12+
- Full Disk Access permission for your terminal
Contributing
Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration.
License
The library is available as open source under the terms of the MIT License.
Metadata
Release files for macos-messages 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| macos_messages-0.2.0.tar.gz | 843.9 kB | Without provenance | Details for macos_messages-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| macos_messages-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for macos_messages-0.2.0-py3-none-any.whl |
Total release size: 866.2 kB
Release files / macos_messages-0.2.0.tar.gz
| Download URL | macos_messages-0.2.0.tar.gz |
|---|---|
| Size | 843.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8827ba2bb52d7a8d982021cc0a31173645e88ff84d24de5a92f836f624049cfe
|
|
BLAKE2b-256 checksum How to use checksums |
cc171708e03b9a85e23bca3161200e5b26837cc84a26b581549d971bef3c965d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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}
|
Release files / macos_messages-0.2.0-py3-none-any.whl
| Download URL | macos_messages-0.2.0-py3-none-any.whl |
|---|---|
| Size | 22.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d721bd352690fce589b57afc927d0d1e5be056381945b2541831a601daa42be
|
|
BLAKE2b-256 checksum How to use checksums |
6ac582c65372fefeeaeb0c6348a8999717320be55d615e2198f3f7349b9f5d1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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}
|
Security for macos-messages 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.