wechat-mcp-publisher
这个 MCP 服务器把微信公众号草稿发布能力封装为 5 个工具,可自动完成图片上传、封面处理、HTML 正文转换和草稿管理。
创建图文草稿:提供 HTML 或 .html 路径、封面图、标题/摘要/作者/原文链接,自动上传正文 并替换为微信 URL。
创建图片消息草稿:传入标题、1~20 张图片和纯文字说明,按序生成图片消息草稿。
查看草稿箱:分页列出草稿(total/offset/items)。
查看草稿详情:按 media_id 获取含正文 HTML、封面等完整字段。
删除草稿:按 media_id 删除,但不删除素材图片。
内部自动处理 access_token 获取、缓存与失效刷新,错误返回中文处置提示。
Provides tools for creating WeChat Official Account drafts, including HTML article drafts with automatic image upload and replacement with WeChat URLs, image-message drafts, and draft listing, retrieval, and deletion.
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-mcp-publisher Publish /path/article.html as a WeChat draft with cover /path/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.
wechat-mcp-publisher
WeChat Official Account draft publishing local MCP tool. It turns "written HTML → Official Account draft box" into a single LLM tool call: image upload, inline image replacement in the article body with WeChat URLs, cover material, and draft creation are all automated.
Based on the official mcp SDK (2.x MCPServer), stdio transport, single account, uv-managed dependencies.
Tools (5)
工具 | 用途 |
| Article draft: accepts HTML (or a |
| Image message draft: plain-text description + 1~20 images (in order) |
| Paginated draft box query |
| Draft details (including body) |
| Delete draft (does not delete materials along with it) |
The access_token is obtained internally, cached, and self-heals on expiration (stable_token + automatic refresh and retry once on 40001/42001); it is not exposed as a tool. Errors are uniformly converted into Chinese messages with handling suggestions (e.g., 40164 prompts adding the IP allowlist, 48001 prompts a verified account), and they contain no credentials.
Related MCP server: WeChat Official Account MCP Server
Installation
uv sync
cp .env.example .env # 填入 WECHAT_APP_ID / WECHAT_APP_SECRETGet credentials: mp.weixin.qq.com → Settings & Development → Basic Configuration. On the same page, add this machine's public IP to the IP allowlist, otherwise token retrieval returns 40164.
Once published to PyPI, you can also run it directly without cloning (in a directory containing .env):
uvx wechat-mcp-publisher
# 或 pip install wechat-mcp-publisher && wechat-mcp-publisherIn this case, the MCP client configuration can be simplified to "command": "uvx", "args": ["wechat-mcp-publisher"].
Connecting to MCP clients
Claude Code (recommended, one command):
claude mcp add wechat-mcp-publisher -- uv run --directory /你的路径/wechat-mcp-publisher python -m wechat_mcp_publisherProject-level configuration (this repository already includes .mcp.json, which takes effect when Claude Code is opened in this repository's directory; on first use, confirm trust in /mcp): no manual addition is required.
Claude Desktop / other clients: merge the snippet from examples/mcp-client-config.example.json into the corresponding configuration file.
Usage examples
Say to the LLM:
Help me publish /path/article.html as an Official Account article draft, using /path/cover.jpg as the cover.
Or for an image message:
Send these three images /a.jpg /b.jpg /c.jpg as an image message draft, with the caption: weekend shots.
A real API pipeline demo is available at examples/simple_usage.py (token → upload → create draft; also serves as a live smoke test).
Testing
uv run pytestAll endpoints are mocked via responses, so they can be run successfully without a real account.
Scope and known limitations
No markdown→HTML conversion: the article body input is HTML; use your existing md→html tool for conversion
No publishing (
freepublish): currently only goes as far as drafts; publishing is left for extension after account verificationPersonal unverified subscription accounts: the material/draft APIs return
48001; live verification requires a verified account (development and testing are unaffected)HTML WeChat compatibility: the WeChat editor only accepts a subset of HTML with inline styles; layout adaptation is handled by the upstream conversion tool; this tool neither validates nor fixes it
Material buildup: deleting a draft does not delete the permanent material images it occupies; with long-term use, clean them up occasionally in the Official Account backend
Single account: credentials come from
.env; no multi-account switching is provided
Available Tools
5 toolscreate_news_draftA
创建图文草稿(news),成功返回 {"media_id": ..., "title": ..., "cover_url": ...}。
参数:
title: 文章标题(必填)
content: 正文。支持两种形态——HTML 字符串,或本地 .html 文件路径
(若该路径存在则自动读取文件,否则按 HTML 内容处理)
cover: 封面图片(必填):本地文件路径或 http(s) URL,自动上传为封面素材
author: 作者名(可选)
digest: 摘要(可选,留空时微信自动截取正文)
content_source_url: 原文链接(可选)
正文 HTML 中的 <img> 会自动上传到微信并替换 src 为微信托管的 URL;
已指向微信域名(mmbiz.qpic.cn / mp.weixin.qq.com)的图片保持不变。
Inputs: cover (required), title (required), content (required), author, +2 more. Returns: object
create_newspic_draftA
创建图片消息草稿(newspic),成功返回 {"media_id": ..., "title": ..., "image_count": ...}。
参数:
title: 消息标题(必填)
images: 1~20 张图片,按传入顺序展示;每项为本地文件路径或 http(s) URL
content: 图片下方的纯文字说明(可选,注意不是 HTML)
与图文消息不同:图片消息的 content 是纯文本,图片本体在 images 中,
全部经永久素材接口上传后按序组装。
Inputs: title (required), images (required), content. Returns: object
delete_draftA
删除指定草稿,成功返回 {"media_id": ..., "deleted": true}。
注意:删除草稿不会连带删除其占用的永久素材图片(微信行为)。
参数:
media_id: 草稿 ID
Inputs: media_id (required). Returns: object
get_draftA
查询草稿详情(含 news_item 全部字段:标题、正文 HTML、封面等)。
参数:
media_id: 草稿 ID(由 create_news_draft / create_newspic_draft 返回,或从 list_drafts 获取)
Inputs: media_id (required). Returns: object
list_draftsA
分页查询草稿箱列表,返回 {"total": 总数, "offset": 当前偏移, "items": [{media_id, title, update_time}]}。
参数:
offset: 起始位置(默认 0)
count: 每页数量(默认 20,最大 20)
Inputs: count, offset. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
The two create tools are clearly separated by draft type (newspic vs news) with distinct parameter semantics, while list, get, and delete have unambiguous scopes. No two tools appear to overlap in purpose.
Most tools follow a verb_noun snake_case pattern such as list_drafts, get_draft, and delete_draft. The create tools also align with verb+type+draft, though 'newspic' vs 'news' is a slightly non-parallel naming choice.
Five tools is well-scoped for a draft-management server: two creation variants plus standard list, get, and delete operations. Each tool earns its place without unnecessary overlap or bloat.
The set covers create, read/list, and delete for drafts, but lacks an update_draft operation, forcing agents to delete and recreate to modify content. Additionally, despite the 'publisher' name, there is no publish/send tool, leaving a notable gap in the apparent domain.
Maintenance
Related MCP Connectors
Publish HTML or markdown from your agent as a shareable link, with password or work-email walls. No key needed to start: your agent can create the account and verify the email right from the chat, then publish.
Publish HTML to private, unguessable, replace-in-place URLs from any MCP-compatible AI agent.
Publish to self-hosted WordPress from AI agents: markdown, images, SEO, and Notion sync.
Publish AI-generated HTML & Markdown to a hosted, shareable URL via MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables saving articles to WeChat Official Account drafts with support for rich text, automatic image upload, and Markdown rendering including Mermaid diagrams.1MIT
- 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.93 npm1,357Apache 2.0
- AlicenseAqualityFmaintenanceEnables AI agents to publish articles to WeChat Official Account (微信公众号). Supports image upload, draft creation, and publishing via standardized MCP protocol.51ISC