WeChat Official Account MCP
Provides tools for managing WeChat Official Account operations including authentication, media uploads (temporary and permanent materials), draft management, article publishing, and content management through the WeChat Official Platform API.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@WeChat Official Account MCPupload a promotional banner image for our new product launch"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
微信公众号 MCP 服务
为 AI 应用(Claude Desktop、Cursor 等)提供微信公众号 API 集成的 MCP 服务。
运行时: Node.js 20.17+
协议: MCP (Model Context Protocol) · 存储: SQLite · 语言: TypeScript
快速开始
WECHAT_APP_ID=<your_app_id> WECHAT_APP_SECRET=<your_app_secret> npx wechat-official-account-mcp mcp接入 Claude Desktop,在 claude_desktop_config.json 中添加:
{
"mcpServers": {
"wechat-official-account": {
"command": "npx",
"args": ["wechat-official-account-mcp", "mcp"],
"env": {
"WECHAT_APP_ID": "<your_app_id>",
"WECHAT_APP_SECRET": "<your_app_secret>"
}
}
}
}推荐用环境变量而非
-a/-s参数传 AppSecret,避免密钥出现在进程命令行里。
凭据会存入 ./data/wechat-mcp.db,其中 app_secret 等敏感字段默认 AES 加密(密钥未指定时自动生成于 ./data/.secret-key,权限 600)。
Related MCP server: Wenyan MCP Server
工具
对外暴露 14 个工具,按「读写分离」组织:只读与写入操作位于不同工具,便于客户端对写入操作做权限控制。所有工具返回 JSON。
类别 | 工具 |
内容 |
|
素材 |
|
用户 |
|
互动 |
|
消息 |
|
数据 |
|
长尾 |
|
每个域工具用一个 action 参数选择具体操作,例如:
wechat_content_read { "action": "list", "count": 10 } # 列出草稿
wechat_content_write { "action": "add", "articles": [...] } # 新建草稿
wechat_content_write { "action": "submit", "mediaId": "..." } # 提交发布菜单、二维码、短链、客服账号、账号配额、自动回复、商品卡片、认证配置等长尾能力未单独建工具,先用 search_actions 检索动作 ID(共 101 个),再用 execute_read_action / execute_write_action 执行。服务端 instructions 已说明该用法。
配置
环境变量 | 说明 |
| 公众号凭据(也可用 |
| 敏感字段加密密钥;未设置时自动生成本地密钥 |
| 本地密钥文件路径,默认 |
| 数据库路径,默认 |
| HTTP 模式下的 Bearer 鉴权令牌 |
| HTTP 模式下的来源白名单(逗号分隔) |
| 开启调试日志 |
AppID / AppSecret 获取:微信公众平台 → 开发 → 基本配置。
远程部署(Streamable HTTP)
MCP_HTTP_TOKEN=$(openssl rand -hex 32) \
CORS_ORIGIN=https://your-client.example \
npx wechat-official-account-mcp mcp -m http -p 3000端点 | 说明 |
| MCP 端点(无状态) |
| 探活,不鉴权 |
⚠️ 微信 IP 白名单:公众号 API 要求调用方 IP 在账号后台白名单内,否则报
40164 invalid ip。 部署到服务器后,需把该服务器出口 IP 加入「公众号后台 → 开发 → 基本配置 → IP 白名单」。
--mode sse 保留但已废弃(该传输无鉴权且被 MCP 规范取代),建议改用 http。
也可以直接用 Docker:docker compose up -d(见 docker-compose.yml)。
systemd + nginx 常驻部署的配置与运维步骤与环境强相关,不入库,保存在本地 deploy/。
开发
npm install
npm run dev -- mcp -a <app_id> -s <app_secret> # 开发模式
npm run check && npm run lint && npm test # 静态检查与测试
npm run verify # 端到端校验(协议层 / 字段映射 / HTTP 鉴权)
npm run build # 构建到 dist/相关文档:CHANGELOG · CLAUDE.md(架构与开发规范)· 微信官方文档 · MCP 规范
安全
凭据加密:
app_secret/access_token/encoding_aes_key默认 AES 加密落库(enc:前缀);日志对敏感字段脱敏HTTP 鉴权:
--mode http下设置MCP_HTTP_TOKEN后所有/mcp请求需带Authorization: Bearer,未设置时启动即告警CORS:仅接受
CORS_ORIGIN白名单内的来源,不使用通配符输入校验:全部工具经 Zod schema 运行时校验,HTML 内容经
sanitizeHtmlContent()清理凭据不外泄:
wechat_auth的返回只含appId与布尔标记,不返回任何密钥或令牌
许可证
MIT · 作者 xwang152-jack <xwang152@163.com>
This server cannot be deployed
Maintenance
Related MCP Connectors
Instagram for AI agents: publish, read comments and DMs, insights, and engage from your account.
Connect any AI agent to 11+ social platforms: schedule, publish & track posts via hosted MCP.
Messaging tools for AI agents: send messages, manage chats, groups and channels.
Connect AI agents to 1000+ apps with managed authentication and tool-calling.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables management of WeChat Official Accounts by supporting draft creation, image uploads, and content publishing via the MCP protocol. It provides tools for interacting with the WeChat API, including secure token caching and draft list management.-
- AlicenseNot gradedqualityBmaintenanceBridges AI writing and content platforms by enabling AI agents to format Markdown and publish posts directly to WeChat Official Accounts with automatic image handling. It supports conversational theme management and streamlined drafting to eliminate the need for manual copy-pasting between editors.84 npm1,341Apache 2.0
- AlicenseAqualityFmaintenanceEnables AI agents to publish articles to WeChat Official Account (微信公众号). Supports image upload, draft creation, and publishing via standardized MCP protocol.51ISC
- FlicenseAqualityCmaintenanceEnables management of WeChat Official Account content, including creating, publishing, and deleting drafts and materials, through MCP tools.527-