iMessage MCP Server
Enables Claude to send and read iMessages on macOS, with smart contact lookup, message history retrieval, and cross-conversation search using natural language commands.
README
iMessage MCP Server
A personalized iMessage MCP (Model Context Protocol) server that lets Claude send and read iMessages on macOS.
Features
- Send Messages: Send iMessages using natural language ("Text John saying I'm running late")
- Read Messages: Retrieve recent message history with any contact
- Smart Contact Lookup: Find contacts by name with fuzzy matching
- Cross-Conversation Search: Search messages across all contacts
- macOS Contacts Sync: Auto-sync contacts from your macOS Contacts app
Requirements
- macOS (required - iMessage is macOS only)
- Python 3.9+
- Claude Code or Claude Desktop (MCP client)
- Full Disk Access permission (for reading message history)
Quick Start
1. Clone and Install
git clone https://github.com/yourusername/imessage-mcp.git
cd imessage-mcp
# Install dependencies
pip install -r requirements.txt
2. Set Up Contacts
# Option A: Sync from macOS Contacts (recommended)
python3 scripts/sync_contacts.py
# Option B: Manual setup
cp config/contacts.example.json config/contacts.json
# Edit config/contacts.json with your contacts
3. Grant Permissions
-
Full Disk Access (for reading messages):
- System Settings → Privacy & Security → Full Disk Access
- Add Terminal.app or your Python interpreter
-
Automation (for sending messages):
- Will be requested automatically on first send
4. Register with Claude Code
# Using Claude Code CLI
claude mcp add -t stdio imessage-mcp -- python3 /path/to/imessage-mcp/mcp_server/server.py
# Then restart Claude Code
5. Test It Out
In Claude Code, try:
List my contacts
Show my recent messages with John
Send a message to Jane saying "Hey, are you free for coffee tomorrow?"
Available MCP Tools
| Tool | Description |
|---|---|
list_contacts |
List all configured contacts |
send_message |
Send an iMessage to a contact by name |
get_recent_messages |
Get recent messages with a specific contact |
get_all_recent_conversations |
Get recent messages across all contacts |
search_messages |
Full-text search across all messages |
get_messages_by_phone |
Get messages by phone number directly |
Project Structure
imessage-mcp/
├── mcp_server/
│ └── server.py # MCP server entry point
├── src/
│ ├── messages_interface.py # iMessage send/read
│ ├── contacts_manager.py # Contact lookup
│ └── contacts_sync.py # macOS Contacts sync
├── config/
│ ├── contacts.json # Your contacts (gitignored)
│ └── contacts.example.json # Example template
├── scripts/
│ ├── sync_contacts.py # Sync from macOS Contacts
│ ├── test_mcp_protocol.py # Test MCP protocol
│ └── test_mcp_tools.py # Test tool functionality
└── tests/ # Unit tests
Configuration
Contact Format
Contacts are stored in config/contacts.json:
{
"contacts": [
{
"name": "John Doe",
"phone": "14155551234",
"relationship_type": "friend",
"notes": "Optional notes"
}
]
}
Phone numbers can be in any format - they're normalized automatically.
Server Config
Optional settings in config/mcp_server.json:
{
"logging": {
"level": "INFO"
},
"contacts_sync": {
"fuzzy_match_threshold": 0.85
}
}
Troubleshooting
"Contact not found"
- Run
python3 scripts/sync_contacts.pyto sync contacts - Check
config/contacts.jsonexists and has contacts - Try partial names (e.g., "John" instead of "John Doe")
"Permission denied" reading messages
- Grant Full Disk Access to Terminal/Python
- Restart Terminal after granting permission
- Verify:
ls ~/Library/Messages/chat.db
Messages show "[message content not available]"
- Some older messages use a different format
- Attachment-only messages don't have text content
- This is normal for some message types
MCP server not appearing in Claude Code
- Verify registration:
claude mcp list - Check Python path:
which python3 - Restart Claude Code after adding the server
How It Works
- Sending: Uses AppleScript to control Messages.app
- Reading: Directly queries
~/Library/Messages/chat.db(SQLite) - Contacts: Syncs from macOS Contacts via PyObjC framework
Claude Code Skill (Optional)
This repo includes a Claude Code skill at .claude/skills/imessage-texting/ with usage examples for each MCP tool.
To use it, clone this repo - Claude Code will automatically pick up the skill from the .claude/skills/ directory.
Development
# Run tests
pytest tests/ -v
# Test MCP protocol manually
python3 scripts/test_mcp_protocol.py
# Test tools
python3 scripts/test_mcp_tools.py
Privacy & Security
- All data stays local on your Mac
- No cloud services or external APIs
- Contacts file is gitignored by default
- Message history accessed read-only
License
MIT License - see LICENSE for details.
Contributing
Contributions welcome! Please open an issue or PR.
Built for use with Claude Code and Claude Desktop
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。