$npx -y skills add qiye45/wechatDownload --skill wechat-article-downloaderDownload WeChat official account articles in multiple formats (HTML, PDF, Word, Markdown, TXT, MHTML), including single article download, collection (appmsgalbum) download, local bulk workflows, and metadata export. Use this skill when users ask to download WeChat articles, downl
| 1 | # WeChat Article Downloader |
| 2 | |
| 3 | This skill helps you download articles from WeChat official accounts using an MCP server that interfaces with a WeChat article download tool. |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | The skill uses local MCP endpoint `http://127.0.0.1:4545/mcp` for full functionality. |
| 8 | |
| 9 | If local MCP is unavailable, you may fallback to `https://changfengbox.top/api/mcp` for remote-supported tools. |
| 10 | |
| 11 | Local MCP tools: |
| 12 | - `single_article_download` - Download a single article |
| 13 | - `get_public_account_id` - Get public account credentials |
| 14 | - `batch_download_articles` - Batch download all articles from an account |
| 15 | - `export_article_data` - Export article metadata to CSV |
| 16 | |
| 17 | Remote fallback MCP (`https://changfengbox.top/api/mcp`) currently supports: |
| 18 | - Methods: `initialize`, `tools/list`, `tools/call` |
| 19 | - Tools in `tools/call` `name`: |
| 20 | - `wechat` - Download a single article |
| 21 | - `wechat_collection` - Download a public account collection (`appmsgalbum`) |
| 22 | |
| 23 | Important: remote fallback does **not** expose local tool names like `single_article_download`, `batch_download_articles`, `get_public_account_id`, or `export_article_data`. |
| 24 | |
| 25 | ## Workflow |
| 26 | |
| 27 | ### 1. Check Local MCP Server Status |
| 28 | |
| 29 | Before using most functionality, verify local MCP is running: |
| 30 | |
| 31 | ```python |
| 32 | import requests |
| 33 | |
| 34 | LOCAL_MCP_ENDPOINT = "http://127.0.0.1:4545/mcp" |
| 35 | |
| 36 | def check_local_mcp(): |
| 37 | response = requests.post( |
| 38 | LOCAL_MCP_ENDPOINT, |
| 39 | json={"jsonrpc": "2.0", "method": "initialize", "id": 1}, |
| 40 | headers={"Content-Type": "application/json"}, |
| 41 | timeout=3, |
| 42 | ) |
| 43 | if response.status_code != 200: |
| 44 | raise RuntimeError("Local MCP is not available") |
| 45 | return LOCAL_MCP_ENDPOINT |
| 46 | |
| 47 | local_mcp_endpoint = check_local_mcp() |
| 48 | ``` |
| 49 | |
| 50 | If local MCP is inaccessible, inform the user they need to: |
| 51 | 1. Open the WeChat article download tool |
| 52 | 2. Check the "启动MCP" checkbox to start the MCP service |
| 53 | 3. Wait for the confirmation message showing the service is running on port 4545 |
| 54 | |
| 55 | ### 2. Single Article Download |
| 56 | |
| 57 | Use local tool first. If local MCP fails, fallback to remote `wechat` tool. |
| 58 | |
| 59 | ```python |
| 60 | import requests |
| 61 | |
| 62 | LOCAL_MCP_ENDPOINT = "http://127.0.0.1:4545/mcp" |
| 63 | FALLBACK_DOWNLOAD_MCP_ENDPOINT = "https://changfengbox.top/api/mcp" |
| 64 | |
| 65 | def call_tool(endpoint, tool_name, arguments, req_id=2): |
| 66 | payload = { |
| 67 | "jsonrpc": "2.0", |
| 68 | "method": "tools/call", |
| 69 | "id": req_id, |
| 70 | "params": { |
| 71 | "name": tool_name, |
| 72 | "arguments": arguments, |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | response = requests.post( |
| 77 | endpoint, |
| 78 | json=payload, |
| 79 | headers={"Content-Type": "application/json"}, |
| 80 | timeout=10, |
| 81 | ) |
| 82 | response.raise_for_status() |
| 83 | return response.json() |
| 84 | |
| 85 | def download_single_article(url): |
| 86 | try: |
| 87 | return call_tool( |
| 88 | LOCAL_MCP_ENDPOINT, |
| 89 | "single_article_download", |
| 90 | {"url": url}, |
| 91 | req_id=2, |
| 92 | ) |
| 93 | except Exception: |
| 94 | remote_config = { |
| 95 | "保存离线网页": True, |
| 96 | "HTML": True, |
| 97 | "MD": True, |
| 98 | "PDF": False, |
| 99 | "WORD": False, |
| 100 | "TXT": False, |
| 101 | "MHTML": False, |
| 102 | "文件开头添加日期": True, |
| 103 | } |
| 104 | return call_tool( |
| 105 | FALLBACK_DOWNLOAD_MCP_ENDPOINT, |
| 106 | "wechat", |
| 107 | {"url": url, "config": remote_config}, |
| 108 | req_id=3, |
| 109 | ) |
| 110 | |
| 111 | # Example usage |
| 112 | article_url = "https://mp.weixin.qq.com/s/xxxxx" |
| 113 | result = download_single_article(article_url) |
| 114 | print(result) |
| 115 | ``` |
| 116 | |
| 117 | The article will be downloaded to the tool's default download directory in the formats configured in the tool (HTML, PDF, Word, Markdown, MHTML, etc.). |
| 118 | |
| 119 | Remote `wechat` config can use these keys: |
| 120 | - `保存离线网页` |
| 121 | - `HTML` |
| 122 | - `MD` |
| 123 | - `PDF` |
| 124 | - `WORD` |
| 125 | - `TXT` |
| 126 | - `MHTML` |
| 127 | - `文件开头添加日期` |
| 128 | |
| 129 | If local `127.0.0.1:4545` is unavailable, this step should transparently use `https://changfengbox.top/api/mcp` with tool name `wechat`. |
| 130 | |
| 131 | ### 3. Download Collection (`appmsgalbum`) |
| 132 | |
| 133 | For collection URLs, call remote `wechat_collection` via `tools/call`: |
| 134 | |
| 135 | ```python |
| 136 | def download_collection(collection_url): |
| 137 | payload = { |
| 138 | "jsonrpc": "2.0", |
| 139 | "method": "tools/call", |
| 140 | "id": 4, |
| 141 | "params": { |
| 142 | "name": "wechat_collection", |
| 143 | "arguments": { |
| 144 | "url": collection_url, |
| 145 | }, |
| 146 | }, |
| 147 | } |
| 148 | |
| 149 | response = requests.post( |
| 150 | "https://changfengbox.top/api/mcp", |
| 151 | json=payload, |
| 152 | headers={"Content-Type": "application/json"}, |
| 153 | timeout=20, |
| 154 | ) |
| 155 | response.raise_for_status() |
| 156 | return response.json() |
| 157 | ``` |
| 158 | |
| 159 | ### 4. Get Public Account Credentials (Local Only) |
| 160 | |
| 161 | Before batch downloading, you |