MCP Servers

模型上下文协议服务器、框架、SDK 和模板的综合目录。

WeChat MCP Server - 通过 MCP 协议控制微信桌面客户端,兼容 OpenCode

创建于 5/11/2026
更新于 about 4 hours ago
Repository documentation and setup instructions

WeChatMCP - Windows 版

为 AI Agent 设计的微信 REST API 服务(Windows 兼容)。

基于 KoujiMinamoto/WeChatMCPforAgent 的架构,将 macOS Accessibility API 替换为 Windows UI Automation。

架构

AI Agent (OpenCode 等)
        │
        ▼
┌─────────────────────────┐
│  WeChatMCP (Windows)    │  ← FastAPI, 端口 8000
│  /api/v1/*              │
└───┬─────────────────┬───┘
    │                 │
    ▼                 ▼
 UI Automation     uiautomation
 (读消息/联系人)    (发消息/操作)

前置要求

| 依赖 | 说明 | |------|------| | Windows 10/11 | 仅支持 Windows | | 微信 Windows 版 | 需要登录并保持运行 | | Python 3.12+ | 运行环境 |

快速开始

# 1. 克隆项目
git clone https://github.com/zhouzdx/WeChatMCP.git
cd WeChatMCP

# 2. 安装依赖
pip install -r requirements.txt

# 3. 启动服务
python -m wechatbot.main

服务启动在 http://localhost:8000,Swagger 文档访问 http://localhost:8000/docs

API 接口

查询类

| 方法 | 路径 | 说明 | 参数 | |------|------|------|------| | GET | /api/v1/sessions | 最近会话列表 | - | | GET | /api/v1/contacts | 搜索联系人 | keyword | | GET | /api/v1/chatrooms | 搜索群聊 | keyword | | GET | /api/v1/messages | 查询聊天记录 | talker, time, sender, keyword |

操作类(通过 UI Automation)

| 方法 | 路径 | 说明 | |------|------|------| | POST | /api/v1/message/send | 发送消息 | | POST | /api/v1/contact/add | 添加好友 | | POST | /api/v1/moment/publish | 发朋友圈 |

Webhook

| 方法 | 路径 | 说明 | |------|------|------| | POST | /api/v1/webhook/register | 注册消息回调 | | DELETE | /api/v1/webhook/{id} | 取消回调 | | GET | /api/v1/webhook | 查看已注册回调 |

其他

| 方法 | 路径 | 说明 | |------|------|------| | GET | /api/v1/health | 健康检查 |

使用示例

# 健康检查
curl http://localhost:8000/api/v1/health

# 查询最近会话
curl http://localhost:8000/api/v1/sessions

# 搜索联系人
curl "http://localhost:8000/api/v1/contacts?keyword=张三"

# 发送消息
curl -X POST http://localhost:8000/api/v1/message/send \
  -H "Content-Type: application/json" \
  -d "{\"chat_name\":\"文件传输助手\",\"message\":\"Hello from Agent!\"}"

# 添加好友
curl -X POST http://localhost:8000/api/v1/contact/add \
  -H "Content-Type: application/json" \
  -d "{\"wechat_id\":\"wxid_xxx\",\"friending_msg\":\"你好\”}"

# 发朋友圈
curl -X POST http://localhost:8000/api/v1/moment/publish \
  -H "Content-Type: application/json" \
  -d "{\"content\":\"测试发布\"}"

与 macOS 版的区别

| 功能 | macOS 版 | Windows 版 | |------|----------|------------| | 底层自动化 | Accessibility API (pyobjc) | UI Automation (uiautomation) | | 消息读取 | chatlog MCP Server (SQLite) | UI Automation 界面读取 | | 搜索联系人 | AX API | 模拟 Ctrl+F 搜索 | | 发送消息 | AX API + 键盘模拟 | UI Automation + SendKeys | | 添加好友 | AX API | 模拟搜索 + 添加流程 | | 发朋友圈 | AX API | 模拟点击发表 |

注意事项

  • 操作过程中请不要移动鼠标或使用键盘,以免干扰 UI 自动化
  • 微信窗口需要保持运行(不必在前台)
  • 发送大量消息时请适当增加间隔
  • 首次使用建议先手动打开微信并登录

许可证

MIT

快速设置
此服务器的安装指南

安装包 (如果需要)

uvx wechatmcp

Cursor 配置 (mcp.json)

{ "mcpServers": { "zhouzdx-wechatmcp": { "command": "uvx", "args": [ "wechatmcp" ] } } }