feat: Add isRead and dateRead fields to Message model#10
Closed
michaelfarrell76 wants to merge 1 commit into
Closed
feat: Add isRead and dateRead fields to Message model#10michaelfarrell76 wants to merge 1 commit into
michaelfarrell76 wants to merge 1 commit into
Conversation
Add `isRead` (Bool) and `dateRead` (Date?) properties to the Message struct, populated from the `is_read` and `date_read` columns in chat.db. Also add an `unreadOnly` parameter to `fetchMessages()` that filters to incoming unread messages (is_read = 0 AND is_from_me = 0) when set. These columns have been present in Apple's Messages database schema but were not previously selected or exposed. Made-with: Cursor
This was referenced Mar 22, 2026
Owner
|
@michaelfarrell76 Thanks so much for putting this together. I took an alternate pass in #11 that keeps |
Owner
|
This is now available in 0.3.0. I'll follow up in iMCP for the feature there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
messagetable in Apple'schat.dbincludesis_readanddate_readcolumns that are not currently selected or exposed by Madrid. This PR adds support for them:Message.isRead: Bool— whether the message has been read (is_readcolumn)Message.dateRead: Date?— when the message was read (date_readcolumn, nil if unread or 0)fetchMessages(unreadOnly:)— new optional parameter that filters to incoming unread messages (is_read = 0 AND is_from_me = 0) when set totrueMotivation
AI assistants using iMCP's
messages_fetchtool currently cannot distinguish read from unread messages. This is one of the most natural queries a user would make ("show me my unread messages"). The underlying data is already inchat.db— Madrid just needs to thread it through.Implementation
Message.swift— AddedisRead: BoolanddateRead: Date?propertiesDatabase.swift— Addedm.is_read(column index 7) andm.date_read(column index 8) to the SELECT infetchMessages(). AddedunreadOnlyparameter that appendsm.is_read = 0 AND m.is_from_me = 0conditions whentrue.dateReaduses the same nanoseconds-since-reference-date conversion asdate.Caveats
is_readanddate_readare reverse-engineered columns — Apple does not document thechat.dbschema. The columns are well-established across community tooling (imessage-exporter, imessage-mcp, SketchyBar).is_read = 0is a best-effort approximation and may not exactly match the Messages app badge count in all cases.Companion PR
An iMCP PR to expose this via
messages_fetchwill follow.Made with Cursor