Wechat Official Account MCP logo

Wechat Official Account MCP

Community
xwang152-jack

微信公众号MCP服务器 - WeChat Official Account MCP Server

Publisherxwang152-jack
Repositorywechat-official-account-mcp
LanguageTypeScript
Forks
26
Stars
65
Available tools
6
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Wechat Official Account MCP exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 6 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    65 stars and 26 forks from the linked repository.

微信公众号 MCP 服务

为 AI 应用(Claude Desktop、Cursor 等)提供微信公众号 API 集成的 MCP 服务。

当前版本: v2.2.1 · 更新日志 · 开发者指南

  • 运行时: Node.js 20.17+
  • 协议: MCP (Model Context Protocol) · 存储: SQLite · 语言: TypeScript

快速开始

bash
WECHAT_APP_ID=<your_app_id> WECHAT_APP_SECRET=<your_app_secret> npx wechat-official-account-mcp mcp

接入 Claude Desktop,在 claude_desktop_config.json 中添加:

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)。


工具

对外暴露 14 个工具,按「读写分离」组织:只读与写入操作位于不同工具,便于客户端对写入操作做权限控制。所有工具返回 JSON。

类别工具
内容wechat_content_read / wechat_content_write — 草稿与发布
素材wechat_media_read / wechat_media_write — 永久/临时素材、图文内图片
用户wechat_audience_read / wechat_audience_write — 粉丝、标签、黑名单
互动wechat_engagement_read / wechat_engagement_write — 文章评论
消息wechat_messaging_read / wechat_messaging_write — 模板/客服/订阅/群发
数据wechat_statistics — 发表内容、消息、接口统计(只读)
长尾search_actions + execute_read_action / execute_write_action

每个域工具用一个 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 已说明该用法。


配置

环境变量说明
WECHAT_APP_ID / WECHAT_APP_SECRET公众号凭据(也可用 -a / -s)
WECHAT_MCP_SECRET_KEY敏感字段加密密钥;未设置时自动生成本地密钥
WECHAT_MCP_SECRET_KEY_FILE本地密钥文件路径,默认 ./data/.secret-key
DB_PATH数据库路径,默认 ./data/wechat-mcp.db
MCP_HTTP_TOKENHTTP 模式下的 Bearer 鉴权令牌
CORS_ORIGINHTTP 模式下的来源白名单(逗号分隔)
DEBUG开启调试日志

AppID / AppSecret 获取:微信公众平台 → 开发 → 基本配置。


远程部署(Streamable HTTP)

bash
MCP_HTTP_TOKEN=$(openssl rand -hex 32) \
CORS_ORIGIN=https://your-client.example \
npx wechat-official-account-mcp mcp -m http -p 3000
端点说明
POST /mcpMCP 端点(无状态)
GET /healthz探活,不鉴权

⚠️ 微信 IP 白名单:公众号 API 要求调用方 IP 在账号后台白名单内,否则报 40164 invalid ip。 部署到服务器后,需把该服务器出口 IP 加入「公众号后台 → 开发 → 基本配置 → IP 白名单」。

--mode sse 保留但已废弃(该传输无鉴权且被 MCP 规范取代),建议改用 http。

也可以直接用 Docker:docker compose up -d(见 docker-compose.yml)。 systemd + nginx 常驻部署的配置与运维步骤与环境强相关,不入库,保存在本地 deploy/。


开发

bash
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>

Installation

TypingMind
{
  "mcpServers": {
    "wechat-official-account-mcp": {
      "command": "npx",
      "args": [
        "wechat-official-account-mcp",
        "mcp",
        "-a",
        "{{config.WECHAT_APP_ID}}",
        "-s",
        "{{config.WECHAT_APP_SECRET}}"
      ],
      "env": {
        "WECHAT_APP_ID": "<WECHAT_APP_ID>",
        "WECHAT_APP_SECRET": "<WECHAT_APP_SECRET>"
      }
    }
  }
}

Available Tools

  • wechat_auth

    管理微信公众号认证配置和 Access Token

  • wechat_draft

    管理微信公众号草稿

  • wechat_publish

    管理微信公众号文章发布

  • wechat_permanent_media

    管理微信公众号永久素材,支持添加、获取、删除、列表和统计操作

  • wechat_media_upload

    上传和管理微信公众号临时素材(图片、语音、视频、缩略图)

  • wechat_upload_img

    上传图文消息内所需的图片,不占用素材库限制

Use Wechat Official Account MCP MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Wechat Official Account MCP is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Wechat Official Account MCP as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Wechat Official Account MCP MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "wechat-official-account-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "wechat-official-account-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Wechat Official Account MCP MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Wechat Official Account MCP MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Wechat Official Account MCP to help me with this task?
Wechat Official Account MCP
Sure. I read it.
Here is what I found using Wechat Official Account MCP.

Frequently asked questions

What is the Wechat Official Account MCP MCP server used for?

Wechat Official Account MCP is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Wechat Official Account MCP MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Wechat Official Account MCP with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Wechat Official Account MCP MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Wechat Official Account MCP connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Wechat Official Account MCP MCP to TypingMind?

Wechat Official Account MCP runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Wechat Official Account MCP MCP provide in TypingMind?

Wechat Official Account MCP exposes 6 MCP tools that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Wechat Official Account MCP MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Wechat Official Account MCP requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇