wechat-mcp
Automates WeChat on macOS using Accessibility APIs and screen capture, focusing on Excel-driven contact requests, add-friend flows, and friend-request status checks for local outreach workflows.
README
<div align="center">
WeChat MCP Excel Contact Server
中文 | English
</div>
An MCP server that automates WeChat on macOS using Accessibility APIs and screen capture. This package focuses on Excel-driven contact requests, reusable add-friend flows, and friend-request status checks for local outreach workflows.
Features
- 📨 Fetch recent messages from any chat (contact or group)
- ✍️ Send automated replies based on chat history
- 📷 Publish text-only Moments posts, with optional draft-only mode
- 👥 Add contacts using WeChat ID with configurable privacy
- 📊 Read selected Excel rows into WeChat contact request payloads
- 🔁 Monitor pending friend requests, classify whether they were accepted, and persist local state for later processing
- 🧾 Write operator-friendly CSV state plus JSONL audit events
- 🔍 Smart chat search with exact name matching
- 🤖 5 specialized Claude Code sub-agents for smart WeChat automation
Quick Start
Installation
uv tool install git+https://github.com/zbvxbb622-code/wechat-mcp-friend-automation.git
After installation, initialize the local state files and print the exact first-run commands:
wechat-mcp-bootstrap
wechat-mcp-doctor
wechat-mcp-bootstrap safely creates the default wechat-followup-state/
directory, monitor_state.csv, monitor_events.jsonl, the production
wechat-outreach-state/ directory, and the default logs/ directory without
overwriting existing files. wechat-mcp-doctor reports
PASS or ACTION REQUIRED for the Python/uv runtime boundary, WeChat
installation and login, macOS Accessibility readiness, writable state, and MCP
registration guidance. The installed console scripts run directly; uv is
needed for this install command and for the source-checkout workflow below,
not for the already-installed wechat-mcp command.
Setup with Claude Code
# If installed as a uv tool
claude mcp add --transport stdio wechat-mcp -- wechat-mcp
# If using uv for development
claude mcp add --transport stdio wechat-mcp -- uv --directory $(pwd) run wechat-mcp
<details> <summary>Setup with Claude Desktop</summary>
// If installed as a uv tool
{
"mcpServers": {
"wechat-mcp": {
"type": "stdio",
"command": "wechat-mcp"
}
}
}
// If using uv for development
{
"mcpServers": {
"wechat-mcp": {
"type": "stdio",
"command": "uv",
"args": [
"--directory",
"{path/to/wechat-mcp}",
"run",
"wechat-mcp"
],
}
}
}
</details>
<details> <summary>Setup with Codex</summary>
# If installed as a uv tool
codex mcp add wechat-mcp -- wechat-mcp
# If using uv for development
codex mcp add wechat-mcp -- uv --directory $(pwd) run wechat-mcp
</details>
macOS Permissions
⚠️ Important: Grant Accessibility permissions to your terminal:
- Open WeChat for Mac and sign in with the QR code or phone login.
- Open System Settings → Privacy & Security → Accessibility
- Add and enable the terminal/IDE that launches the MCP command (Terminal.app, iTerm2, etc.)
- Run
wechat-mcp-doctorand resolve everyACTION REQUIREDcheck before using the server.
The bootstrap command prints these one-time steps and both exact registration commands:
# Claude Code
claude mcp add --transport stdio wechat-mcp -- wechat-mcp
# Codex
codex mcp add wechat-mcp -- wechat-mcp
Usage
Basic Commands
# Re-run first-run checks at any time
wechat-mcp-doctor
# Run one production outreach scheduling pass
wechat-outreach-run --input-xlsx /path/to/contacts.xlsx --sheet-name 独家达人 --once
# Run with default stdio transport
wechat-mcp --transport stdio
# Run with HTTP transport
wechat-mcp --transport streamable-http
# Run with SSE transport
wechat-mcp --transport sse
# Poll pending friend requests once and write monitor_state.csv / monitor_events.jsonl
wechat-followup-monitor --workbook /path/to/contacts.xlsx --sheet-name 独家达人 --rows 3-6 --once
Available MCP Tools
fetch_messages_by_chat- Get recent messages from a chatreply_to_messages_by_chat- Send a reply to a chatadd_contact_by_wechat_id- Add a new contact using a WeChat ID and send a friend requestread_wechat_contacts_from_excel- Read selected Excel rows into friend-request payloadsadd_contacts_from_excel_rows- Read selected Excel rows and add contactscheck_contact_status- Classify a contact asadded,waiting,not_added,not_found, orunknownpublish_moment_without_media- Publish a text-only Moments post (no photos or videos); optionally only prepare a draft without posting viapublish=False
See detailed API documentation for full tool specifications.
The repository also includes local follow-up helpers and runner scripts for stateful workflows, but the default MCP registry intentionally keeps direct accepted-contact send tools hidden.
Excel Contact Workflow
Defaults match the tested creator resource sheet:
nickname_col:Bredbook_id_col:Cwechat_id_col:AZstart_row:3request_message:你好,想和你沟通商务合作remark_template:小红书-{nickname}-{redbook_id}- Batch add delay:
delay_seconds=10by default between contacts - Cooldown: after every 20 contacts, wait 10 minutes before continuing
- Cooldown check: re-check pending contacts after cooldown, update local state files, and record unresolved contacts for later processing
- Optional shared QR image: pass one
followup_image_path/--followup-imageand the same QR image is sent to every accepted contact after the text message
Example MCP arguments for a preview:
{
"workbook_path": "/path/to/contacts.xlsx",
"sheet_name": "独家达人",
"rows": "3,5-8"
}
Example MCP arguments for a dry run:
{
"workbook_path": "/path/to/contacts.xlsx",
"sheet_name": "独家达人",
"rows": "3-6",
"dry_run": true
}
When running a real batch, the server spaces out add attempts and cools down after every 20 contacts by default:
{
"workbook_path": "/path/to/contacts.xlsx",
"sheet_name": "独家达人",
"rows": "3-42",
"delay_seconds": 10,
"cooldown_after_contacts": 20,
"cooldown_seconds": 600,
"followup_image_path": "/path/to/wecom-qr.png"
}
Follow-Up Monitor
This repository includes local follow-up helpers for operator-run workflows. Direct accepted-contact send helpers are not registered as default MCP tools.
wechat-followup-monitor keeps the post-request workflow running without leaving a Codex chat open.
Defaults:
- Check interval: 30 minutes
- Max wait: 72 hours
- State files:
wechat-followup-state/monitor_state.csvandwechat-followup-state/monitor_events.jsonl - Follow-up message:
你好,想和你进一步沟通商务合作,方便时请回复这条消息 - Send failures are recorded as
send_failedand are not retried automatically
Run wechat-mcp-bootstrap --state-dir /path/to/wechat-followup-state to create
these state files before the first batch or monitor run. Existing CSV/JSONL
files are preserved.
Example:
wechat-followup-monitor \
--workbook /path/to/contacts.xlsx \
--sheet-name 独家达人 \
--rows 3-6 \
--followup-image /path/to/wecom-qr.png
For a safe test without touching WeChat:
wechat-followup-monitor \
--workbook /path/to/contacts.xlsx \
--rows 3 \
--once \
--dry-run \
--dry-run-status waiting
Production Outreach Runner
wechat-outreach-run is the production closed-loop entrypoint. It keeps an
internal queue in wechat-outreach-state/run_state.json, exports operator
views as:
wechat-outreach-state/输入快照.xlsxwechat-outreach-state/待处理表.xlsxwechat-outreach-state/成功表.xlsxwechat-outreach-state/失败表.xlsx
Default behavior:
- Work window:
10:00-24:00local time - One WeChat action at a time
- Global deduplication by
wechat_id - Fixed follow-up delay:
5-15minutes after acceptance - Single-instance lock:
wechat-outreach-state/.wechat-outreach.lock - Circuit-breaker evidence:
wechat-outreach-state/evidence/
Resume after a pause:
wechat-outreach-run --state-dir /path/to/wechat-outreach-state --resume- When a circuit breaker pauses the run, resume only continues unfinished
people from
待处理表.xlsx. 成功表.xlsxand失败表.xlsxare never retried automatically.
Example:
wechat-outreach-run \
--input-xlsx /path/to/contacts.xlsx \
--sheet-name 独家达人 \
--rows 3-40 \
--followup-image /path/to/wecom-qr.png
Claude Code Sub-Agents
This project includes 5 intelligent sub-agents designed specifically for WeChat automation. They enable natural language control of WeChat through Claude Code.
Available Sub-Agents
- Chat-summarizer - Summarize chat history and extract key information
- Auto-replier - Auto-generate and send appropriate replies
- Message-searcher - Search chat history for specific content
- Multi-chat-checker - Monitor multiple chats and prioritize messages
- Chat-insights - Analyze relationship dynamics and communication patterns
📖 View complete sub-agents guide
Development
Local Setup with uv
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and setup
git clone https://github.com/zbvxbb622-code/wechat-mcp-friend-automation.git
cd wechat-mcp-friend-automation
uv sync
# Run locally
uv run wechat-mcp --transport stdio
# Run the install checks from a source checkout
uv run wechat-mcp-bootstrap
uv run wechat-mcp-doctor
Documentation
- 📘 Detailed Guide - Complete API documentation and architecture
- 🤖 Sub-Agents Guide - How to use Claude Code sub-agents
Requirements
- macOS (uses Accessibility API)
- WeChat for Mac installed and running
- Python 3.12+
- Accessibility permissions for terminal
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。