Skip to content

Feature request: Add unread message filtering to messages_fetch #154

@michaelfarrell76

Description

@michaelfarrell76

Feature Request

Add the ability to filter messages_fetch to only return unread incoming messages, and include read status (isRead, dateRead) in the output.

Motivation

Fetching unread messages is one of the most natural queries when using iMCP with an AI assistant:

"Show me my unread messages"
"Do I have any messages I haven't read?"
"What messages need my attention?"

Currently messages_fetch returns all messages matching date/participant/query filters with no way to distinguish read from unread.

Proposed Solution

1. New unread_only parameter on messages_fetch

When true, filter to messages where is_read = 0 AND is_from_me = 0 in chat.db.

2. New isRead and dateRead output fields

Include read status in the message output for all queries, not just filtered ones.

Feasibility

The message table in chat.db already has is_read (INTEGER) and date_read (INTEGER, nanoseconds since reference date) columns. Madrid's Database.swift just needs to SELECT them, and Message.swift needs two new properties.

These columns are well-established across community tooling:

Implementation PRs

I've put together companion PRs for both Madrid and iMCP:

Caveats

is_read = 0 is a best-effort approximation of unread status — it may not exactly match the Messages app badge count in all edge cases. This should be documented in the parameter description.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions