Provides read-only access to the macOS iMessage database, allowing queries of message history with specific phone numbers, including message text, timestamps, and attachment information with support for date range filtering.
Leverages macOS-specific features to access the local iMessage database, enabling search and retrieval of message content while maintaining proper phone number validation and safe attachment handling.
iMessage Query MCP Server
An MCP server that provides safe access to your iMessage database through Model Context Protocol (MCP). This server is built with the FastMCP framework and the imessagedb library, enabling LLMs to query and analyze iMessage conversations with proper phone number validation and automatic macOS permission handling.
π System Requirements
macOS (required for iMessage database access)
Python 3.12+ (required for modern type hints)
uv (modern Python package manager)
Full Disk Access permission for your MCP client (Claude Desktop, Cursor, VS Code, etc.)
Related MCP server: MySQL MCP Server
π¦ Dependencies
Install uv (Required)
This project uses uv for fast, reliable Python package management. Install it first:
Python Dependencies
The script automatically manages its dependencies using the embedded metadata. No separate installation needed! Dependencies include:
fastmcp: Framework for building Model Context Protocol servers
imessagedb: Python library for accessing and querying the macOS Messages database
phonenumbers: Google's phone number handling library for proper number validation and formatting
All dependencies are automatically installed when the script runs via uv.
π Table of Contents
π οΈ MCP Tools
The server exposes the following tools to LLMs:
get_chat_transcript
Retrieve message history for a specific phone number with optional date filtering.
Parameters:
phone_number(required): Phone number in any format (E.164 format preferred)start_date(optional): Start date in ISO format (YYYY-MM-DD)end_date(optional): End date in ISO format (YYYY-MM-DD)
Features:
Automatic phone number validation and formatting
Message text and timestamps
Attachment information with missing file detection
Date range filtering (defaults to last 7 days if no dates specified)
Sender identification (is_from_me flag)
π Getting Started
Clone the repository:
π¦ Installation Options
You can install this MCP server in Claude Desktop, Cline VSCode plugin, or any other MCP client. Choose the option that best suits your needs.
Option 1: Claude Desktop
Find your Claude Desktop config file:
Location:
~/Library/Application Support/Claude/claude_desktop_config.jsonCreate the file if it doesn't exist
Add the server configuration:
Replace the path with the full path to your cloned repository (e.g.,
/Users/username/Projects/imessage-query-fastmcp-mcp-server/imessage-query-server.py)Restart Claude Desktop completely (Cmd+Q, then relaunch)
Option 2: Cline VSCode Plugin
To use this server with the Cline VSCode plugin:
In VSCode, click the server icon (β°) in the Cline plugin sidebar
Click the "Edit MCP Settings" button (β)
Add the following configuration to the settings file:
Replace the path with the full path to your cloned repository
Option 3: Other MCP Clients
For other MCP clients, use the direct script path as the command:
The script's shebang (#!/usr/bin/env -S uv run --script) handles dependency management automatically.
Note: This simplified configuration replaces the previous FastMCP installation method. The script is now self-contained and manages its own dependencies through
uv.
π macOS Permissions Setup
This server requires Full Disk Access permission to read the iMessage database. The server includes intelligent permission detection and will guide you through the setup process.
Automatic Permission Detection
When you first use the server, it will:
Detect your MCP client (Claude Desktop, Cursor, VS Code, etc.)
Check for Full Disk Access permission
Automatically open System Preferences to the correct settings panel
Provide step-by-step instructions specific to your application
Manual Permission Setup
If automatic detection doesn't work, follow these steps:
Open System Preferences β Privacy & Security β Full Disk Access
Click the lock icon and enter your password to make changes
Click the '+' button to add an application
Navigate to and select your MCP client:
Claude Desktop:
/Applications/Claude.appCursor:
/Applications/Cursor.appVS Code:
/Applications/Visual Studio Code.app
Restart your MCP client completely (Cmd+Q, then relaunch)
Common Issues
Permission denied errors: Make sure you've restarted your MCP client after granting permission
"uv" instead of app name: The server will auto-detect your actual MCP client and provide correct instructions
Database not found: Ensure you've used the Messages app and iMessage is enabled
Security Note
This server only requires read access to your iMessage database. It cannot modify, delete, or send messages.
π Safety Features
Read-only access to the iMessage database (cannot modify, delete, or send messages)
Phone number validation using Google's phonenumbers library with proper E.164 formatting
Safe attachment handling with missing file detection and metadata extraction
Date range validation to prevent invalid queries
Progress output suppression for clean JSON responses in MCP protocol
Intelligent permission detection with automatic System Preferences navigation
MCP client identification for accurate permission guidance
π Development Documentation
The repository includes comprehensive documentation for development:
dev_docs/imessagedb-documentation.txt: Complete documentation about the iMessage database structure and the imessagedb library's capabilitiesdev_docs/fastmcp-documentation.txt: FastMCP framework details and MCP tool developmentdev_docs/mcp-documentation.txt: Model Context Protocol specification
This documentation serves as context when developing features and can be used with LLMs to assist in development.
βοΈ Environment Variables
Variable | Description | Default |
| Custom path to iMessage database |
|
The server automatically locates the iMessage database in the default macOS location. The environment variable is only needed for custom database locations.
π§ Advanced Usage
Custom Database Path
If you need to use a custom database path:
Testing the Server
Test the server directly using mcptools (github.com/f/mcptools):
The script will automatically handle dependency installation via uv when first run.
π Troubleshooting
Common Error Messages
"β Full Disk Access permission required"
Follow the macOS Permissions Setup section
Ensure you've restarted your MCP client after granting permission
"Messages database not found"
Make sure you've used the Messages app at least once
Verify iMessage is enabled in Messages preferences
"Invalid phone number"
Phone numbers are validated using Google's phonenumbers library
Try using E.164 format (e.g., "+1234567890")
US numbers without country code will be assumed to be US numbers
Getting Help
If you encounter issues:
Check the error message for specific guidance
Ensure your MCP client has Full Disk Access permission
Verify the Messages app has been used and iMessage is enabled
Try testing the server directly with mcptools (see Advanced Usage)