Skip to main content
Glama
cannavis

imessage-rich-search

by cannavis

imessage-rich-search

Full-text search across macOS iMessages — including the link preview metadata (titles, summaries, site names) that Messages.app indexes but the raw chat.db text column never exposes.

License: MIT Python 3.9+ Platform: macOS No deps MCP

The problem this solves

When you paste a URL into iMessage, macOS fetches a rich preview — title, summary, site name, hero image — and stores that metadata in chat.db as an NSKeyedArchiver blob in message.payload_data. Messages.app's search bar reads it. The raw chat.db text column does not.

So if a friend sent https://x.com/foo/status/123 and the preview card said "Obsidian + Claude Code is the most underrated productivity stack" — searching for "obsidian" in any tool that only reads text returns zero results. Messages.app finds it. This tool finds it. They search the same surface.

Related MCP server: imessage-mcp

What it is — and isn't

Is: A read-only, local search over your chat.db. ~200 lines of stdlib Python. Zero runtime dependencies. CLI + optional MCP server for Claude Desktop.

Isn't: A Messages replacement (no UI, no send/edit/delete). A way to access anyone else's messages. An iCloud sync tool — searches only what's locally on this Mac. An OCR / image / audio / sticker reader. A bypass for Full Disk Access — you must grant it explicitly.

Requirements

OS

macOS 11 Big Sur or newer (tested through macOS 26)

Architecture

Apple Silicon (arm64) or Intel (x86_64)

Python

Apple's system /usr/bin/python3 (3.9, ships with Xcode Command Line Tools) — required, see Why Apple's Python

Permissions

One specific Full Disk Access grant — see Step 2

Disk

~30 KB code + ~15 MB venv

If you don't have Command Line Tools, run xcode-select --install first.

Install

Step 1 — Run the installer (one command)

curl -fsSL https://raw.githubusercontent.com/cannavis/imessage-rich-search/main/install.sh | bash

What this does, in plain English:

  1. Verifies you're on macOS with Command Line Tools.

  2. Creates a virtual environment at ~/.local/share/imessage-rich-search against Apple's system Python 3.9.

  3. Pulls and installs this package from GitHub into that venv.

  4. Symlinks three commands into ~/.local/bin: imessage-rich-search, imrs (alias), imessage-rich-search-mcp.

If you'd rather not pipe curl into bash, do it manually:

/usr/bin/python3 -m venv ~/.local/share/imessage-rich-search
~/.local/share/imessage-rich-search/bin/pip install --upgrade pip
~/.local/share/imessage-rich-search/bin/pip install "git+https://github.com/cannavis/imessage-rich-search@v0.2.1"
mkdir -p ~/.local/bin
for exe in imessage-rich-search imrs imessage-rich-search-mcp; do
  ln -sf ~/.local/share/imessage-rich-search/bin/$exe ~/.local/bin/$exe
done

The CLI works immediately after this:

~/.local/bin/imrs "obsidian" --limit 3

If your shell can't find imrs, add ~/.local/bin to your PATH:

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && exec zsh

Step 2 — Grant Full Disk Access to Apple's Python 3.9

You must add this exact path to FDA, or the MCP server (and any disclaimed call into chat.db) will fail with authorization denied. This step does not affect the CLI when run from your own terminal.

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

  2. Click the + button.

  3. In the file picker, press ⌘ + Shift + G (Go to Folder).

  4. Paste this path exactly:

    /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin
  5. Hit Return — you'll see the contents of that bin folder.

  6. Select python3.9 (not python3, which is a symlink).

  7. Click Open. It appears in the list as python3.9.

  8. Make sure the toggle is ON. Authenticate if prompted.

Step 3 — Wire the MCP server into Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json and merge this in (preserve any existing keys):

{
  "mcpServers": {
    "imessage-rich-search": {
      "command": "/Users/YOUR_USERNAME/.local/bin/imessage-rich-search-mcp"
    }
  }
}

Replace YOUR_USERNAME with your actual username (whoami will tell you).

Step 4 — Restart Claude Desktop

⌘Q (full quit — not just close-window) and relaunch. New chats will have a search_imessages_rich tool.

Verify it works

CLI:

imrs "obsidian" --limit 3
# 3 match(es) for 'obsidian':
# [2026-04-08T22:56:23+00:00] -> +1XXXXXXXXXX  (rowid=...)
#   * preview: Claude Code + Obsidian Ultimate Guide (build an AI second brain)

MCP server (manual JSON-RPC handshake — same path Claude Desktop uses):

(printf '%s\n%s\n' \
  '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"0"}}}' \
  '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"search_imessages_rich","arguments":{"query":"obsidian","limit":1}}}') \
| /Applications/Claude.app/Contents/Helpers/disclaimer ~/.local/bin/imessage-rich-search-mcp

You should see two JSON-RPC responses. If the second one contains "isError": true and "authorization denied", Step 2 (FDA grant) was missed or the toggle is off.

Usage

imrs "obsidian"                                  # search all conversations
imrs "obsidian" --contact "+14073993471"         # restrict to one handle
imrs "claude code" --json | jq '.[].preview[0]'  # JSON for piping
imrs "obsidian" --limit 20 --db /backup/chat.db  # backup file
imessage-rich-search --help                      # full options

Output legend: -> sent · <- received · * preview hit · rowid cross-references back into chat.db.

Claude Desktop (MCP server)

Once Steps 1–4 above are done, Claude can call this tool directly:

search_imessages_rich(query, contact?, limit?)
  • query — case-insensitive substring (required)

  • contact — optional handle filter, e.g. "+14073993471" or "name@example.com"

  • limit — max matches, default 50

Returns newest-first matches with body, decoded preview metadata, handle, date, and rowid.

Why Apple's Python

This isn't arbitrary — it's the only thing that works inside Claude Desktop, and there's a clear reason:

Claude Desktop spawns MCP servers through /Applications/Claude.app/Contents/Helpers/disclaimer, a tiny wrapper that calls responsibility_spawnattrs_setdisclaim(). This is an Apple API that deliberately breaks the TCC responsibility chain so the MCP server is treated as its own responsible process. The intent: prevent third-party MCP servers from silently inheriting Claude.app's broad permissions.

Consequence: the spawned binary needs its own Full Disk Access grant — Claude.app's grant doesn't propagate. macOS resolves the venv's python3 to its canonical Apple binary at /Library/Developer/CommandLineTools/.../python3.9, and that's the path TCC checks. Hence Step 2.

If you install with Homebrew Python or pyenv instead, the canonical path resolves somewhere else and TCC blocks the request. Apple's CLT Python is the path of least resistance.

References:

How it works

chat.db (SQLite, opened with mode=ro)
  └─ message
       ├─ text                 ← raw text (what basic tools see)
       ├─ payload_data  BLOB   ← NSKeyedArchiver bplist of LPLinkMetadata
       │                         (title, summary, site, image refs)
       └─ balloon_bundle_id    ← e.g. com.apple.messages.URLBalloonProvider

For every row matching the contact filter:
  1. Read text + payload_data
  2. plistlib.loads(payload_data) → walk $objects → collect strings
  3. haystack = (text + '\n'.join(preview_strings)).lower()
  4. Match if query.lower() in haystack

Walking strings out of $objects avoids needing ccl_bplist, pyobjc, or full NSKeyedUnarchiver — for full-text search the leaf strings are all that matter.

Privacy & security

  • Read-only. Opens chat.db with SQLite URI flag mode=ro.

  • Local-only. No network calls. (grep -r 'urllib\|requests\|http\|socket' src/ returns nothing.)

  • No telemetry.

  • Zero runtime dependencies — nothing to be supply-chain-attacked through.

  • The FDA grant from Step 2 applies to Apple's system Python 3.9 system-wide. If you have Terminal, bash, or Visual Studio Code already in FDA, this isn't expanding your attack surface — those can already trivially shell out to /usr/bin/python3.

See SECURITY.md for vulnerability reporting.

Limitations

  • Substring match only. No FTS5, regex, or boolean operators. (Roadmap.)

  • Local DB only. If a message lives only in iCloud and isn't synced to this Mac's chat.db, this tool won't see it.

  • Preview metadata depends on Messages.app having fetched it. If a link card never loaded (offline send, expired URL), there's no payload_data to search.

  • String extraction is lossy by design. Image MIME types, dimension tuples like {0, 0}, and profile-image URLs may appear in raw output. They don't affect search hits.

Troubleshooting

Symptom

Fix

imrs: command not found

Add ~/.local/bin to PATH: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && exec zsh

unable to open database file from CLI in your terminal

Add your terminal app to FDA: System Settings → Privacy & Security → Full Disk Access. ⌘Q + relaunch the terminal.

authorization denied from Claude Desktop's MCP call (CLI works fine)

Step 2 is missing or toggled off. Verify python3.9 is in FDA list with toggle ON. ⌘Q + relaunch Claude Desktop.

Claude Desktop doesn't see the tool at all

Validate JSON: python3 -c "import json; json.load(open('$HOME/Library/Application Support/Claude/claude_desktop_config.json'))". Then ⌘Q + relaunch.

Returns 0 matches but Messages.app finds them

Wrong --contact format. Drop --contact to confirm. Phone numbers must be E.164: +14155551212.

Apple's Python 3.9 isn't at the expected path

xcode-select -p to verify CLT is installed. If installed but path differs (e.g., full Xcode), find it: xcrun --find python3

Search slow on huge DBs

Linear scan + bplist parse per row. ~100k message DBs take a few seconds. FTS5 index is roadmap.

Verify the TCC grant directly

If unsure whether Step 2 took effect, watch the system log while making a request:

log stream --predicate 'process == "tccd"' --info | grep -E "python3\.9|chat\.db|SystemPolicyAllFiles"

You want to see Auth Right: Allowed (System Set) for the python3.9 binary. Denied (Service Policy) means the grant isn't in place.

Contributing

See CONTRIBUTING.md. Issues and PRs welcome. Don't paste real chat content into public issues — redact phone numbers, names, and message text first.

Changelog

See CHANGELOG.md.

License

MIT — see LICENSE.

Available Tools

1 tool
search_imessages_richA

Full-text search across macOS iMessages including link preview metadata (title, summary, site name) that Apple stores in payload_data — content the basic chat.db text column does not expose. Returns newest-first matches where the query (case-insensitive substring) appears in either the message body OR the rich link preview.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesSubstring to search for (case-insensitive).
contactNoOptional handle filter, e.g. '+14073993471' or 'name@example.com'.
limitNoMax matches to return (default 50).

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, description carries full burden. Discloses search over message body and rich link preview, case-insensitive substring matching, and newest-first sorting. Could add more on returns (empty results, pagination) but covers key behavioral traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with purpose, no superfluous words. Each sentence adds value: first defines scope, second details ordering and search targets.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema, so description should cover return structure. It mentions 'newest-first matches' but does not describe fields (e.g., message text, sender, timestamp, preview metadata). Agent may need to infer or handle uncertainly. Lacks completeness for a search tool without output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema descriptions cover 100% of parameters, but description adds operational context: query searches both body and preview, contact is an optional handle filter, and limit default/max. Adds meaning beyond schema fields.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it performs full-text search across macOS iMessages, including link preview metadata beyond basic chat.db. Specifies scope, search scope (body or preview), and result ordering (newest-first). Distinguishes from potential siblings by highlighting the rich link preview capability.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides context that this tool searches rich link preview metadata not exposed by basic chat.db, implying its niche. However, it does not explicitly state when not to use it or mention alternatives. Still clear enough for an agent to infer appropriate scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.3/5.0
Disambiguation5/5

Only one tool exists, so there is no possibility of confusion or ambiguity between tools.

Naming Consistency5/5

With a single tool, naming consistency is perfect; the name 'search_imessages_rich' is descriptive and follows a clear verb_noun pattern.

Tool Count3/5

A single tool feels thin for a server named 'imessage-rich-search', as it likely covers only a narrow part of iMessage interaction. While the tool is focused, users may expect additional functionality like retrieving messages or managing conversations.

Completeness4/5

The tool thoroughly performs the described search across both message text and rich link previews, but lacks complementary operations such as fetching individual messages or performing more advanced queries, which are minor gaps.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    A local MCP server that enables reading iMessage conversations and sending new messages through Claude Desktop. It provides secure, read-only access to your Mac's iMessage database and AppleScript-based message sending capabilities.
    6
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    A read-only MCP server that exposes your iMessage data to Claude Code and Claude Desktop, with automatic contact name resolution.
    3
  • -
    license
    Not graded
    quality
    Not graded
    maintenance
    Read, search, and send iMessages locally from your terminal or through MCP clients like Claude, Cursor, and VS Code.
  • A
    license
    Not graded
    quality
    C
    maintenance
    macOS-only MCP server that exposes iMessage history to Claude and exports per-chat conversations into an Obsidian vault.
    2
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cannavis/imessage-rich-search'

If you have feedback or need assistance with the MCP directory API, please join our Discord server