Skip to main content
Glama
weinh

wechat-mcp-publisher

by weinh

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)

工具

用途

create_news_draft

Article draft: accepts HTML (or a .html file path) + cover image; embedded <img> tags are automatically uploaded and replaced with WeChat URLs

create_newspic_draft

Image message draft: plain-text description + 1~20 images (in order)

list_drafts

Paginated draft box query

get_draft

Draft details (including body)

delete_draft

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_SECRET

Get 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-publisher

In 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_publisher

Project-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 pytest

All 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 verification

  • Personal 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

Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Publish Markdown or HTML to a shareable link from your AI assistant. OAuth, no API keys.

  • 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.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/weinh/wechat_mcp_publisher'

If you have feedback or need assistance with the MCP directory API, please join our Discord server