Skip to main content

MCP Server for WeChat — let AI read and send WeChat messages

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wx_mcp_server-0.1.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wx_mcp_server-0.1.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file wx_mcp_server-0.1.0.tar.gz.

File metadata

  • Download URL: wx_mcp_server-0.1.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for wx_mcp_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bebb2570cda72a9a8fab047158771f98c783018931131bd3431a316937e74be3
MD5 408f3ede32df77eef73ea19f51fe4412
BLAKE2b-256 e2ddebaff979d4781f58b26bcf85b40001fde7196c099851cf75603c9a24303f

See more details on using hashes here.

File details

Details for the file wx_mcp_server-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wx_mcp_server-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for wx_mcp_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48ead244b783280a0f0456cb5fd977ff5247e8b5810354cc962a6fdc2857b3b1
MD5 f942731b9ffbfbf295ede62f530f05ed
BLAKE2b-256 e53b324e3bfb33e337d6e8fa976c8fdfd409cb6959285a9770263a0e23038550

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page