Skip to main content

WeChat MCP Server

让 AI 读写微信消息 — 通过 Model Context Protocol (MCP) 标准协议,AI 助手可以直接搜索联系人、读取聊天、发送消息。

AI agents can read and write WeChat messages through the Model Context Protocol (MCP).


✨ 功能 Features

功能 说明
📥 读聊天 截取聊天窗口 → Qwen-VL 识别文字 → 返回结构化消息
📤 发消息 搜索联系人 → 截图验证 → 粘贴发送
🔍 搜联系人 Cmd+F 搜索 → 自动验证是否打开正确聊天
🟡 红点检测 OpenCV 检测未读消息红点位置
👁️ 视觉分析 使用阿里云 DashScope Qwen-VL-Plus 理解截图内容

📋 需求 Requirements

  • macOS (WeChat for Mac)
  • Python 3.10+
  • WeChat 已登录且主窗口可见
  • cua-driver — 快捷键自动化层(GitHub)
  • DashScope API Key — 阿里云百炼视觉模型(免费额度)

🚀 快速开始 Quick Start

1. 安装

pip install wechat-mcp

或者从源码安装:

git clone https://github.com/jp7454yv4f-sudo/WeChat-mcp.git
cd WeChat-mcp
pip install -e .

2. 配置 API Key

# 方式一:环境变量(推荐)
export WEIXIN_MCP_API_KEY='sk-...'

# 方式二:配置文件
# 创建 ~/.wechat_mcp/config.json:
# {"dashscope_api_key": "sk-..."}

API Key 获取:https://dashscope.aliyun.com → 模型广场 → Qwen-VL-Plus

3. 启动

wechat-mcp

4. 配置 MCP 客户端

Claude Desktop:

{
  "mcpServers": {
    "wechat": {
      "command": "wechat-mcp"
    }
  }
}

Cursor / Windsurf:

MCP Server → Add → Command: wechat-mcp

🛠️ 可用工具 Available Tools

工具 参数 说明
search_contact name 搜索并打开联系人聊天
send_message contact, text 发送消息(自动验证)
read_chat contact? 读取当前/指定聊天内容
reply_message contact, text 发送消息 + 语气迭代记录
list_contacts — 列出所有有过对话的联系人
detect_new_messages interval_seconds 红点检测循环

🔧 技术栈 Tech Stack

组件 技术
协议 Model Context Protocol (MCP)
自动化驱动 cua-driver / osascript 快捷键
截图 macOS screencapture
红点检测 OpenCV HSV 颜色空间
视觉理解 Qwen-VL-Plus (DashScope)

💰 运营成本

每次 API 调用约 0.002元(Qwen-VL-Plus),完整读写一次约 0.01元。 红点检测为本地 OpenCV,零成本。

📄 许可 License

GNU AGPL v3 — 开源但保护作者权益。

  • ✅ 个人/内部使用免费
  • ✅ 修改后自用免费
  • ❌ 修改后作为 SaaS/网络服务提供须开源修改内容
  • ❌ 闭源的商业分发需要授权

商业授权请联系:jp7454yv4f-sudo@users.noreply.github.com

🧑‍💻 作者 Author

Lozzi — built for AI-powered WeChat automation.

Release files for wx-mcp-server 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wx-mcp-server 0.1.0
File Size Uploaded
wx_mcp_server-0.1.0.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wx-mcp-server 0.1.0
File Interpreter ABI Platform
wx_mcp_server-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.1 kB

Release files / wx_mcp_server-0.1.0.tar.gz

Download URL wx_mcp_server-0.1.0.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bebb2570cda72a9a8fab047158771f98c783018931131bd3431a316937e74be3
BLAKE2b-256 checksum
How to use checksums
e2ddebaff979d4781f58b26bcf85b40001fde7196c099851cf75603c9a24303f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / wx_mcp_server-0.1.0-py3-none-any.whl

Download URL wx_mcp_server-0.1.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48ead244b783280a0f0456cb5fd977ff5247e8b5810354cc962a6fdc2857b3b1
BLAKE2b-256 checksum
How to use checksums
e53b324e3bfb33e337d6e8fa976c8fdfd409cb6959285a9770263a0e23038550
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page