mac_messages_mcp

作者 carterlasalle已验证

An MCP server that securely interfaces with your iMessage database via the Model Context Protocol (MCP), allowing LLMs to query and analyze iMessage conversations. It includes robust phone number validation, attachment processing, contact management, group chat handling, and full support for sending and receiving messages.

318
Stars
49
Forks
Python
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/carterlasalle/mac_messages_mcp

快速入门

使用 mac_messages_mcp 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

Mac Messages MCP

Use Claude, Codex, Cursor, VS Code, or any local MCP client to search, read, and send messages through the macOS Messages app.

PyPI Python CI Downloads License: MIT

Mac Messages MCP runs locally on your Mac. It opens the Messages and Contacts databases read-only, returns only the data a client asks for, and uses Messages.app automation only when the client explicitly calls the send tool.

[!IMPORTANT] This server is macOS-only. Reading messages requires Full Disk Access. Sending requires a Mac signed into Messages plus permission for the launching app to automate Messages.

What it can do

  • Read recent messages across all conversations or filter by contact or group chat
  • Fuzzy-search message text across a time window, including all available history
  • Find Contacts by approximate name and return send-ready phone numbers
  • List named group chats and use their chat IDs for reads or sends
  • Send iMessage, with SMS/RCS fallback for eligible phone recipients
  • Check whether a recipient appears reachable through iMessage before sending
  • Find attachments by date, sender, and MIME type
  • Return small images inline, convert HEIC images to PNG, or return a local path for larger and non-image files
  • Diagnose Messages and Contacts database permissions from inside the MCP client

Quick start

1. Install uv

brew install uv

Confirm that the launcher is available:

uvx --version

Python 3.10 or newer is required. uvx can provision a compatible Python and installs Mac Messages MCP in an isolated environment, so you do not need to create a virtual environment first.

2. Grant macOS permissions

Open System Settings → Privacy & Security → Full Disk Access and enable the app that will launch the MCP server:

  • Claude Desktop, Cursor, VS Code, or the ChatGPT desktop app when configured in that app
  • Terminal, iTerm2, Ghostty, or another terminal when using Claude Code or Codex CLI from that terminal

Quit and reopen the app after changing Full Disk Access. On the first contact lookup or send, macOS may separately ask for access to Contacts or permission to control Messages. Allow those prompts.

Also make sure Messages.app is open, signed in, and already able to send a normal message.

3. Add the server to your MCP client

The server command is the same everywhere:

uvx mac-messages-mcp

Choose your client below.

Claude Desktop

Open Claude → Settings → Developer → Edit Config, then add:

{
  "mcpServers": {
    "mac-messages": {
      "command": "uvx",
      "args": ["mac-messages-mcp"]
    }
  }
}

Preserve any other servers already in claude_desktop_config.json, save the file, and restart Claude Desktop.

Claude Desktop also supports installable .mcpb extensions. See Build the Claude Desktop extension if you want to package this repository as one.

Claude Code

Add it once at user scope so it is available in every project:

claude mcp add --transport stdio --scope user mac-messages -- uvx mac-messages-mcp

Verify it:

claude mcp get mac-messages

Inside Claude Code, run /mcp to inspect the connection and tools.

Codex CLI, Codex IDE extension, and ChatGPT desktop app

Codex clients on the same Mac share MCP configuration. Add the server with:

codex mcp add mac-messages -- uvx mac-messages-mcp

Then verify it:

codex mcp list

You can also add it directly to ~/.codex/config.toml:

[mcp_servers.mac-messages]
command = "uvx"
args = ["mac-messages-mcp"]

Restart the desktop app or IDE extension after changing the configuration. In Codex CLI, use /mcp to view the active server.

Cursor

Install MCP Server

Or open Cursor Settings → Tools & MCP → New MCP Server and use:

{
  "mcpServers": {
    "mac-messages": {
      "command": "uvx",
      "args": ["mac-messages-mcp"]
    }
  }
}

Restart the server from Cursor's MCP settings after saving.

VS Code / GitHub Copilot

Open the Command Palette and run MCP: Add Server. Choose Command (stdio), enter uvx as the command, add mac-messages-mcp as the argument, and install it globally.

Or add it from a terminal:

code --add-mcp '{"name":"mac-messages","command":"uvx","args":["mac-messages-mcp"]}'

The equivalent user or workspace mcp.json entry is:

{
  "servers": {
    "mac-messages": {
      "type": "stdio",
      "command": "uvx",
      "args": ["mac-messages-mcp"]
    }
  }
}

[!NOTE] VS Code uses a top-level servers object. Claude Desktop and Cursor use mcpServers.

Other stdio MCP clients

Use this generic server definition:

{
  "command": "uvx",
  "args": ["mac-messages-mcp"]
}

If a GUI client reports that uvx cannot be found, run which uvx in Terminal and replace "uvx" with the returned absolute path. Homebrew commonly installs it at /opt/homebrew/bin/uvx on Apple silicon and /usr/local/bin/uvx on Intel Macs.

4. Verify the connection

Ask your client to call tool_check_db_access, then tool_check_addressbook. Once both succeed, try prompts such as:

Show me my messages from the last two hours.
Find messages from Carter about dinner in the last 30 days.
Find PDFs sent to me this month, but do not open any yet.
Find Jordan in my contacts and draft a message saying I am running 10 minutes
late. Do not send it until I confirm.

The first uvx launch can take longer while it downloads and caches Python dependencies.

Available tools

ToolPurposeSide effect
tool_get_recent_messagesRead recent messages, optionally filtered by contact or group chat IDRead-only
tool_fuzzy_search_messagesSearch message bodies by approximate text match; defaults to 30 days, or use hours=0 for all historyRead-only
tool_find_contactFuzzy-match a name in Contacts and return phone numbersRead-only
tool_get_chatsList named group chats and their identifiersRead-only
tool_search_attachmentsFind attachment metadata by date, contact, MIME type, and limitRead-only
tool_get_attachmentFetch one attachment by ID, inline when supported or as a local pathRead-only
tool_check_imessage_availabilityCheck likely iMessage availability for a phone number or emailRead-only
tool_check_db_accessDiagnose access to ~/Library/Messages/chat.dbRead-only
tool_check_contactsReturn a contact count and a small sampleRead-only
tool_check_addressbookDiagnose Contacts/AddressBook database accessRead-only
tool_send_messageSend one direct or group message through Messages.appSends a real message

The server also exposes two MCP resources:

  • messages://recent/{hours}
  • messages://contact/{contact}/{hours}

Working with contacts, chats, and attachments

Recipients

For direct messages, E.164 phone numbers are the most reliable format:

+14155551234

The server normalizes bare numbers with a country code and converts 10-digit US numbers to +1.... It also accepts email addresses, contact names, and contact:N selections returned after an ambiguous contact search.

For a group conversation, call tool_get_chats, pass its chat ID to tool_send_message, and set group_chat=true. Use the same ID as chat_id in tool_get_recent_messages to read that conversation.

Attachments

Attachment access is deliberately split into three steps:

  1. Message reads and searches add compact markers such as [attachments: #42 image/jpeg (invitation.jpg)].
  2. tool_search_attachments searches metadata without loading file contents.
  3. tool_get_attachment fetches one selected attachment.

Images up to 5 MB are returned inline by default. HEIC images are converted to PNG. Larger images, PDFs, video, and audio are returned as local filesystem paths so the MCP client can decide whether to open them. Stickers, link-preview payloads, and .pluginPayloadAttachment containers are filtered out.

Privacy and security

  • Messages and Contacts SQLite connections use read-only mode and SQLite query_only.
  • The server does not upload, mirror, index, or maintain its own message archive.
  • Results are written to the local MCP stdio connection started by your client.
  • Message bodies are sanitized and bounded before being returned.
  • Attachment bytes are returned only after an explicit fetch and are size-limited for inline images.
  • Sending is isolated in tool_send_message, escapes AppleScript inputs, and uses a bounded execution timeout.
  • Full Disk Access is broader than Messages access. Grant it only to MCP clients you trust and review the destination before approving a send.

See SECURITY.md to report a vulnerability privately.

Troubleshooting

uvx or spawn uvx ENOENT

The GUI app cannot see your shell's Homebrew path. Run:

which uvx

Use that full path as the MCP command, then restart the client.

Operation not permitted, unable to open database file, or no messages

Grant Full Disk Access to the app that launches the server, not just to Messages.app. Completely quit and reopen the launcher afterward, then call tool_check_db_access again.

For Claude Code or Codex CLI, the launcher is normally your terminal. For a desktop or IDE integration, it is normally Claude Desktop, Cursor, VS Code, or the ChatGPT desktop app itself.

Contacts are empty or contact lookup fails

Allow the launching app to access Contacts if macOS prompts. Confirm Full Disk Access, restart the app, and call tool_check_addressbook followed by tool_check_contacts.

Reading works but sending fails

  1. Open Messages.app and send a message manually to confirm the account and recipient work.
  2. Check System Settings → Privacy & Security → Automation and allow the launching app to control Messages.
  3. Prefer an E.164 number such as +14155551234 for a direct recipient.
  4. Use tool_check_imessage_availability to inspect the likely route.

An attachment is listed but cannot be opened

Messages may retain database metadata after macOS has offloaded the file. Open the conversation in Messages.app and download the attachment, then retry tool_get_attachment.

The server appears to hang when run in Terminal

That is normal for an MCP stdio server: it waits for protocol input from a client. Use your client's MCP status view, or launch the MCP Inspector:

yarn dlx @modelcontextprotocol/inspector uvx mac-messages-mcp

Install as a standalone tool

MCP clients can launch the package directly with uvx; a permanent installation is optional.

uv tool install mac-messages-mcp
mac-messages-mcp

Upgrade or remove it with:

uv tool upgrade mac-messages-mcp
uv tool uninstall mac-messages-mcp

Python API

The MCP server is the primary interface, but the package also exports its core read/send functions:

from mac_messages_mcp import get_recent_messages, send_message

recent = get_recent_messages(hours=48)
print(recent)

result = send_message(
    recipient="+14155551234",
    message="Hello from Mac Messages MCP!",
)
print(result)

These calls use the same macOS permissions and can send real messages.

Development

git clone https://github.com/carterlasalle/mac_messages_mcp.git
cd mac_messages_mcp

uv sync --frozen --extra dev
uv run pytest
uv run black --check .
uv run isort --check-only .
uv build

Tests mock AppleScript and use temporary database fixtures; they must never read a contributor's real Messages or Contacts data. See CONTRIBUTING.md for the contribution checklist and VERSIONING.md for releases.

Build the Claude Desktop extension

The repository includes an MCPB manifest.json and a build script that can bundle an architecture-specific uv binary:

yarn global add @anthropic-ai/mcpb
uv run python scripts/build_mcpb.py

For an Intel build:

uv run python scripts/build_mcpb.py --arch x86_64

Install the generated .mcpb from Claude Desktop → Settings → Extensions → Advanced settings → Install Extension…. A bundled extension still needs network access on first launch to download Python and the package dependencies.

Use --no-bundle to package against the system uv, or run uv run python scripts/build_mcpb.py --help for every option.

Docker

The included Dockerfile is for package and catalog validation. A Linux container cannot access macOS TCC permissions or automate Messages.app, so Docker is not a supported way to read or send messages on the host Mac.

License

MIT © Carter Lasalle

Contributing

Issues and focused pull requests are welcome. Do not include real message contents, contacts, phone numbers, database files, or attachments in bug reports or fixtures.

Changelog · Contributing · Security · PyPI

常见问题

What is mac_messages_mcp?

mac_messages_mcp is an open-source mcp servers skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by carterlasalle. An MCP server that securely interfaces with your iMessage database via the Model Context Protocol (MCP), allowing LLMs to query and analyze iMessage conversations. It includes robust phone number validation, attachment processing, contact management, group chat handling, and full support for sending and receiving messages. It has 318 GitHub stars.

Is mac_messages_mcp safe to use?

Yes. mac_messages_mcp passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install mac_messages_mcp?

Clone the repository with "git clone https://github.com/carterlasalle/mac_messages_mcp" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is mac_messages_mcp written in?

mac_messages_mcp is primarily written in Python. It is open-source under carterlasalle on GitHub, so you can review or fork the full source.

Are there alternatives to mac_messages_mcp?

Yes. SkillsLLM lists many other MCP Servers skills you can browse and compare side by side. Open the MCP Servers category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh mac_messages_mcp against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

Scrapling

by D4Vinci

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

75,9137,581Python
MCP 服务器
查看详情

TrendRadar

by sansan0

⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。

61,65224,883Python
MCP 服务器
查看详情

context7

by upstash

Context7 Platform -- Up-to-date code documentation for LLMs and AI code editors

61,0602,938TypeScript
MCP 服务器
查看详情

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

39,9393,219C
MCP 服务器
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情