Skip to main content
Glama
imessage-mcp

imessage-mcp

by kashyapmanu

imessage-mcp

A local, read-only Model Context Protocol server that lets an MCP client (such as Claude Desktop) search and read your macOS Messages history from ~/Library/Messages/chat.db.

It runs on your Mac over stdio, opens the database read-only, and never sends data anywhere. It cannot send, edit or delete messages.

Requirements

  • macOS with Messages signed in and in use

  • Node.js 22.13 or newer (uses the built-in node:sqlite module, so no native compilation is needed)

Related MCP server: iMessage MCP

Install and build

git clone https://github.com/kashyapmanu/imessage-mcp.git
cd imessage-mcp
npm install
npm run build

Output goes to dist/. The entry point is dist/index.js.

Full Disk Access

macOS protects ~/Library/Messages and ~/Library/Application Support/AddressBook (Contacts). The app that launches this server (for example Claude Desktop, or your terminal if you run it manually) needs Full Disk Access:

  1. Open System Settings > Privacy & Security > Full Disk Access.

  2. Enable the app that runs the server (e.g. Claude).

  3. Fully quit and restart that app.

If Messages access is missing, every tool returns an error that explains this. If only Contacts access is missing, message tools still work but names are omitted, and the server logs one line to stderr.

Claude Desktop starts MCP servers through a helper that makes macOS check the program being run, so a plain node entry needs Full Disk Access granted to node itself, which would cover every Node script. Instead, build a tiny launcher that runs only this server and grant access to that:

scripts/build-launcher.sh   # needs Xcode Command Line Tools (cc, codesign)

This creates ~/.local/share/imessage-mcp/imessage-mcp-launcher. Add that file under Full Disk Access, and use it as the command in the config below (no args). The launcher bakes in two paths: the stable Homebrew symlink /opt/homebrew/bin/node (so Node upgrades and npm run build need no action) and this repo's dist/index.js. Re-run the script and re-grant only if you move the repo or stop using Homebrew Node.

Configuration

Variable

Default

Purpose

IMESSAGE_DB_PATH

~/Library/Messages/chat.db

Override the Messages database file to read.

CONTACTS_DB_DIR

~/Library/Application Support/AddressBook

Override the AddressBook base directory used for Contacts name lookup.

Contacts names

Handles are labelled with names from macOS Contacts. The server opens every AddressBook-v22.abcddb under the AddressBook directory (the root database and each Sources/*/ database) read-only, once per process, the first time a name is needed. It normalises phone numbers to their last 10 digits, so (415) 555-1234 matches the handle +14155551234, and lower-cases emails. Names are display only; nothing is written.

If a Contacts database cannot be read, the server prints one line to stderr and continues without names.

Tools

All tools are annotated readOnlyHint: true and openWorldHint: false. Results are JSON-style text. Limits default to 50 and max at 500. Each message's text is capped at 2000 characters, and total output at 100 KB.

Tool

Purpose

list_chats

Recent conversations with chat id, name, participant handles and participant_names, last message time and message count.

read_messages

Messages newest-first, filtered by chat_id, contact, since / until (ISO dates). Shows sender, sender_name for incoming messages, text, is_from_me and attachment count.

search_messages

Case-insensitive text search with optional contact and date filters. Incoming messages include sender_name. Reports if the scan cap was reached.

get_conversation

The most recent messages of one chat, oldest first. Use before to page back.

get_unread

Incoming messages that Messages marks unread. The flag is read from chat.db and may not match the app exactly.

list_contacts_handles

Phone numbers and emails with their Contacts name and message counts. query matches a handle substring or a contact name.

Notes:

  • Tapbacks (reactions) and group events are excluded from message results.

  • Message text is read from message.text. When that is empty, the server decodes the NSString from message.attributedBody.

  • contact accepts a contact name, phone number or email. It matches messages from any handle that matches the text, belongs to a contact whose name contains it, or (for 7 or more digits) has the same digits, so (415) 555-1234 finds +14155551234. It also matches your replies in chats that include those handles. A name matching more than 200 handles is cut to the first 200, with a note on stderr.

  • Names come from macOS Contacts. Without Contacts access, sender_name, name and participant_names are null or empty.

Claude Desktop configuration

Add this to claude_desktop_config.json (Claude > Settings > Developer > Edit Config), using the absolute path to your build:

{
  "mcpServers": {
    "imessage": {
      "command": "/Users/YOU/.local/share/imessage-mcp/imessage-mcp-launcher"
    }
  }
}

Use the absolute path to the launcher. (Without the launcher, use the absolute path from command -v node as command and ["/absolute/path/to/imessage-mcp/dist/index.js"] as args, and grant Full Disk Access to node.) Fully quit Claude Desktop from the menu bar and reopen it afterwards.

Set it up with an AI agent

Paste this into Claude (Claude Code, or any agent with shell access on your Mac) to install and connect the server for you:

Set up the iMessage MCP server from https://github.com/kashyapmanu/imessage-mcp on this Mac so I can use it in Claude Desktop. It is local-only and read-only.

1. Check that Node.js 22.13+ is installed (`node -v`). If not, tell me and stop.
2. Clone the repo into ~/Projects/imessage-mcp, then run `npm install` and `npm run build`. Run `npm run smoke` and report the result (it prints only counts, never message contents).
3. (The launcher build in the next step bakes in the node and dist/index.js paths, so nothing to do here.)
4. Run scripts/build-launcher.sh and use the resulting ~/.local/share/imessage-mcp/imessage-mcp-launcher as the "command" (no args). Back up ~/Library/Application Support/Claude/claude_desktop_config.json, then add an "imessage" entry under "mcpServers" with the launcher path as "command" and no "args". Keep every existing server entry unchanged and keep the JSON valid.
5. Tell me to add that launcher file (not node, not all of Node) to Full Disk Access (System Settings > Privacy & Security > Full Disk Access), then fully quit and reopen Claude Desktop. Do not change any system or security setting yourself.
6. After I restart, help me verify by asking Claude to list my 3 most recent chats. Do not print or store message contents beyond what I ask for.

Ask me before anything that is not on this list.

Security and privacy

  • Runs entirely on your machine. There are no network calls and no third-party services.

  • The database is opened with readOnly: true and PRAGMA query_only. All SQL is parameterised, and the server issues only SELECT statements.

  • Message content is returned to whichever MCP client you connect. Only connect clients you trust, because they will see your message history.

  • Logs go to stderr only, since stdout carries the protocol.

Smoke test

npm run build
npm run smoke

scripts/smoke.mjs starts the built server, lists the tools and calls list_chats with a limit of 3. It prints only counts and field names, never message contents.

Available Tools

6 tools
get_conversationGet conversation contextA
Read-only

Return the most recent messages of one chat in chronological order (oldest first). Use 'before' (ISO date) to page back into older context.

Inputs: chat_id (required), limit, before.

get_unreadGet unread incoming messagesA
Read-only

List incoming messages that Messages marks as unread, newest first. The unread flag comes from chat.db and may not match the Messages app exactly.

Inputs: limit.

list_chatsList iMessage chatsA
Read-only

List recent iMessage/SMS conversations, newest activity first. Returns chat id, name (group display name, else participant contact names, else handles), participant handles with their Contacts names (participant_names), last message time and message count. Use the chat id with read_messages, get_conversation.

Inputs: limit, offset.

list_contacts_handlesList handles with message countsA
Read-only

List phone numbers, emails and other Messages handles with their Contacts name (if any) and how many messages each has, most active first. Optional query matches a substring of the handle id or of a contact name.

Inputs: limit, query.

read_messagesRead iMessage messagesA
Read-only

Read messages newest-first, optionally filtered by chat id, contact (name, phone or email) and date range. Returns timestamp, sender (me or handle), sender_name from Contacts for incoming messages, text, is_from_me and attachment count. Tapbacks and group events are excluded.

Inputs: limit, since, until, offset, +2 more.

search_messagesSearch iMessage textA
Read-only

Case-insensitive substring search over message text, newest first. Also decodes attributedBody for messages whose plain text is empty. Optional contact (name, phone or email) and date filters are applied in SQL. Incoming messages include sender_name from Contacts. The scan is capped; the result says if the cap was hit, meaning the search was not exhaustive.

Inputs: query (required), limit, since, until, +1 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 6 tools

    Disambiguation4/5

    Most tools are clearly separated by resource and intent: list_chats for conversation inventory, get_unread for the unread queue, search_messages for text lookup, list_contacts_handles for handle/contact inventory. The only mild overlap is read_messages versus get_conversation, since both return message content; descriptions clarify that one is filtered newest-first and the other is per-chat chronological, so confusion is limited.

    Naming Consistency5/5

    All six names follow a predictable verb_noun pattern in snake_case: list_chats, get_unread, read_messages, search_messages, get_conversation, list_contacts_handles. The verbs (list/get/read/search) are used sensibly and consistently with their semantics.

    Tool Count5/5

    Six tools is a well-scoped set for an iMessage read/inspection server, with each tool covering a distinct access pattern (chat list, unread, message read, search, conversation context, contacts). Nothing feels redundant or padded.

    Completeness3/5

    The read-side surface is fairly comprehensive: chats, unread messages, message history, search, conversation paging, and contact/handle mapping. However, there is no send-message or reply operation, no explicit attachment retrieval despite attachment counts being reported, and no way to mark messages read, which are notable gaps for a messaging server.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables reading, searching, and sending iMessages directly from MCP-compatible clients by accessing the local macOS iMessage database, supporting conversations, attachments, and both individual and group chats.
      10
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Read-only MCP server for local macOS Messages database, enabling querying of chats, messages, attachments, and metadata.
      7
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables AI clients to read and search macOS Messages history through a read-only MCP interface.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients to search and read Apple Messages history on macOS, including conversation timelines, attachments, contact resolution, change syncing, communication analytics, and server status checks.
      6
      MIT