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-publisherPublish /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)的图片保持不变。
| Name | Required | Description | Default |
|---|---|---|---|
| cover | Yes | ||
| title | Yes | ||
| author | No | ||
| digest | No | ||
| content | Yes | ||
| content_source_url | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are present, so the description carries full responsibility. It discloses several non-obvious behaviors: content may be a file path that is auto-read, cover is auto-uploaded, <img> URLs are rewritten to WeChat-hosted URLs while WeChat-domain images are left intact, and an empty digest triggers automatic extraction. This is well beyond baseline.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with purpose and return value, then organized as a labeled parameter list. Every sentence adds operational value, including the image-handling note, with no filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a 6-parameter creation tool with an output schema, the description covers input formats, side effects, image handling, and return shape. No gaps remain for an agent to call it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema descriptions are 0% covered, and the description compensates fully by explaining each parameter (title, content with dual forms, cover with path/URL and auto-upload, author, digest fallback, content_source_url). It adds requiredness and behavioral nuances the schema lacks.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb ('创建' - create) and resource ('图文草稿(news)'), and names the successful return fields. It clearly identifies the tool's function and is distinguishable from sibling tools like delete_draft or list_drafts by the create/news-specific framing.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit comparison to siblings is provided. The intended use case (creating a news draft) is implied by the name and the headline phrase, but the description does not state when to choose this over create_newspic_draft or when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
create_newspic_draftA
创建图片消息草稿(newspic),成功返回 {"media_id": ..., "title": ..., "image_count": ...}。
参数:
title: 消息标题(必填)
images: 1~20 张图片,按传入顺序展示;每项为本地文件路径或 http(s) URL
content: 图片下方的纯文字说明(可选,注意不是 HTML)
与图文消息不同:图片消息的 content 是纯文本,图片本体在 images 中,
全部经永久素材接口上传后按序组装。
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | ||
| images | Yes | ||
| content | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full disclosure burden. It goes beyond basics by stating the success return structure, the 1-20 image limit, the ordering behavior, the plain-text nature of content, and that images are uploaded via the permanent material interface and assembled in order. This gives an agent a strong mental model of what invoking the tool does.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and front-loaded: purpose and return format come first, followed by a concise parameter list and a clarifying note about the difference from news messages. Every sentence adds value, with no filler or repetition.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a 3-parameter draft creation tool with an output schema, the description covers purpose, parameters with constraints, return format, and behavioral nuances. It also addresses the sibling distinction. Nothing essential for an agent to correctly select and invoke the tool is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Input schema coverage is 0%, so the description must fully explain parameters. It does: title is required, images allows 1-20 items with local file path or http(s) URL and ordering, content is optional plain text (explicitly not HTML). This adds substantial meaning beyond the raw schema fields.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb and resource: '创建图片消息草稿' (create image message draft), which clearly states what the tool does. It also distinguishes itself from the related '图文消息' (news/image-text) concept, helping an agent differentiate it from sibling tools without ambiguity.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context by contrasting with 图文消息: it explicitly notes that image message content is plain text and the images are in the images parameter, which implies when this tool is appropriate. However, it does not explicitly name the sibling tool (create_news_draft) or state a direct 'use this when, use that instead' rule, so it falls just short of fully explicit guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
delete_draftA
删除指定草稿,成功返回 {"media_id": ..., "deleted": true}。
注意:删除草稿不会连带删除其占用的永久素材图片(微信行为)。
参数:
media_id: 草稿 ID
| Name | Required | Description | Default |
|---|---|---|---|
| media_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It does disclose a critical behavioral trait beyond the schema: deleting a draft does not delete the associated permanent materials (微信行为). It also shows the success return shape. For a tool with zero annotations, this is meaningful behavioral disclosure, although it falls short of full transparency (e.g., no error behavior, no idempotency note, no permission requirements).
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact: two sentences plus a one-item parameter list. The key behavioral warning (does not delete associated permanent materials) is front-loaded in the attention paragraph before the parameter list. Every sentence earns its place; no filler or redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool has only one parameter, an output schema exists, and the description adds the success return and the critical non-cascade deletion behavior. For a simple delete tool, this is largely complete. Missing minor items could include error conditions, idempotency, or permission requirements, but the description's length and clarity are appropriate for the level of complexity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It does add meaning by explaining media_id is the draft ID and it's the sole parameter, and the success response references it. However, it only repeats the schema's 'Media Id' notion with '草稿 ID' and doesn't add more depth such as where to find this ID or constraints on the value. Basic useful compensation for one required parameter, but not rich enough for a higher score.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('删除') with a clear resource ('指定草稿'), satisfying the purpose statement requirement of verb+resource. It explicitly states the success return value, and although siblings exist for managing drafts (create, list, get), this delete operation is clearly distinguished by the delete semantics and the mention of behavior that only deletion triggers (永久素材 not being released).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context for when to use the tool: when deleting a specified draft by media_id. It does not explicitly name alternatives or exclusions, but sibling tools are self-evidently create/list/get, and the delete action is unambiguous. Strong context for a simple delete router, though it could have explicitly said 'use get_draft/list_drafts to find drafts, not this tool.'
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_draftA
查询草稿详情(含 news_item 全部字段:标题、正文 HTML、封面等)。
参数:
media_id: 草稿 ID(由 create_news_draft / create_newspic_draft 返回,或从 list_drafts 获取)
| Name | Required | Description | Default |
|---|---|---|---|
| media_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the burden of disclosing behavior. It discloses the output contents—title, body HTML, cover—and implies a read-only operation via '查询', but it does not mention error cases, permissions, or side effects. This is acceptable for a simple retrieval tool but not exhaustive.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact and front-loaded: one sentence states the purpose and return contents, and one line defines the parameter. There is no redundant phrasing or repetition of schema information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple retrieval tool with one required parameter and an output schema, the description is nearly complete: it covers what is returned and where the ID comes from. The remaining gaps are explicit usage differentiation from sibling tools and edge-case behavior, which are minor but would improve completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0% and the schema only provides type/title. The description compensates fully by explaining that media_id is the draft ID returned by the draft-creation tools or obtainable from list_drafts, which is exactly the semantic information an agent needs to populate the parameter correctly.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific action (查询草稿详情) on a specific resource (draft identified by media_id), and further specifies that it returns the full news_item fields including title, body HTML, and cover. This clearly distinguishes it from the sibling create/list/delete tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives useful operational guidance by explaining where media_id comes from (create_news_draft, create_newspic_draft, or list_drafts). However, it does not explicitly state when to prefer get_draft over list_drafts or how it differs from them; the when-to-use context is only implied by the verb 'get' and the mention of '详情'.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_draftsA
分页查询草稿箱列表,返回 {"total": 总数, "offset": 当前偏移, "items": [{media_id, title, update_time}]}。
参数:
offset: 起始位置(默认 0)
count: 每页数量(默认 20,最大 20)
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | ||
| offset | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
无 annotations,描述承担了行为披露责任。它补充了分页行为(offset/count 默认值、count 上限 20)以及返回结构(total/offset/items 及字段),足以让代理理解这是只读查询并预知响应。但未说明排序、错误处理或鉴权等边界情况。
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
描述采用两段式结构:先给出返回格式,再列出参数说明。没有冗余内容,信息密度高且易于扫描。
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
对于只有两个可选参数的列表查询工具,描述覆盖了调用所需的核心信息:分页参数、默认值、上限和返回结构。虽然未涉及排序或错误处理,但结合输出 schema 已足以支持正确调用。
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
输入 schema 的参数没有描述,覆盖率为 0%,但描述为 offset 提供了“起始位置”的语义,为 count 提供了“每页数量”的语义,并补充了最大值为 20 的限制。描述有效补偿了 schema 的空白。
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
描述明确说明工具用于“分页查询草稿箱列表”,动词和资源清晰,且与兄弟工具(创建草稿、获取单个草稿、删除草稿)形成明显区分。即使不看名字,也能知道这是列表查询操作。
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
描述隐含了“需要草稿列表时使用此工具”的用法,但未显式说明何时不该使用,也未与 get_draft 或创建类工具做取舍对比。用法可推断,但缺少明确指引。
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v0.1.0- First observed
create_news_draft - First observed
create_newspic_draft - First observed
delete_draft - First observed
get_draft - First observed
list_drafts
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 Markdown or HTML to a shareable link from your AI assistant. OAuth, no API keys.
- StacktreeOAuthee.stacktr
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.
把 Agent 为客户生成的方案发布成客户专属的微信/手机可读链接,收回客户看了什么、说了什么,再交回 Agent 改下一版。需授权(OAuth 2.1 或 API token)。
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 gradedqualityCmaintenanceBridges 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.91 npm1,313Apache 2.0
- FlicenseAqualityFmaintenanceEnables AI agents to publish articles to WeChat Official Account (微信公众号). Supports image upload, draft creation, and publishing via standardized MCP protocol.51-