wechat-mp-mcp-server
v0.2.0WeChat Official Account (公众号) MCP Server — 25 tools spanning official API, editor channel and HTML lint: media, drafts, long-form publishing and stats…
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
wechat_auth_configure
配置微信公众号 AppID 和 AppSecret
| Parameter | Type | Description |
|---|---|---|
app_id * | string | 公众号 AppID |
app_secret * | string | 公众号 AppSecret |
wechat_auth_get_token
获取当前 Access Token(自动刷新)
wechat_auth_refresh
强制刷新 Access Token
wechat_auth_health_check
凭据健康检查:清除本地缓存 token,强制向微信平台换取新 token 以验证凭据真实有效(可识别「缓存 token 假阳性」——本地 token 未过期但 AppSecret 已失效的情况)。失败时返回错误码、出口 IP 与操作指引
wechat_auth_sync_from_env
从环境变量同步 AppID/AppSecret 到本地存储并清除 token 缓存(解决「平台重置 secret 后本地 SQLite 仍存旧值」的问题)。优先读进程环境变量,缺失时自动解析 ~/.zshenv(或指定文件)中的 export 语句。secret 不会出现在返回结果中
| Parameter | Type | Description |
|---|---|---|
zshenv_path | string | 包含 export WECHAT_APP_SECRET 的 shell 配置文件路径,默认 ~/.zshenv(仅在进程环境变量缺失时读取) |
wechat_media_upload
上传临时素材(图片/语音/视频)
| Parameter | Type | Description |
|---|---|---|
file_path * | string | 本地文件路径 |
type * | string | 素材类型 |
wechat_media_get
获取临时素材
| Parameter | Type | Description |
|---|---|---|
media_id * | string | 素材 media_id |
wechat_material_upload_image
上传永久图片素材(用于草稿封面图,返回的 media_id 可作为 thumb_media_id)
| Parameter | Type | Description |
|---|---|---|
file_path * | string | 本地图片文件路径(JPG/PNG,≤10MB) |
wechat_media_uploadimg
上传图文消息内的图片(正文配图专用端点),返回可直接嵌入正文 HTML 的 mmbiz URL。注意:官方 draft/add 接口会过滤非 mmbiz 域名的外链图片,正文图片必须走本接口或 wechat_web_upload_image
| Parameter | Type | Description |
|---|---|---|
file_path * | string | 本地图片文件路径(JPG/PNG,≤10MB) |
wechat_draft_add
创建草稿(支持多图文,最多8篇)。注意:官方接口限制正文 <2 万字符,长文请改用 wechat_web_write_draft
| Parameter | Type | Description |
|---|---|---|
articles * | array | 图文列表 |
wechat_draft_list
获取草稿列表
| Parameter | Type | Description |
|---|---|---|
count | number | 数量(最大20) |
offset | number | 偏移量 |
wechat_draft_get
获取草稿详情
| Parameter | Type | Description |
|---|---|---|
media_id * | string | 草稿 media_id |
wechat_draft_delete
删除草稿
| Parameter | Type | Description |
|---|---|---|
media_id * | string | 草稿 media_id |
wechat_draft_update
更新草稿中的单篇文章(官方 /draft/update 接口)。只传需要修改的字段,正文同样受 2 万字符限制
| Parameter | Type | Description |
|---|---|---|
index * | number | 要更新的文章在草稿中的位置(从 0 开始) |
media_id * | string | 草稿 media_id |
author | string | 新作者 |
content | string | 新正文 HTML(与 content_file_path 二选一) |
content_file_path | string | 新正文 HTML 的本地文件路径 |
content_source_url | string | 新原文链接(传空字符串清除) |
digest | string | 新摘要 |
need_open_comment | number | 是否打开评论(0/1) |
only_fans_can_comment | number | 是否仅粉丝可评论(0/1) |
show_cover_pic | boolean | 是否显示封面 |
thumb_media_id | string | 新封面图 media_id |
title | string | 新标题 |
wechat_publish_submit
提交发布(草稿 → 发布)
| Parameter | Type | Description |
|---|---|---|
media_id * | string | 草稿 media_id |
wechat_publish_list
获取已发布文章列表
| Parameter | Type | Description |
|---|---|---|
count | number | 数量(最大20) |
offset | number | 偏移量 |
wechat_publish_get
获取发布状态
| Parameter | Type | Description |
|---|---|---|
article_id * | string | 发布文章 article_id |
wechat_publish_delete
删除已发布文章
| Parameter | Type | Description |
|---|---|---|
article_id * | string | 发布文章 article_id |
wechat_web_login
扫码登录公众号后台(打开 Chrome 窗口展示二维码)。登录一次后 cookie 持久保存于本地浏览器 profile,日常操作无需重复登录
| Parameter | Type | Description |
|---|---|---|
timeout_ms | number | 等待扫码的最长时间(毫秒),默认 5 分钟 |
wechat_web_status
检查公众号后台登录态(不报错:未登录时返回 logged_in: false 与登录指引)
wechat_web_upload_image
通过 web 编辑器通道上传图片(filetransfer 接口),返回 mmbiz 图床 URL。不依赖 IP 白名单,适合无白名单/出口 IP 多变的环境
| Parameter | Type | Description |
|---|---|---|
file_path * | string | 本地图片文件路径(JPG/PNG,≤10MB) |
wechat_web_write_draft
长文直写公众号草稿(编辑器通道):读取本地 HTML 文件 → lint 预检 → 外链降级 → 图片自动上图床 → operate_appmsg 创建完整草稿。不受官方接口 2 万 HTML 字符限制(限制的是去标签正文字数 ≤2 万)。返回 appMsgId 与编辑器 URL,最终发表由人工确认(每天仅 1 次群发额度)
| Parameter | Type | Description |
|---|---|---|
file_path * | string | 正文 HTML 文件路径 |
author | string | 作者(≤16字) |
auto_process_images | boolean | 自动把本地/外链图片上传到 mmbiz 图床并替换 src(推荐开启) |
digest | string | 摘要(≤120字),缺省时由公众号自动截取正文开头 |
show_cover_pic | boolean | 是否显示封面 |
source_url | string | 原文链接 |
strip_links | boolean | 把非微信域名的 <a> 降级为纯文本(规避外链违规拒绝保存) |
title | string | 标题(≤64字);缺省时从 <title> 或首个 <h1> 提取 |
wrap_section | boolean | 是否用默认排版 section 包裹正文(自带排版的文章保持 false) |
wechat_stats_article_summary
图文数据统计(web 后台 misc 接口,cookie 鉴权无 IP 白名单依赖):按日返回指定日期区间内文章的阅读/分享/点赞等数据。跨度 ≤7 天,查询昨天及更早的数据最准
| Parameter | Type | Description |
|---|---|---|
begin_date * | string | 开始日期 YYYY-MM-DD |
end_date * | string | 结束日期 YYYY-MM-DD(跨度 ≤7 天) |
wechat_stats_user_summary
用户数据统计(web 后台 misc 接口,cookie 鉴权无 IP 白名单依赖):按日返回指定日期区间内的新增关注/取关/净增等数据。跨度 ≤7 天
| Parameter | Type | Description |
|---|---|---|
begin_date * | string | 开始日期 YYYY-MM-DD |
end_date * | string | 结束日期 YYYY-MM-DD(跨度 ≤7 天) |
wechat_html_check
公众号正文 HTML 发布前静态检查(纯本地无网络):ul/li 残留、裸 br 换行丢失风险、占位符残留、非 mmbiz 图片、script 标签、SVG 动画双事件、去标签字数上限预警
| Parameter | Type | Description |
|---|---|---|
file_path * | string | 正文 HTML 文件路径 |