mcp-wechat-server

mcp-wechat-server

A WeChat robot server based on the Model Context Protocol that enables AI agents to send and receive messages and manage typing status. It provides tools for QR code login, long-polling message retrieval, and persistent state management across various MCP clients.

Category
Visit Server

README

mcp-wechat-server

基于 MCP(Model Context Protocol)的微信机器人服务器,让任何 AI Agent 都能收发微信消息。

npm version

功能

  • 6 个 MCP 工具:登录、消息轮询、文本发送、打字状态
  • 扫码登录:生成终端文本二维码、PNG 图片、URL 链接三种方式
  • 长轮询监听:阻塞等待新消息,最长可等待 7 天
  • 打字状态:Agent 处理消息时自动显示"对方正在输入..."
  • 状态持久化:重启不丢失登录凭证和消息游标
  • 独立运行:无需 OpenClaw 框架,开箱即用

快速开始

Claude Desktop

claude_desktop_config.json 中添加:

{
  "mcpServers": {
    "wechat": {
      "command": "bunx",
      "args": ["mcp-wechat-server"]
    }
  }
}

OpenCode

opencode.json 中添加:

{
  "mcp": {
    "wechat": {
      "type": "local",
      "command": ["bunx", "mcp-wechat-server"],
      "enabled": true
    }
  }
}

Cursor / 其他 MCP 客户端

{
  "command": "bunx",
  "args": ["mcp-wechat-server"]
}

bunx 会自动从 npm 下载并运行,无需手动安装。

环境要求

使用方法

1. 扫码登录

AI Agent 调用 login_qrcode 生成二维码,你可以通过以下方式扫码:

  • 在终端运行 cat ~/.mcp-wechat-server/qrcode.txt 查看二维码
  • 打开图片文件 ~/.mcp-wechat-server/qrcode.png
  • 将链接复制到微信中打开

提示:如果手机扫码后页面一直加载,请切换到移动数据网络(关闭 WiFi)。

<img src="assets/opencode_screenshot1.png" alt="OpenCode 登录二维码" width="600">

2. 确认登录

Agent 调用 check_qrcode_status 确认登录状态。

3. 开始聊天

登录成功后,Agent 会自动执行以下流程:

  1. 调用 get_messages 轮询新消息
  2. 收到消息后调用 send_typing 显示"正在输入..."
  3. 处理完成后调用 send_text_message 回复
  4. 回复完毕后调用 send_typing 取消打字状态

<img src="assets/wechat_screenshot1.jpg" alt="微信收发消息" width="400">

<img src="assets/opencode_screenshot2.png" alt="OpenCode Agent 交互" width="600">

<img src="assets/wechat_screenshot2.jpg" alt="微信收到回复" width="400">

工具列表

工具 说明
login_qrcode 生成微信登录二维码
check_qrcode_status 检查二维码是否已扫码确认
logout 退出登录并清除凭证
get_messages 拉取新消息(wait=true 阻塞等待直到收到消息)
send_text_message 发送文本消息
send_typing 发送或取消"正在输入"状态

数据存储

所有数据保存在 ~/.mcp-wechat-server/ 目录下:

文件 说明
account.json Bot Token 和用户 ID(权限 600)
state.json 消息游标和上下文 Token
qrcode.png 生成的二维码图片
qrcode.txt 生成的终端二维码文本

本地开发

git clone https://github.com/Howardzhangdqs/mcp-wechat-server.git
cd mcp-wechat-server
bun install
bun run dev

许可证

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured