iMessage Query MCP Server

iMessage Query MCP Server

Securely query and analyze your iMessage history with LLMs using the Model Context Protocol.

71
Stars
13
Forks
71
Watchers
3
Issues
iMessage Query MCP Server is an MCP-compliant server that provides safe access to the macOS iMessage database for Large Language Models (LLMs). Built with the FastMCP framework and imessagedb library, it enables querying, validation, and analysis of iMessage conversations, complete with proper phone number handling and permissions management. The tool integrates seamlessly with MCP clients such as Claude Desktop and CLine for VSCode, allowing for controlled retrieval of chat histories via standardized protocols. Enhanced security features and automated dependency management ensure a smooth and safe user experience.

Key Features

Provides standardized MCP interface for iMessage data
Automatic phone number validation and formatting
Secure access to iMessage database with Full Disk Access support
Retrieves message history with date range filtering
Identifies senders and message metadata
Attachment information with missing file detection
Automatic environment and dependency management with uv
Seamless integration with tools like Claude Desktop and CLine for VSCode
macOS permissions automation
Safety features to protect user data

Use Cases

Enabling LLMs to analyze personal or organizational iMessage chats securely
Automating export and review of message transcripts with context filtering
Integrating private communication histories into AI-powered workflows
Building chat summarization or search tools for macOS messages
Validating and cleaning phone numbers in chat datasets
Providing secure and permission-bound access to chat data for research
Auditing and monitoring iMessage conversations in compliance-focused environments
Creating personal data insights dashboards from messaging history
Supporting AI agents that need contextual awareness from user messages
Enabling advanced attachment management and metadata extraction for iMessage conversations

README

MseeP.ai Security Assessment Badge

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.)

📦 Dependencies

Install uv (Required)

This project uses uv for fast, reliable Python package management. Install it first:

bash
# Install uv using Homebrew (recommended)
brew install uv

# Or install using the official installer
curl -LsSf https://astral.sh/uv/install.sh | sh

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:

bash
git clone https://github.com/hannesrudolph/imessage-query-fastmcp-mcp-server.git
cd imessage-query-fastmcp-mcp-server

📦 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

  1. Find your Claude Desktop config file:

    • Location: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Create the file if it doesn't exist
  2. Add the server configuration:

json
{
  "mcpServers": {
    "imessage-query": {
      "command": "/full/path/to/imessage-query-server.py"
    }
  }
}
  1. 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)

  2. Restart Claude Desktop completely (Cmd+Q, then relaunch)

Option 2: Cline VSCode Plugin

To use this server with the Cline VSCode plugin:

  1. In VSCode, click the server icon (☰) in the Cline plugin sidebar
  2. Click the "Edit MCP Settings" button (✎)
  3. Add the following configuration to the settings file:
json
{
  "imessage-query": {
    "command": "/full/path/to/imessage-query-server.py"
  }
}
  1. 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:

/full/path/to/imessage-query-server.py

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:

  1. Detect your MCP client (Claude Desktop, Cursor, VS Code, etc.)
  2. Check for Full Disk Access permission
  3. Automatically open System Preferences to the correct settings panel
  4. Provide step-by-step instructions specific to your application

Manual Permission Setup

If automatic detection doesn't work, follow these steps:

  1. Open System PreferencesPrivacy & SecurityFull Disk Access
  2. Click the lock icon and enter your password to make changes
  3. Click the '+' button to add an application
  4. Navigate to and select your MCP client:
    • Claude Desktop: /Applications/Claude.app
    • Cursor: /Applications/Cursor.app
    • VS Code: /Applications/Visual Studio Code.app
  5. 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 capabilities
  • dev_docs/fastmcp-documentation.txt: FastMCP framework details and MCP tool development
  • dev_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
SQLITE_DB_PATH Custom path to iMessage database ~/Library/Messages/chat.db

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:

bash
export SQLITE_DB_PATH="/path/to/custom/chat.db"

Testing the Server

Test the server directly using mcptools (github.com/f/mcptools):

bash
# Navigate to the repository directory
cd /path/to/imessage-query-fastmcp-mcp-server

# List available tools
mcp tools ./imessage-query-server.py

# Test a tool call
mcp call get_chat_transcript ./imessage-query-server.py -p '{"phone_number": "+1234567890"}'

The script will automatically handle dependency installation via uv when first run.

🐛 Troubleshooting

Common Error Messages

"❌ Full Disk Access permission required"

"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:

  1. Check the error message for specific guidance
  2. Ensure your MCP client has Full Disk Access permission
  3. Verify the Messages app has been used and iMessage is enabled
  4. Try testing the server directly with mcptools (see Advanced Usage)

Star History

Star History Chart

Repository Owner

Repository Details

Language Python
Default Branch main
Size 126 KB
Contributors 3
MCP Verified Nov 11, 2025

Programming Languages

Python
100%

Tags

Topics

llm mcp mcp-server

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • iMessage MCP

    iMessage MCP

    MCP server enabling LLM integration with macOS iMessage data.

    iMessage MCP offers a Model Context Protocol (MCP) server that facilitates seamless integration between large language models (LLMs) and macOS iMessage data. It provides robust tools for searching and managing iMessage messages, conversations, and contacts in a read-only manner. Features include message and contact search, chat listing, and context retrieval, making it suitable for conversational agents and context-aware applications. Built using Deno and designed for easy integration with applications such as Claude Desktop, it handles context management efficiently for AI models.

    • 16
    • MCP
    • wyattjoh/imessage-mcp
  • MCP Server for Iaptic

    MCP Server for Iaptic

    A Model Context Protocol server for accessing and managing Iaptic data with AI agents.

    MCP Server for Iaptic implements the Model Context Protocol to enable AI models, such as Claude, to securely and efficiently interact with Iaptic's customer, purchase, transaction, and statistics data. The server provides a standardized interface and command set for querying and managing information related to customers, purchases, transactions, events, and application management. Designed for integration with Claude Desktop and similar AI clients, it offers both automated and manual installation options.

    • 5
    • MCP
    • iaptic/mcp-server-iaptic
  • WhatsApp MCP Server

    WhatsApp MCP Server

    Bridge WhatsApp messaging to Model Context Protocol-compliant LLM agents.

    WhatsApp MCP Server enables users to access, search, and interact with their personal WhatsApp messages through the Model Context Protocol. It connects to WhatsApp via the WhatsApp web multidevice API, stores messages locally in a SQLite database, and exposes them as tools to LLM-powered agents like Claude. Users can also send messages, media, and search contacts, all while retaining control over what is shared with the AI agent.

    • 5,056
    • MCP
    • lharries/whatsapp-mcp
  • SQLite Explorer MCP Server

    SQLite Explorer MCP Server

    Secure, read-only access to SQLite databases for LLMs via the Model Context Protocol.

    SQLite Explorer MCP Server provides a safe, read-only interface to SQLite databases using the Model Context Protocol (MCP). Built with the FastMCP framework, it enables large language models to explore, query, and retrieve database schema information with robust safety and validation mechanisms. The server exposes structured tools such as read_query, list_tables, and describe_table, ensuring secure and reliable access to database contents. Designed for integration with platforms like Claude Desktop and Cline VSCode Plugin.

    • 93
    • MCP
    • hannesrudolph/sqlite-explorer-fastmcp-mcp-server
  • Slack MCP Server

    Slack MCP Server

    A feature-rich Model Context Protocol server for integrating Slack Workspaces with AI model context management.

    Slack MCP Server acts as a Model Context Protocol (MCP) server tailored for Slack Workspaces, providing flexible integration modes including Stealth and OAuth. It enables advanced functionalities such as fetching channel and thread messages, supporting direct and group messages, smart history retrieval, and robust context management for AI workflows. Communication is supported over Stdio, SSE, and HTTP transports, and the platform includes enhanced features like user information embedding and cache support. Designed for enterprise and individual use, it allows seamless context extraction and management without compromising workspace security.

    • 903
    • MCP
    • korotovsky/slack-mcp-server
  • BigQuery MCP Server

    BigQuery MCP Server

    Enables LLMs to securely converse with BigQuery data using natural language.

    BigQuery MCP Server acts as a bridge between large language models and Google BigQuery, allowing natural language interactions with database data through the Model Context Protocol. Designed for integration with Claude Desktop, it securely processes user queries and translates them into SQL, streamlining data access and minimizing manual query writing. The tool ensures safe and read-only data operations, supports both tables and materialized views, and labels resource types for easier exploration. Installation is possible via Smithery or manual setup, with a focus on developer-friendliness and robust authentication options.

    • 129
    • MCP
    • ergut/mcp-bigquery-server
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results