Labsco
anipotts logo

imessage-mcp

β˜… 14

from anipotts

25 read-only tools for searching, analyzing, and exploring your entire iMessage history on macOS. Spotify Wrapped for texts, conversation analytics, streaks, read receipts, reactions, and more.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

imessage-mcp

npm version License: MIT TypeScript MCP CI Node

26 tools for locally exploring your iMessage history with AI.

<img src="https://raw.githubusercontent.com/anipotts/imessage-mcp/main/assets/demo-dark.gif" alt="imessage-mcp demo" width="100%">

if this helped you, star it. it helps others find it.

An MCP server that gives AI assistants read-only access to your local iMessage database. Nothing is written, modified, or uploaded. Your messages stay on your Mac; the AI only sees what you ask about.

Read-only access to 2 local files (chat.db + AddressBook). Zero network requests. Nothing is written, uploaded, or shared. All 26 tools are annotated readOnlyHint: true β€” your MCP client can auto-approve every call without prompts.

Privacy & Security

imessage-mcp reads your local iMessage database in read-only mode. No data leaves your machine. Nothing is written, modified, uploaded, or shared.

PathAccessPurpose
~/Library/Messages/chat.dbRead-onlyYour iMessage database
~/Library/Application Support/AddressBook/Read-onlyContact name resolution

No other files are accessed. No external APIs are called.

Copy & paste β€” that's it
chat.db --> [imessage-mcp] --> stdio/http --> [Your MCP Client] --> AI Provider
  ^                                              ^
  Your Mac only                         Already authorized by you

What Can You Ask?

Once connected, ask your AI assistant anything about your messages in plain language:

  • "Give me my 2024 iMessage Wrapped"
  • "Do I always text first with [name]?"
  • "What's my longest texting streak?"
  • "Who reacts to my messages the most?"
  • "What was the first text I ever sent my partner?"
  • "What was I texting about on this day last year?"
  • "Do I double-text [name] a lot?"
  • "Who have I lost touch with?"
<details> <summary><strong>More examples</strong></summary>
  • "Show me the longest silence between me and [name]"
  • "How many messages have I sent this year?"
  • "Show my conversation with Mom"
  • "What time of day am I most active texting?"
  • "Show me messages people unsent"
  • "What are the most popular group chats?"
</details> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/anipotts/imessage-mcp/main/assets/wrapped-dark.png"> <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/anipotts/imessage-mcp/main/assets/wrapped-light.png"> <img src="https://raw.githubusercontent.com/anipotts/imessage-mcp/main/assets/wrapped-dark.png" alt="iMessage Wrapped β€” year-in-review summary" width="100%"> </picture>

Tools

26 tools across 10 categories. All read-only. All annotated with readOnlyHint: true.

ToolDescription
search_messagesFull-text search with filters: query, contact, date range, direction, group chat, attachments
yearly_wrappedSpotify Wrapped for iMessage β€” full year summary
who_initiatesWho starts conversations? Initiation ratio per contact
streaksConsecutive-day messaging streaks
get_reactionsTapback distribution, top reactors, most-reacted messages
on_this_dayMessages from this date in past years
<details> <summary><strong>All 26 tools</strong></summary>
ToolDescription
search_messagesFull-text search with filters: query, contact, date range, direction, group chat, attachments
get_conversationConversation thread with cursor-based pagination
list_contactsAll contacts with message counts and date ranges
get_contactDeep contact info with stats and yearly breakdown
resolve_contactFuzzy-match a name, phone number, or email to a contact
message_statsAggregate stats with time-series grouping
contact_statsPer-contact volumes, trends, and hourly patterns
temporal_heatmap7x24 activity heatmap (day-of-week by hour)
on_this_dayMessages from this date in past years
first_last_messageFirst and last message ever exchanged with a contact
who_initiatesWho starts conversations? Initiation ratio per contact
streaksConsecutive-day messaging streaks
double_textsDetect double-texting and unanswered message patterns
conversation_gapsFind the longest silences in a conversation
forgotten_contactsContacts you've lost touch with
yearly_wrappedSpotify Wrapped for iMessage β€” full year summary
list_group_chatsGroup chats with member counts and activity
get_group_chatPer-member stats and monthly activity timeline
list_attachmentsQuery attachments by contact, MIME type, and date range
get_reactionsTapback distribution, top reactors, most-reacted messages
get_read_receiptsRead/delivery latency and unread patterns
get_threadReconstruct reply thread trees
get_edited_messagesEdited and unsent messages with timing
get_message_effectsSlam, loud, confetti, fireworks analytics
check_new_messagesTrack new messages since your last check (baseline + delta)
helpFull tool guide with usage examples
</details>

CLI Commands

<details> <summary><strong><code>imessage-mcp doctor</code></strong> β€” run setup diagnostics</summary>

Checks macOS version, Node.js version, chat.db access, database permissions, AddressBook, and message count.

Copy & paste β€” that's it
$ npx imessage-mcp doctor

imessage-mcp doctor

  βœ“ macOS: Running on macOS (darwin)
  βœ“ Node.js: Node v22.0.0 (>= 18 required)
  βœ“ chat.db: Found at /Users/you/Library/Messages/chat.db
  βœ“ Database access: Database readable
  βœ“ Messages: 97,432 messages indexed
  βœ“ AddressBook: 342 contacts resolved

All checks passed β€” ready to use!
<picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/anipotts/imessage-mcp/main/assets/doctor-dark.png"> <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/anipotts/imessage-mcp/main/assets/doctor-light.png"> <img src="https://raw.githubusercontent.com/anipotts/imessage-mcp/main/assets/doctor-dark.png" alt="imessage-mcp doctor output" width="100%"> </picture>

Pass --json for machine-readable output:

Copy & paste β€” that's it
npx imessage-mcp doctor --json
</details> <details> <summary><strong><code>imessage-mcp dump</code></strong> β€” export messages or contacts to JSON</summary>
Copy & paste β€” that's it
# Export last 1000 messages
npx imessage-mcp dump > messages.json

# Filter by contact
npx imessage-mcp dump --contact "+15551234567"

# Date range with custom limit
npx imessage-mcp dump --from 2024-01-01 --to 2024-12-31 --limit 5000

# Export contacts (excluding spam/promo by default)
npx imessage-mcp dump --contacts > contacts.json

# Include all contacts (even ones you never replied to)
npx imessage-mcp dump --contacts --all > all-contacts.json

# Export all messages (including unfiltered contacts)
npx imessage-mcp dump --all > all-messages.json
</details>

Transport Modes

By default, imessage-mcp uses stdio transport β€” the standard for local MCP clients like Claude Desktop and Claude Code. For workflow tools (n8n, Lutra, Copilot Studio) or remote access, HTTP transport is available.

FlagShortDefaultDescription
--transport-tstdioTransport mode: stdio, http, or sse
--port-p3000Port for HTTP/SSE transport
--host-H127.0.0.1Bind address (use 0.0.0.0 for Docker/remote)
<details> <summary><strong>Streamable HTTP</strong> (recommended for HTTP)</summary>
Copy & paste β€” that's it
npx imessage-mcp --transport http --port 3000

Starts a Streamable HTTP server on http://127.0.0.1:3000/mcp. Supports POST, GET, and DELETE on /mcp with session management via mcp-session-id headers. This is the MCP 2025-03-26 standard.

</details> <details> <summary><strong>Legacy SSE</strong> (for older clients)</summary>
Copy & paste β€” that's it
npx imessage-mcp --transport sse --port 3000

Starts a legacy SSE server: GET /sse to establish the stream, POST /messages?sessionId=<id> for JSON-RPC requests. Use this only if your client does not support Streamable HTTP.

</details>

Docker

Run imessage-mcp as an HTTP server in Docker. Copy your chat.db to a volume mount:

Copy & paste β€” that's it
docker build -t imessage-mcp .
docker run -p 3000:3000 -v /path/to/chat.db:/data/chat.db:ro imessage-mcp

The container starts with --transport http --host 0.0.0.0 on port 3000 by default. Connect any MCP client to http://localhost:3000/mcp.

To secure the HTTP endpoint with authentication:

Copy & paste β€” that's it
docker run -p 3000:3000 -e IMESSAGE_API_TOKEN=your-secret-token -v /path/to/chat.db:/data/chat.db:ro imessage-mcp

All requests must then include the Authorization: Bearer your-secret-token header.

<details> <summary><strong>Safe Mode</strong> β€” redact all message bodies</summary>

Prevent message bodies from being sent to the AI. Only metadata (counts, dates, contact names) is returned. No actual message text.

Copy & paste β€” that's it
{
  "mcpServers": {
    "imessage": {
      "command": "npx",
      "args": ["-y", "imessage-mcp"],
      "env": { "IMESSAGE_SAFE_MODE": "1" }
    }
  }
}
<picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/anipotts/imessage-mcp/main/assets/safe-mode-dark.png"> <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/anipotts/imessage-mcp/main/assets/safe-mode-light.png"> <img src="https://raw.githubusercontent.com/anipotts/imessage-mcp/main/assets/safe-mode-dark.png" alt="Safe Mode β€” all message bodies redacted" width="100%"> </picture>

Useful for demos, shared environments, or when you want analytics without exposing private conversations.

</details> <details> <summary><strong>Smart Filtering</strong> β€” spam/promo exclusion</summary>

By default, listing and global search tools only include contacts you have actually replied to. This filters out spam, promo texts, and unknown senders.

Filtered tools: search_messages (global), list_contacts, message_stats (global), temporal_heatmap (global), who_initiates (global), streaks (global), on_this_day (global), forgotten_contacts, yearly_wrapped.

Unfiltered tools: get_conversation, get_contact, contact_stats, first_last_message, conversation_gaps, get_reactions, get_read_receipts, get_thread, get_edited_messages, get_message_effects, group chats, attachments, check_new_messages.

To include all contacts (including unrecognized senders), pass include_all: true to any filtered tool.

</details> <details> <summary><strong>Sync & New Messages</strong> β€” real-time notifications</summary>

Looking for iCloud sync? This section covers real-time message tracking within imessage-mcp. To sync your full message history from iPhone/iPad to your Mac, see iCloud Sync & Multiple Devices.

By default, every query reads the latest data β€” if someone texts you, your next tool call sees it immediately. No sync needed.

For proactive awareness, the check_new_messages tool tracks what arrived since your last check:

  1. First call sets a baseline
  2. Subsequent calls report the delta β€” count, who messaged, and optional text previews

For push notifications (opt-in):

Copy & paste β€” that's it
{
  "mcpServers": {
    "imessage": {
      "command": "npx",
      "args": ["-y", "imessage-mcp"],
      "env": { "IMESSAGE_SYNC": "watch" }
    }
  }
}

This watches your iMessage database for changes and notifies your AI client within seconds. Uses macOS FSEvents β€” zero CPU when idle.

</details>

How It Works

imessage-mcp reads ~/Library/Messages/chat.db using better-sqlite3 in read-only mode with query_only = ON. Zero network requests. Contact names are resolved from your macOS AddressBook automatically.

On macOS 14 (Sonoma) and later, Apple changed how message text is stored. Some messages have NULL in the text column but contain the actual text in the attributedBody binary blob. imessage-mcp extracts text from this blob automatically so no messages are left behind.

All 26 tools are annotated with readOnlyHint: true so MCP clients can auto-approve them without user prompts.

part of claude-code-tips

tools i built while living in claude code every day.

  • claude-code-tips Β· practical patterns for agentic coding
  • claudemon Β· real-time session monitor
  • cc Β· cross-session messaging
  • mine Β· session mining to sqlite

more from me

License

MIT