Skip to content

Messages: list attachments in messages_fetch and add messages_attachment_read - #244

Merged
mattt merged 2 commits into
mainfrom
mattt/messages-attachments
Sep 24, 2026
Merged

mattt merged 2 commits into
mainfrom
mattt/messages-attachments

Conversation

@mattt

@mattt mattt commented Sep 24, 2026

Copy link
Copy Markdown
Owner

This PR brings @patp's #214 onto the current main. The #214 branch still carried the original commit from #198, which was squash-merged, so it conflicted. This is its attachments commit cherry-picked onto main, with @patp as the author, plus a formatting pass for the lint check.

patp and others added 2 commits September 24, 2026 11:36
- attachments: true on messages_fetch returns each message's attachments
  ({@id, name, encodingFormat, contentSize, sticker}, hidden ones excluded)
  and keeps attachment-only messages (U+FFFC / at_<n>_<UUID> placeholders
  stripped from the text)
- messages_attachment_read {id, maxBytes}: base64 bytes of one attachment,
  only from under the granted Messages folder
- RawDatabase: read-only sqlite3 access for the attachment join
@mattt
mattt merged commit 8577275 into main Sep 24, 2026
1 check passed
@mattt
mattt deleted the mattt/messages-attachments branch September 24, 2026 23:05
mattt added a commit that referenced this pull request Sep 26, 2026
The attachments added in #244 are listed through a second SQLite connection, which assumed that the default database path and folder grants always open `chat.db` with its write-ahead log. When the log is unreadable, Madrid falls back to `immutable=1`, but the second connection still opened with `mode=ro`. macOS refused it, so `messages_fetch` with `attachments: true` failed with `attachmentsQueryFailed("authorization denied")`.

This PR makes `DatabaseAccess.immutable` follow the database's `accessMode`, so both connections open the file the same way.
mattt added a commit that referenced this pull request Sep 26, 2026
…247)

This PR removes the `messages_attachment_read` tool added in #244, so it does not ship in 1.6.0.

In a signed, sandboxed build of `main`, iMCP reads `chat.db` through the Messages folder grant, but opening any file under `~/Library/Messages/Attachments` fails with "Operation not permitted". That includes a screenshot sent seconds earlier. It fails with the folder grant's security scope active and after adding the app to Full Disk Access, and no sandbox or TCC denial is logged. So the tool reported every attachment as missing.

`messages_fetch` with `attachments: true` still lists each attachment's name, type, size, and `@id` from `chat.db`. Reading the files can come back once we know what grants access to them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants