Enables querying iMessage history, listing conversations, searching messages, getting message context, and sending messages to existing conversations on macOS through the local Messages.app database.
Uses OpenAI embeddings API for semantic search capabilities to find conceptually similar messages in iMessage history, complementing keyword-based search.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g.,@jons-mcp-imessage what is the weather in Tokyo?
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
You can also use deployed servers via HTTP endpoints. For instructions, see How to Test MCP Streamable HTTP Endpoints Using cURL.
jons-mcp-imessage
A local MCP server for querying and sending iMessages on macOS.
This FastMCP server exposes tools through the Model Context Protocol (MCP), enabling AI assistants to read your iMessage history and send messages.
Requirements
macOS (tested on Tahoe 26.x, should work on recent versions)
Python 3.10+
Messages.app (for sending messages)
Permissions Required
This server requires specific macOS permissions to function. Permission issues are the most common cause of problems.
Full Disk Access (Required for Reading Messages)
The application running this server needs Full Disk Access to read ~/Library/Messages/chat.db.
To grant Full Disk Access:
Open System Settings (or System Preferences on older macOS)
Navigate to Privacy & Security → Full Disk Access
Click the lock icon and authenticate if needed
Click the + button
Add the appropriate application:
If using Claude Desktop: Add
Claude.app(usually in /Applications)If running from terminal: Add your terminal app (e.g.,
Terminal.app,iTerm.app,Zed.app)If running via another app: Add that specific application
Restart the application after granting access
How to verify: Run check_permissions tool - it will report whether database access is working.
Automation Permission (Required for Sending Messages)
To send messages via AppleScript, the application needs permission to control Messages.app.
This permission is prompted automatically the first time you try to send a message. Click "OK" to allow.
To manually grant or verify:
Open System Settings → Privacy & Security → Automation
Find your application (Terminal, Claude Desktop, etc.)
Ensure Messages is checked
Contacts Permission (Optional - For Contact Name Enrichment)
The server can enrich message responses with contact names from your Contacts app. This is optional - all features work without it, but you'll see phone numbers/emails instead of names.
To enable contact name enrichment:
Open System Settings (or System Preferences on older macOS)
Navigate to Privacy & Security → Contacts
Click the lock icon and authenticate if needed
Click the + button
Add the appropriate application:
If using Claude Desktop: Add
Claude.app(usually in /Applications)If running from terminal: Add your terminal app (e.g.,
Terminal.app,iTerm.app)
Restart the application after granting access
What you get with Contacts permission:
Message responses include
contact_namefield (e.g., "John Smith" instead of just "+15551234567")Conversation responses include
participant_namesfieldlookup_contacttool becomes available for explicit contact lookups
Without Contacts permission:
Contact name fields will be
nulllookup_contactreturns an error messageAll other functionality works normally (graceful degradation)
Installation
Running the Server
Adding to Claude Code
Adding to Claude Desktop
Add the following to your Claude Desktop configuration file:
Location: ~/Library/Application Support/Claude/claude_desktop_config.json
Notes:
Replace
/path/to/jons-mcp-imessagewith the actual path to this repositoryReplace
sk-your-openai-api-keywith your OpenAI API key (required for semantic search)If you don't have an OpenAI key, omit the
envsection entirely - keyword search will still workRestart Claude Desktop after modifying the config
Search Features
The search system combines two powerful search methods:
Keyword Search (FTS5)
Full-text search using SQLite FTS5 with BM25 ranking. Supports:
Phrase search:
"exact phrase"Prefix matching:
word*Proximity:
word1 NEAR word2Boolean:
word1 AND word2,word1 OR word2,NOT word
Semantic Search
AI-powered search using OpenAI embeddings to find conceptually similar messages, even when exact keywords don't match.
Setup
Basic Setup (keyword search only): Works out of the box
Full Setup (hybrid search): Set your OpenAI API key:
export OPENAI_API_KEY=your-api-key
Search Modes
hybrid(default): Combines keyword + semantic results using RRFkeyword: FTS5 only (no API key needed)semantic: Embedding similarity only (requires API key)
Index Management
The search index is stored separately from iMessage's chat.db at:
~/.local/share/jons-mcp-imessage/search_index.db
Tools available:
search_index_status- Check index health and sync statusrebuild_search_index- Full reindex (use if issues occur)
Troubleshooting
Issue | Solution |
"No results found" | Check if index is synced with |
Semantic search not working | Verify |
Slow first search | Index is building in background, try again shortly |
Stale results | chat.db may be locked by Messages app |
Available Tools
Reading Messages
Tool | Description |
| Verify database access and diagnose permission issues |
| List all conversations with metadata (participants, last message, etc.) |
| Get messages from a specific conversation by contact or chat_id |
| Get recent messages across all conversations |
| Get messages before/after a specific message in the same thread |
| Search messages by text content with optional filters |
| Search for contacts/handles by phone number or email in iMessage database |
| Look up contact name from Contacts app by phone/email (requires Contacts permission) |
Sending Messages
Tool | Description |
| Send a message to an existing conversation |
send_message Limitations
Important: The send_message tool has significant limitations:
Existing conversations only: Can only send to contacts you have previously messaged. New contacts require starting a conversation manually in Messages.app first.
No delivery confirmation: The tool reports success when the message is handed to Messages.app, but cannot confirm actual delivery. Messages may silently fail if:
The recipient has blocked you
The phone number/email is invalid
Network issues occur
Messages.app must be running: If Messages.app is not running, the tool will fail with a "Messages not running" error.
Service detection: By default, attempts iMessage first. Use
service="SMS"to force SMS for non-iMessage contacts.
Example Usage
Troubleshooting
"Permission denied" or "Unable to read database"
Cause: Full Disk Access not granted.
Fix: Follow the Full Disk Access instructions above. Make sure to:
Grant access to the correct application (the one actually running the server)
Restart the application after granting access
"Messages not running (-600)"
Cause: Messages.app is not running.
Fix: Open Messages.app before sending messages.
"Not allowed to send Apple events (-1743)"
Cause: Automation permission not granted.
Fix:
Go to System Settings → Privacy & Security → Automation
Find your application and enable Messages access
If not listed, try sending a message again to trigger the permission prompt
"Can't get buddy id" or "existing conversations only"
Cause: Trying to message a contact you haven't messaged before.
Fix: Start a conversation with this contact manually in Messages.app first, then try again.
Messages appear empty or "(non-text message)"
Cause: The message contains only attachments (images, videos) or is a system message (like "renamed the group").
Note: This is expected behavior. The server extracts text content only.
Privacy Considerations
This server accesses your local iMessage database and optionally your Contacts database. Be aware that:
All message history is accessible: The server can read all messages stored locally
Contact information is exposed: Phone numbers and email addresses are visible
Attachments are referenced: File paths to attachments (photos, videos) are included
No cloud access: Only locally-stored messages are accessible (not messages only on iCloud)
Contact Name Privacy
If you grant Contacts permission:
Contact names come from YOUR Contacts app: The server reads your personal contact list to enrich message responses
Names are NOT stored: Contact names are resolved at query time and are NOT stored in any database or search index
Names are cached in-memory only: The server loads all contacts into memory on first use, cache is cleared on restart
All Contacts databases are read: Includes main Contacts DB plus any per-source databases (iCloud, CardDAV, etc.)
Use appropriate caution when granting AI assistants access to this server.
Development
Setup
Running Tests
Code Quality
Project Structure
License
MIT