Skip to main content
Glama
Apple Messages MCP

Apple Messages MCP

Apple Messages MCP

macOS 上で Claude から iMessage、SMS、RCS の会話を読み取り・検索します。

関連プロジェクト: claude-connector-apple-mail および claude-connector-apple-reminders。

ステータス: 読み取りと検索は安定しています。送信は動作しますが、実際の送信については未検証です — スクリプト呼び出しは実装済みで構文も確認済みですが、Apple はこれまでに send を壊したことがあるため、最初の実際の送信はテストとして扱ってください。詳細は メッセージの送信 を参照してください。

ツール

ツール

説明

get_stats

合計数、未読数、サービス別の内訳 (iMessage/SMS/RCS)、日付範囲

list_chats

会話一覧。最近アクティブな順。参加者とプレビュー付き

get_chat_messages

1 つの会話のメッセージ。古い順、ページング対応

search_messages

全履歴に対する部分文字列検索。会話、送信者、日付範囲でフィルタリング可能

get_message

1 件のメッセージの全文。添付ファイルと配信タイムスタンプ付き

get_attachment

添付ファイルのバイト列。base64 エンコード

refresh_search_index

ローカル検索インデックスをウォームアップまたは再構築

compose_message

テキストを事前入力した状態で Messages を開く — 送信ボタンを押すのはあなた

send_message

既存の会話に送信。即座に配信されます

Related MCP server: iMessage MCP Server

必要条件

  • macOS 13 Ventura 以降。RCS には macOS 26 以降が必要です。

  • Claude アプリに対する フルディスクアクセス — 読み取りに必要です。

  • Messages に対する 自動化 権限 — 送信と連絡先名に必要です。 macOS はこれを自動的にプロンプト表示します。

フルディスクアクセスを許可する方法

  1. システム設定 → プライバシーとセキュリティ → フルディスクアクセス

  2. Claude を有効にする (一覧にない場合は + で /Applications/Claude.app を追加)

  3. Claude を終了して再度開きます。 macOS はこの権限をプロセス起動時にキャッシュするため、 再起動は必須です — これを行わないと拡張機能は動作し続けられません。

Apple Mail と異なり、なぜフルディスクアクセスが必要なのか

Apple Mail 拡張機能は Mail.app と完全にスクリプト経由でやり取りするため、 特別な権限は不要です。しかし Messages はそうはいきません。

Messages の AppleScript 辞書が公開しているのは正確に 4 つのクラス — account、 chat、participant、file transfer — であり、メッセージクラスはありません。 macOS 26.5.2 で確認済み:

$ osascript -e 'tell application "Messages" to get every text message of first chat'
syntax error: Expected "from", etc. but found identifier. (-2741)

チャットと参加者の列挙は問題なくできますが、メッセージの 本文 は単純に公開されていません。 したがって、唯一の読み取り経路は ~/Library/Messages/chat.db 上の SQLite であり、これは TCC で保護されています。Automation と異なり、Full Disk Access はプログラムから 要求できません — ユーザーが手動で許可する必要があります。

このため、拡張機能は 2 つの権限をそれぞれ異なる目的で使用します:

目的

仕組み

権限

メッセージ、チャット、検索、添付ファイル

SQLite 上の chat.db

Full Disk Access

生のハンドルに対する連絡先名

Messages スクリプティング

Automation

送信

Messages スクリプティング (send)

Automation

事前入力された作成ウィンドウ

imessage: / sms: URL スキーム

権限不要

連絡先名は Messages の participant クラス (full name) から取得されます。これにより、 個別に保護されている AddressBook データベースを回避できます — Automation が拒否された場合、 ハンドルは単に生の数字として表示されます。

実装上の注意

attributedBody. Ventura 以降、message.text は頻繁に NULL になり、 本文は message.attributedBody に Apple の typedstream として格納されます — これは従来の NSArchiver 形式であり、plistlib では読み取れません。typedstream.py はこれを 純粋な Python でデコードするため、バンドルに PyObjC 依存は不要です。これは NSString/NSMutableString クラス名をアンカーとし、+ 型マーカーの後に続く 長さプレフィックス付き UTF-8 ペイロードを読み取ります。デコードは全か無かです: デコードできない本文は None を返し、クエリ自体は失敗しません。

タイムスタンプ. message.date は Apple エポック (2001-01-01) 基準で、macOS 13 より前は 秒、以降は ナノ秒 です。両方とも検出して処理します。

検索. chat.db にはテキストインデックスがなく、ほとんどの本文は attributedBody にのみ存在するため、SQL からは見えません。この組み合わせは 見た目以上に厄介です。

最初の実装では述語を m.text LIKE ? OR m.attributedBody IS NOT NULL に広げ、デコードした テキストを Python 側で再フィルタリングしていました。しかしこの 2 番目の句はほぼすべての最新 行に対して真となるため、クエリの LIMIT がスキャンを最新の数百メッセージに切り詰め、 Python フィルタが実行される前に — それより古い一致は静かに消えていました。実際の メッセージに対する検索は、遅いどころか結果ゼロを返していました。916 MB の 履歴では、検索が事実上最後の数日分しかカバーしないことを意味していました。

修正方法は、クエリごとにデコードするのではなく一度だけデコードすることです。index.py はデコード済み・ ケースフォールド済みの本文を ~/Library/Caches/apple-messages-mcp/search-index.db にミラーリングし、 検索はそれに対して JOIN します — これにより、一致、フィルタ、並び順、 LIMIT のすべてが SQL 内で完全な履歴に適用されます。ミラーは次のとおりです:

  • 増分更新。 新しいメッセージは message.ROWID ウォーターマークで検出されます。 編集と送信取り消しは既存の ROWID を再利用するため、各リフレッシュでは最新の 2000 行も確認します — ただし、date_edited が設定されている行、または両方の 本文列が NULL になっている行のみを対象とします。なぜなら、2000 個の blob を検索のたびに 再デコードするのは実質的な作業であり、ほとんどの場合何も見つからないからです。 Messages が何らかの理由でスタンプを付けなかった編集、またはそのウィンドウより古い編集は、 refresh_search_index(rebuild=True) が必要です。attributedBody デコーダの改善も 再構築を正当化します; SCHEMA_VERSION を上げれば強制的に再構築されます。

  • ケースフォールドのみ。 表示テキストは依然として chat.db から取得されるため、 ミラーは純粋にマッチングのためのものです。str.casefold() を格納することでサイズが半分になり、 非 ASCII に対しても大文字小文字を区別しないマッチングが正しく機能します — SQLite の LIKE は ASCII のみで大文字小文字を畳み込みます。

  • 使い捨て。 これは ~/Library/Caches に置かれ、削除されれば再構築されます。 ここから chat.db に書き込むことは一切ありません。

FTS5 ではありません。以前の計画にもかかわらず: FTS5 はトークン単位でマッチするため、 MATCH 'dentist' は "mydentist" を見つけられません。これは search_messages が文書化している 部分文字列セマンティクスよりも狭いものです。コンパクトなケースフォールド済みテキストに対する 部分文字列スキャンはすでに高速なので、FTS5 は使用できないセマンティクスのために インデックスを 2 倍にするだけです。将来クエリが遅くなった場合に備えて、後から追加するのは 限定的な変更で済みます。

読み取り専用・非ロック。 接続は mode=ro で開かれ、ステートメントは データベースを変更しません。SQLite がライブの WAL を読み取り専用で開けない場合は、 プライベートなスナップショットコピーにフォールバックするため、実行中の Messages.app を 妨害することはありません。

Tapback、編集、返信。 リアクションは associated_message_type (2000–2007、および削除を示す 3000 番台) からデコードされ、 スレッド返信は thread_originator_guid から、編集は date_edited から取得されます。

メッセージの送信

Messages には下書きオブジェクトがないため、Mail 拡張機能の 下書き優先設計に正確に対応するものはありません。書き込み経路には 2 つのレベルがあり、 それぞれ意図的に異なっています。

compose_message — 安全なデフォルト。 受信者と 本文を imessage: / sms: URL スキームで事前入力した状態で Messages を開き、そこで停止します。 人間がそれを読んで送信ボタンを押すため、Claude の判断だけでマシンから情報が送信されることはありません。 これは 新しい 会話を開始する唯一の方法でもあります。権限はまったく必要ありません。

send_message — 即座に配信。 スクリプティングインターフェースの send を使用し、取り消しはできません。電話番号ではなく chat_id を受け取りますが、 これは制限ではなく意図的な設計です: 辞書は participant と chat のどちらも受け付け、 既存のチャットを GUID で指定することで、呼び出し側が推測して iMessage 利用者に SMS を静かに送信するのではなく、Messages 側がトランスポート (iMessage / SMS / RCS) を 選択できます。また、confirm=True が必須であり、これは単に不注意で 起動されるのを防ぐためのガードです。

検証済みのことと、未検証のこと

macOS 26.5.2 で確認済み — 辞書は以下を公開しています:

send : direct-parameter (file | text), to: (participant | chat)

service type 列挙は SMS、iMessage、RCS であり、chat には アドレス指定のための GUID id プロパティがあり、生成された AppleScript はコンパイルされます。

未確認: 実際の送信が本当に配信されるかどうか。 Apple は過去に AppleScript の send を壊したことがあり、辞書に存在することが 動作の証明になったことはありません。テストスイートはメッセージを配信しないため、 最初の実際の送信が実験となります。失敗した場合、shortcuts run と "Send Message" アクションを 使う方法が次に試す価値のあるフォールバックです。

メッセージテキストは AppleScript に osascript 引数 (on run argv) として渡され、 スクリプトソースに補間されるわけではないため、二重引用符を含む本文は 構文エラーやインジェクションではなく、単に無害です。

添付ファイルの送信は配線されていませんが、file 直接パラメータがあるため 実現可能な範囲にあります。

開発

python3 tests/test_db.py       # SQL, decoder, and search-index tests
python3 tests/test_send.py     # compose URLs, send guards, argv safety
python3 tools/probe_schema.py  # verify the real chat.db (needs Full Disk Access)
./build.sh                     # test, validate manifest, pack the .mcpb

tests/test_db.py は実際のスキーマで使い捨てデータベースを構築するため、 Full Disk Access や実際のメッセージ履歴がなくても SQL を検証できます。そのうちの 1 つは 3000 件の新しいメッセージの下に一致を埋め込んでおり、上記で説明した 切り詰め検索バグの回帰テストとなっています。

tests/test_send.py は何も送信せず、ウィンドウも開きません: URL ビルダー、 ガード句、正確な osascript argv をカバーしています — そのためどこでも安全に実行でき、 その代わりに Apple の send が動作するかどうかは教えてくれません。

どちらのスイートも実際の検索インデックスには触れず、両方とも一時的なものを注入します。

ライセンス

MIT

Available Tools

9 tools
compose_messageA

Open Messages with a recipient and text prefilled, WITHOUT sending.

This is the safe way to write a message: it puts the text in front of the user in Messages and stops, so they read it and press send themselves. Prefer it over send_message, and use it whenever the conversation does not exist yet — send_message can only reply to an existing one.

Args: handle: Recipient phone number or email, e.g. "+15551234567". body: Text to prefill. May be empty to just open the conversation. service: "imessage" or "sms" — which transport Messages preselects.

Inputs: handle (required), body, service. Returns: A compose window was opened; nothing was sent.

get_attachmentA

Retrieve an attachment's bytes, base64-encoded.

Args: attachment_id: Attachment id from get_message.

Inputs: attachment_id (required). Returns: size, filename, mime_type, data_base64

get_chat_messagesA

Read messages from one conversation, returned oldest-first.

In Claude the result renders as an inline card, so don't repeat its contents in your reply — a one-line summary or the answer to the user's question is enough.

Args: chat_id: Conversation id from list_chats. limit: Maximum messages to return (default 50). before_id: Return messages older than this message id, to page back through history.

Inputs: chat_id (required), limit, before_id. Returns: result

get_messageA

Read one message in full, including attachments and delivery times.

In Claude the result renders as an inline card, so don't repeat its contents in your reply — a one-line summary or the answer to the user's question is enough.

Args: message_id: Message id from search_messages or get_chat_messages.

Inputs: message_id (required). Returns: id, date, guid, text, +15 more

get_statsA

Overview of the Messages database: message and chat totals, unread count, attachment count, a per-service breakdown (iMessage / SMS / RCS), and the date range covered.

Inputs: no named parameters. Returns: by_service, attachments, group_chats, total_chats, +5 more

list_chatsA

List conversations, most recently active first.

In Claude the result renders as an inline card, so don't repeat its contents in your reply — a one-line summary or the answer to the user's question is enough.

Args: limit: Maximum conversations to return (default 30). offset: Conversations to skip, for paging through the list.

Inputs: limit, offset. Returns: result

refresh_search_indexA

Update the local search index, and report on it.

search_messages keeps this current on its own, so calling this is optional. It is useful for warming the index deliberately — the first build on a large history decodes every message and takes a while — and for forcing a full rebuild.

Args: rebuild: Discard the index and decode every message again. Needed only to pick up edits to messages older than the recent-edit window.

Inputs: rebuild. Returns: State of the local search mirror (see index.py).

search_messagesA

Search message bodies across every conversation, over all history.

Backed by a local index of decoded message bodies, which is brought up to date automatically. The first search on a large history has to build that index and may take a while; later searches are fast.

In Claude the result renders as an inline card, so don't repeat its contents in your reply — a one-line summary or the answer to the user's question is enough.

Args: query: Text to look for (case-insensitive substring match). Leave it out to search on the filters alone — chat_id plus a date range with no search term reads one conversation newest-first. limit: Maximum messages to return (default 30). chat_id: Restrict to one conversation from list_chats. from_me: True for only messages you sent, False for only received. after: Only messages at or after this time. before: Only messages at or before this time.

Inputs: after, limit, query, before, +2 more. Returns: query, total, messages, truncated

send_messageA

Send a message to an existing conversation. This delivers immediately.

IRREVERSIBLE — the message goes out as soon as this runs, and scripting cannot unsend it. Confirm the exact recipient and wording with the user before calling, and pass confirm=True to acknowledge that. If they have not clearly asked for it to be sent, use compose_message instead and let them press send.

Messages picks the transport (iMessage, SMS, or RCS) for the conversation itself, which is why this addresses a chat rather than a raw handle. To start a new conversation, use compose_message.

Args: chat_id: Conversation id from list_chats. body: Text to send. confirm: Must be True. A guard against sending by accident.

Inputs: body (required), chat_id (required), confirm. Returns: A message was actually delivered.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 9 tools

    Disambiguation4/5

    Each tool has a clear primary purpose: listing chats, reading messages, single-message lookup, attachments, stats, compose, send, and index refresh are all distinct. The only mild overlap is between get_chat_messages and search_messages when search is given a chat_id with no query term, but the descriptions explicitly clarify this boundary.

    Naming Consistency5/5

    All tools use snake_case with a verb_noun shape (list_chats, get_message, send_message, compose_message, search_messages, refresh_search_index). No mixed conventions or vague standalone verbs.

    Tool Count5/5

    Nine tools is well-scoped for a Messages client: a compact read/search surface plus the two write paths (compose/send) and one maintenance operation. Nothing feels redundant or missing by count.

    Completeness4/5

    Core lifecycle is covered: discover chats, read messages, search, fetch attachments, send and draft messages, plus stats and index maintenance. Minor gaps remain (e.g. group-chat creation or participant management, reactions, marking read), but agents can work around them.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables Claude to send and read iMessages on macOS, with smart contact lookup, message history retrieval, and cross-conversation search using natural language commands.
      6
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to read and search through iMessage, SMS, and RCS conversations, including mixed-protocol group chats with Android users. It decodes binary message data from the macOS Messages database to provide a comprehensive view of message history.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to send and read iMessages on macOS, with human approval required for sending and no auto-replies.
      2
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      Connects Claude Desktop to iMessage on macOS, enabling reading conversations, searching messages, sending texts, and managing attachments.
      7
      8 npm
      MIT