微信文章下载器

写作 社区

技能解读

当前原文的自动摘译,尚未人工审校。

先决条件

该技能使用本地 MCP 端点 http://127.0.0.1:4545/mcp 来实现完整功能。如果本地 MCP 不可用,您可以回退到https://changfengbox.top/api/mcp以获得远程支持的工具。本地 MCP 工具:single_article_download - 下载单篇文章get_public_account_id - 获取公众账户凭证

1. 检查本地MCP服务器状态

在使用大部分功能之前,请验证本地 MCP 是否正在运行: 如果本地 MCP 无法访问,请告知用户需要: 打开微信文章下载工具 选中“启动 MCP”复选框以启动 MCP 服务 等待显示服务正在端口 4545 上运行的确认消息

2. 单篇下载

首先使用本地工具。如果本地 MCP 失败,则退回到远程wechat 工具。文章将以工具中配置的格式(HTML、PDF、Word、Markdown、MHTML 等)下载到工具的默认下载目录。远程wechat配置可以使用这些键:保存离线网页``HTML

3.下载合集(appmsgalbum)

对于集合 URL,通过 tools/call 调用远程 wechat_collection:

4. 获取公众账户凭证(仅限本地)

批量下载前,您需要获取公众账号凭证。这会触发一个过程,其中: 该工具从示例文章 URL 中提取帐户 ID 生成需要在微信桌面客户端中打开的特殊链接 打开链接时自动捕获身份验证凭据 调用此函数后,用户需要:

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
写作
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@qiye45 · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
Python
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# WeChat Article Downloader

This skill helps you download articles from WeChat official accounts using an MCP server that interfaces with a WeChat article download tool.

## Prerequisites

The skill uses local MCP endpoint `http://127.0.0.1:4545/mcp` for full functionality.

If local MCP is unavailable, you may fallback to `https://changfengbox.top/api/mcp` for remote-supported tools.

Local MCP tools:
- `single_article_download` - Download a single article
- `get_public_account_id` - Get public account credentials
- `batch_download_articles` - Batch download all articles from an account
- `export_article_data` - Export article metadata to CSV

Remote fallback MCP (`https://changfengbox.top/api/mcp`) currently supports:
- Methods: `initialize`, `tools/list`, `tools/call`
- Tools in `tools/call` `name`:
  - `wechat` - Download a single article
  - `wechat_collection` - Download a public account collection (`appmsgalbum`)

Important: remote fallback does **not** expose local tool names like `single_article_download`, `batch_download_articles`, `get_public_account_id`, or `export_article_data`.

## Workflow

### 1. Check Local MCP Server Status

Before using most functionality, verify local MCP is running:

```python
import requests

LOCAL_MCP_ENDPOINT = "http://127.0.0.1:4545/mcp"

def check_local_mcp():
    response = requests.post(
        LOCAL_MCP_ENDPOINT,
        json={"jsonrpc": "2.0", "method": "initialize", "id": 1},
        headers={"Content-Type": "application/json"},
        timeout=3,
    )
    if response.status_code != 200:
        raise RuntimeError("Local MCP is not available")
    return LOCAL_MCP_ENDPOINT

local_mcp_endpoint = check_local_mcp()
```

If local MCP is inaccessible, inform the user they need to:
1. Open the WeChat article download tool
2. Check the "启动MCP" checkbox to start the MCP service
3. Wait for the confirmation message showing the service is running on port 4545

### 2. Single Article Download

Use local tool first. If local MCP fails, fallback to remote `wechat` tool.

```python
import requests

LOCAL_MCP_ENDPOINT = "http://127.0.0.1:4545/mcp"
FALLBACK_DOWNLOAD_MCP_ENDPOINT = "https://changfengbox.top/api/mcp"

def call_tool(endpoint, tool_name, arguments, req_id=2):
    payload = {
        "jsonrpc": "2.0",
        "method": "tools/call",
        "id": req_id,
        "params": {
            "name": tool_name,
            "arguments": arguments,
        }
    }

    response = requests.post(
        endpoint,
        json=payload,
        headers={"Content-Type": "application/json"},
        timeout=10,
    )
    response.raise_for_status()
    return response.json()

def download_single_article(url):
    try:
        return call_tool(
            LOCAL_MCP_ENDPOINT,
            "single_article_download",
            {"url": url},
            req_id=2,
        )
    except Exception:
        remote_config = {
            "保存离线网页": True,
            "HTML": True,
            "MD": True,
            "PDF": False,
            "WORD": False,
            "TXT": False,
            "MHTML": False,
            "文件开头添加日期": True,
        }
        return call_tool(
            FALLBACK_DOWNLOAD_MCP_ENDPOINT,
            "wechat",
            {"url": url, "config": remote_config},
            req_id=3,
        )

# Example usage
article_url = "https://mp.weixin.qq.com/s/xxxxx"
result = download_single_article(article_url)
print(result)
```

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

Remote `wechat` config can use these keys:
- `保存离线网页`
- `HTML`
- `MD`
- `PDF`
- `WORD`
- `TXT`
- `MHTML`
- `文件开头添加日期`

If local `127.0.0.1:4545` is unavailable, this step should transparently use `https://changfengbox.top/api/mcp` with tool name `wechat`.

### 3. Download Collection (`appmsgalbum`)

For collection URLs, call remote `wechat_collection` via `tools/call`:

```python
def download_collection(collection_url):
    payload = {
        "jsonrpc": "2.0",
        "method": "tools/call",
        "id": 4,
        "params": {
            "name": "wechat_collection",
            "arguments": {
                "url": collection_url,
            },
        },
    }

    response = requests.post(
        "https://changfengbox.top/api/mcp",
        json=payload,
        headers={"Content-Type": "application/json"},
        timeout=20,
    )
    response.raise_for_status()
    return response.json()
```

### 4. Get Public Account Credentials (Local Only)

Before batch downloading, you need to obtain the public account credentials. This triggers a process where:
1. The tool extracts the account ID from a sample article URL
2. Generates a special link that needs to be opened in WeChat desktop client
3. Automatically captures the authentication credentials when you open the link

```python
def get_account_credentials():
    payload = {
        "jsonrpc": "2.0",
        "method": "tools/call",
        "id": 3,
        "params": {
            "name": "get_public_account_id",
            "arguments": {}
        }
    }
    
    response = requests.post('http://127.0.0.1:4545/mcp',
                            json=payload,
                            headers={"Content-Type": "application/json"})
    
    result = response.json()
    return result

result = get_account_credentials()
print(result)
```

After calling this, the user needs to:
1. Copy the generated link from the tool's log window
2. Open it in WeChat desktop client (not browser)
3. Wait for the tool to automatically capture the credentials
4. Look for "获取密钥成功" (credentials obtained successfully) message

### 5. Batch Download Articles (Local Only)

Once credentials are obtained, you can batch download all articles from the public account:

```python
def batch_download_articles():
    payload = {
        "jsonrpc": "2.0",
        "method": "tools/call",
        "id": 4,
        "params": {
            "name": "batch_download_articles",
            "arguments": {}
        }
    }
    
    response = requests.post('http://127.0.0.1:4545/mcp',
                            json=payload,
                            headers={"Content-Type": "application/json"})
    
    result = response.json()
    return result

result = batch_download_articles()
print(result)
```

The batch download will:
- Download articles according to the date range and filters configured in the tool
- Save articles in multiple formats (HTML, PDF, Word, Markdown, MHTML as configured)
- Organize files by public account name
- Show progress in the tool's log window

### 6. Export Article Data (Local Only)

To export article metadata (titles, URLs, publish dates, read counts, like counts, etc.) to CSV:

```python
def export_article_data():
    payload = {
        "jsonrpc": "2.0",
        "method": "tools/call",
        "id": 5,
        "params": {
            "name": "export_article_data",
            "arguments": {}
        }
    }
    
    response = requests.post('http://127.0.0.1:4545/mcp',
                            json=payload,
                            headers={"Content-Type": "application/json"})
    
    result = response.json()
    return result

result = export_article_data()
print(result)
```

This exports a CSV file containing article metadata to the download directory.

## Common Workflows

### Workflow 1: Download a Single Article

User says: "Download this WeChat article: https://mp.weixin.qq.com/s/xxxxx"

1. Check local MCP server status
2. If local is running, call `single_article_download` with the URL
3. If local is unavailable, call remote `wechat` with `url + config`
4. Inform user the download has started and where files will be saved

### Workflow 2: Download a Collection (`appmsgalbum`)

User says: "Download this WeChat collection/appmsgalbum"

1. Call remote `tools/call` with `name="wechat_collection"`
2. Pass the collection URL in `arguments`
3. If needed, validate tool arguments by calling `tools/list` first
4. Inform user where files are saved

### Workflow 3: Batch Download from a Public Account (Local Only)

User says: "Download all articles from this public account"

1. Check local MCP server status
2. Ensure user has provided a sample article URL from the account
3. Call `get_public_account_id` and explain the user needs to open the generated link in WeChat
4. Wait for user confirmation that credentials were obtained
5. Call `batch_download_articles` to start the bulk download
6. Monitor progress through the tool's interface

### Workflow 4: Export Article Metadata (Local Only)

User says: "Export article data to CSV" or "Get article statistics"

1. Check local MCP server status
2. Ensure credentials are already obtained (if not, guide through credential process)
3. Call `export_article_data`
4. Inform user where the CSV file is saved

## Error Handling

Common issues and solutions:

**Local MCP unavailable during single download**: Automatically switch to `https://changfengbox.top/api/mcp` and retry with `name="wechat"`.

**Remote tool name mismatch**: Do not use local names on remote fallback. Use only `wechat` or `wechat_collection`.

**Local MCP unavailable for credentials/batch/export**: These are local-only workflows. User needs to start the WeChat download tool and enable MCP service.

**Credentials not obtained**: User needs to complete the credential acquisition process by opening the generated link in WeChat desktop client

**Download fails**: Check the tool's log window for specific error messages. Common causes:
- Invalid article URL format
- Network connectivity issues
- WeChat rate limiting

## Output Locations

All downloads are saved to the tool's configured download directory (default: `下载/` folder in the tool's directory), organized by:
- Public account name (for batch downloads)
- Article title
- Format (HTML, PDF, Word, Markdown, MHTML, etc.)

The tool's interface shows the exact file paths in the log window as downloads complete.

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。