Skip to main content
Glama

WeChat MCP Excel Contact Server

Python 3.12+ Install via GitHub License: MIT

中文 | English

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

Related MCP server: WinAutoWx

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
// 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"
      ],
    }
  }
}
# 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

macOS Permissions

⚠️ Important: Grant Accessibility permissions to your terminal:

  1. Open WeChat for Mac and sign in with the QR code or phone login.

  2. Open System Settings → Privacy & Security → Accessibility

  3. Add and enable the terminal/IDE that launches the MCP command (Terminal.app, iTerm2, etc.)

  4. Run wechat-mcp-doctor and resolve every ACTION REQUIRED check 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 chat

  • reply_to_messages_by_chat - Send a reply to a chat

  • add_contact_by_wechat_id - Add a new contact using a WeChat ID and send a friend request

  • read_wechat_contacts_from_excel - Read selected Excel rows into friend-request payloads

  • add_contacts_from_excel_rows - Read selected Excel rows and add contacts

  • check_contact_status - Classify a contact as added, waiting, not_added, not_found, or unknown

  • publish_moment_without_media - Publish a text-only Moments post (no photos or videos); optionally only prepare a draft without posting via publish=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: B

  • redbook_id_col: C

  • wechat_id_col: AZ

  • start_row: 3

  • request_message: 你好,想和你沟通商务合作

  • remark_template: 小红书-{nickname}-{redbook_id}

  • Batch add delay: delay_seconds=10 by 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-image and 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.csv and wechat-followup-state/monitor_events.jsonl

  • Follow-up message: 你好,想和你进一步沟通商务合作,方便时请回复这条消息

  • Send failures are recorded as send_failed and 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/输入快照.xlsx

  • wechat-outreach-state/待处理表.xlsx

  • wechat-outreach-state/成功表.xlsx

  • wechat-outreach-state/失败表.xlsx

Default behavior:

  • Work window: 10:00-24:00 local time

  • One WeChat action at a time

  • Global deduplication by wechat_id

  • Fixed follow-up delay: 5-15 minutes 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.

  • 成功表.xlsx and 失败表.xlsx are 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

  1. Chat-summarizer - Summarize chat history and extract key information

  2. Auto-replier - Auto-generate and send appropriate replies

  3. Message-searcher - Search chat history for specific content

  4. Multi-chat-checker - Monitor multiple chats and prioritize messages

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

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

A
license - permissive license
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    D
    maintenance
    Enables AI assistants to send WeChat messages and take screenshots through ADB automation with LDPlayer emulator. Supports automated WeChat replies to multiple contacts with personalized messages for business and personal use.
    Last updated
    18
    MIT
  • F
    license
    -
    quality
    D
    maintenance
    Enables automated WeChat operations on Windows through pywinauto, allowing users to send messages to multiple friends or groups programmatically. Provides tools for searching contacts, sending bulk messages, and controlling WeChat interface elements via MCP protocol.
    Last updated
    16
  • F
    license
    -
    quality
    C
    maintenance
    Automates job searching and initial communication on the Boss Zhipin platform by parsing resumes and matching them with relevant job listings. It includes anti-bot detection features and supports automated messaging to HR representatives through various MCP clients.
    Last updated
    10

View all related MCP servers

Related MCP Connectors

  • MCP connector for iMessage & Contacts via a local Mac agent + Vercel relay

  • Let ChatGPT, Claude & Cursor use your Mac: email, calendar, iMessage, Teams, files. Local, free.

  • Managed LinkedIn MCP server for AI agents: search, connect, message and enrich on accounts you own.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zbvxbb622-code/wechat-mcp-friend-automation'

If you have feedback or need assistance with the MCP directory API, please join our Discord server