mmbiz-mcp
Provides tools for managing WeChat Official Account content through the WeChat backend API, including creating and updating drafts, uploading article and cover images, managing permanent materials, publishing drafts, and checking publish status.
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., "@mmbiz-mcp 把 ~/blog/posts/mcp-intro.md 保存为公众号草稿,封面用 ~/blog/images/cover.jpg"
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.
mmbiz-mcp
微信公众号后台管理的 MCP 服务。接入 Cursor、Claude Desktop 等支持 MCP 的 agent 后,可以直接让 agent 帮你写稿、上传图片、保存草稿、发布文章。
功能
工具 | 说明 |
| 新建草稿(支持多篇、Markdown 正文、正文图片自动上传、封面自动上传) |
| 修改草稿中的某一篇文章 |
| 查询草稿 |
| 删除草稿 |
| 上传正文图片(jpg/png ≤1MB),返回可用于 |
| 上传永久图片素材,返回 |
| 管理永久素材 |
| 发布草稿并查询结果 |
几个对 agent 友好的细节:
图片来源灵活:所有图片参数都支持本地路径、
file://、http(s)://链接和data:URI。正文图片自动转存:微信不显示外链图片,
wechat_create_draft/wechat_update_draft默认会把正文里非微信域名的图片上传到微信并替换链接(可用localize_images: false关闭)。上传前本地校验:按微信规则检查图片格式与大小,避免浪费接口调用次数。
access_token 自动管理:使用
stable_token接口(不会让其他服务持有的 token 失效),自动缓存、提前刷新,遇到 token 失效自动刷新重试一次。错误可读:常见错误码附带中文提示(例如 IP 白名单、接口权限、配额)。
Related MCP server: WeChat Official Account MCP Server
准备工作
在 微信公众平台 → 设置与开发 → 基本配置 中获取 AppID 和 AppSecret。
在同一页面把运行本服务的机器的出口 IP 加入 IP 白名单,否则会返回
40164。草稿与发布接口需要公众号具备相应权限(一般需认证)。
安装与配置
运行需要 Node.js ≥ 20(开发与跑测试需要 ≥ 22.12)。
git clone https://github.com/Siubaak/mmbiz-mcp.git
cd mmbiz-mcp
npm install
npm run build在 MCP 客户端中配置(以 Cursor 的 ~/.cursor/mcp.json 或 Claude Desktop 的 claude_desktop_config.json 为例):
{
"mcpServers": {
"wechat-mp": {
"command": "node",
"args": ["/绝对路径/mmbiz-mcp/dist/index.js"],
"env": {
"WECHAT_APP_ID": "wx...",
"WECHAT_APP_SECRET": "..."
}
}
}
}环境变量 | 必填 | 说明 |
| 是 | 公众号 AppID |
| 是 | 公众号 AppSecret |
| 否 | 默认 |
使用示例
对 agent 说:
把
~/blog/posts/mcp-intro.md保存为公众号草稿,封面用~/blog/images/cover.jpg,作者写“小明”。
agent 会调用 wechat_create_draft:
{
"articles": [
{
"title": "MCP 入门",
"content": "# MCP 入门\n\n\n\n正文……",
"content_format": "markdown",
"thumb_image": "/Users/me/blog/images/cover.jpg",
"author": "小明"
}
]
}返回草稿的 media_id,以及本次自动上传的正文图片和封面素材,之后可在公众平台“草稿箱”中预览和编辑。wechat_publish_draft 会让文章公开可见,只建议在明确需要时让 agent 调用。
开发
项目按 TDD 开发,所有微信接口在测试中以假的 fetch 模拟,MCP 工具通过 SDK 的内存传输端到端测试,另有一个通过 stdio 启动真实子进程的集成测试。
npm test # 运行测试
npm run test:watch
npm run typecheck
npm run build
npm run dev # 用 tsx 直接运行源码目录结构:
src/
config.ts 环境变量读取
errors.ts 微信错误码与中文提示
token.ts stable access_token 缓存与刷新
client.ts 微信 API 客户端(草稿 / 素材 / 发布)
media.ts 图片加载(路径 / URL / data URI)与格式大小校验
content.ts Markdown 转 HTML、正文图片转存
server.ts MCP 工具定义
index.ts stdio 入口
test/ 与 src 一一对应的测试License
MIT
Available Tools
14 toolswechat_count_drafts草稿总数CRead-only
获取草稿总数。
Inputs: no named parameters.
wechat_count_materials永久素材总数BRead-only
获取各类型永久素材的数量。
Inputs: no named parameters.
wechat_create_draft新建草稿A
新建图文草稿(可包含多篇文章),返回草稿 media_id。支持 Markdown 正文;默认会把正文中的本地/外链图片自动上传到微信并替换链接;封面可传已有 thumb_media_id 或图片来源 thumb_image。
Inputs: articles (required).
wechat_delete_draft删除草稿ADestructive
删除指定草稿。此操作不可撤销。
Inputs: media_id (required).
wechat_delete_material删除永久素材ADestructive
删除指定永久素材。此操作不可撤销,使用该素材的草稿封面可能失效。
Inputs: media_id (required).
wechat_get_draft获取草稿BRead-only
获取草稿详情(包含每篇文章的标题、正文、封面、预览链接等)。
Inputs: media_id (required).
wechat_get_publish_status查询发布状态BRead-only
根据 publish_id 查询发布状态;成功时返回 article_id 与文章链接。
Inputs: publish_id (required).
wechat_list_drafts草稿列表ARead-only
分页获取草稿列表,按更新时间倒序。默认不返回正文内容以节省篇幅。
Inputs: count, offset, no_content.
wechat_list_materials永久素材列表CRead-only
分页获取永久素材列表。
Inputs: type, count, offset.
wechat_list_published已发布文章列表BRead-only
分页获取已成功发布的文章列表。
Inputs: count, offset, no_content.
wechat_publish_draft发布草稿ADestructive
将草稿提交发布(发布后内容对外可见,且不会推送给粉丝/不占群发次数)。发布是异步的,返回 publish_id,请用 wechat_get_publish_status 查询结果。仅在用户明确要求发布时调用。
Inputs: media_id (required).
wechat_update_draft修改草稿A
整体替换草稿中指定位置(index,从 0 开始)的一篇文章。参数与新建草稿中的单篇文章一致。
Inputs: article (required), media_id (required), index.
wechat_upload_article_image上传正文图片A
上传文章正文内使用的图片(仅 jpg/png,≤1MB),返回可直接写入 的微信图片 URL。不占用素材库数量限制。
Inputs: source (required).
wechat_upload_image_material上传永久图片素材A
上传永久图片素材到素材库,返回 media_id(可作为草稿封面 thumb_media_id)和 url。type=image 支持 bmp/png/jpeg/jpg/gif(≤10MB);type=thumb 仅 jpg(≤64KB)。
Inputs: source (required), type.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Most tools target a distinct resource+action pair, but two upload tools (wechat_upload_article_image vs wechat_upload_image_material) could be momentarily confused, though their descriptions clearly separate inline images from permanent materials. The near-trivial wechat_count_materials and wechat_count_drafts are distinguishable but add slight noise to the draft/material distinction.
All 14 tools follow a uniform wechat_<verb>_<noun> snake_case pattern (create/get/list/update/delete/publish/count). Minor variation in noun ordering between the two upload tools does not break predictability.
14 tools is well within a healthy range for a WeChat MP publishing workflow and each maps to a real operation. Nothing feels padded beyond the two optional count helpers.
Draft lifecycle is fully covered (create/update/get/list/delete/count plus publish and status polling) and materials have upload/list/count/delete. Gaps are minor: no get-material-by-media_id and no update of an existing material, which agents can work around by re-uploading.
Maintenance
Related MCP Connectors
Write, edit, translate and publish blog and help-center articles across all your sites.
Agent-first social media publishing, scheduling, analytics, and unified inbox API + 16-tool MCP server across 18 social platforms (X, LinkedIn, Instagram, YouTube, TikTok, Threads, Bluesky, Reddit, Telegram, Discord, Mastodon, Facebook, Pinterest).
Agent control plane for multi-site content ops: research, drafts, review, CMS draft delivery.
Draft, schedule and publish social media posts from AI agents, under workspace approval rules.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI applications to manage WeChat Official Accounts through standardized tools for authentication, media uploads, draft creation, article publishing, and permanent material management.90 npm67MIT
- 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.-
- 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.526-