Wechat Article For Ai logo

Wechat Article For Ai

Community
bzd6661

微信公众号文章转 Markdown 工具 | AI Agent 可直接调用的 MCP Server + Skill | Camoufox 反检测、自动重试、批量处理、图片本地化

Publisherbzd6661
Repositorywechat-article-for-ai
LanguagePython
Forks
14
Stars
103
Available tools
0
Transport typestdio
Categories
Links
  • Connect tools to AI workflows

    Wechat Article For Ai exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    103 stars and 14 forks from the linked repository.

wechat-article-for-ai

English | 中文


English

A modular Python tool that converts WeChat Official Account (微信公众号) articles into clean Markdown files with locally downloaded images. Designed for both human use (CLI) and AI agent integration (MCP server + SKILL.md).

Features

  • Anti-detection scraping — Uses Camoufox (stealth Firefox) to bypass WeChat's bot detection
  • Smart page loading — networkidle wait instead of hardcoded sleep
  • Retry logic — 3× exponential backoff for page fetching, 3× linear backoff for image downloads
  • CAPTCHA detection — Explicit detection with actionable error messages
  • Batch processing — Multiple URLs via args or file input
  • Image localization — Concurrent async downloads with Content-Type based extension inference
  • Code block preservation — Language detection, CSS counter garbage filtering
  • Media extraction — Handles WeChat's <mpvoice> audio and <mpvideo> video elements
  • YAML frontmatter — Structured metadata (title, author, date, source)
  • MCP server — Expose as tools for any MCP-compatible AI client
  • SKILL.md — Ready for Claude Code skill integration

Installation

bash
git clone https://github.com/bzd6661/wechat-article-for-ai.git
cd wechat-article-for-ai
pip install -r requirements.txt

Camoufox browser will be auto-downloaded on first run.

Usage

CLI — Single Article

bash
python main.py "https://mp.weixin.qq.com/s/ARTICLE_ID"

CLI — Batch from File

bash
python main.py -f urls.txt -o ./output -v

CLI Options

FlagDescription
urlsOne or more WeChat article URLs
-f, --file FILEText file with URLs (one per line, # for comments)
-o, --output DIROutput directory (default: ./output)
-c, --concurrency NMax concurrent image downloads (default: 5)
--no-imagesSkip image download, keep remote URLs
--no-headlessShow browser window (for solving CAPTCHAs)
--forceOverwrite existing output
--no-frontmatterUse blockquote metadata instead of YAML frontmatter
-v, --verboseEnable debug logging

MCP Server

Run as an MCP server for AI tool integration:

bash
python mcp_server.py

Tools exposed:

  • convert_article — Convert a single WeChat article to Markdown
  • batch_convert — Convert multiple articles in one call

MCP client configuration (e.g. claude_desktop_config.json):

json
{
  "mcpServers": {
    "wechat-to-md": {
      "command": "python",
      "args": ["mcp_server.py"],
      "cwd": "/path/to/wechat-article-for-ai"
    }
  }
}

Output Structure

output/
  <article-title>/
    <article-title>.md
    images/
      img_001.png
      img_002.jpg
      ...

Project Structure

wechat_to_md/
  __init__.py        # Package init, public API
  errors.py          # CaptchaError, NetworkError, ParseError
  utils.py           # Logging, filename sanitizer, timestamp, image ext inference
  scraper.py         # Camoufox + networkidle + retry with exponential backoff
  parser.py          # BeautifulSoup: metadata, code blocks, media, noise removal
  converter.py       # markdownify + YAML frontmatter + image URL replacement
  downloader.py      # httpx async + retry per image + Content-Type inference
  cli.py             # argparse CLI with batch support
  mcp_server.py      # FastMCP server with convert_article / batch_convert
main.py              # CLI entry point
mcp_server.py        # MCP server entry point
SKILL.md             # AI skill definition

Troubleshooting

ProblemSolution
CAPTCHA / verification pageRun with --no-headless to solve manually
Empty contentWeChat may be rate-limiting; wait and retry
Image download failuresFailed images keep remote URLs; re-run with --force

License

MIT


中文

一个模块化的 Python 工具,将微信公众号文章转换为干净的 Markdown 文件并下载图片到本地。同时支持人工使用(CLI)和 AI 智能体集成(MCP 服务器 + SKILL.md)。

功能特点

  • 反检测抓取 — 使用 Camoufox(隐身 Firefox)绕过微信的反爬机制
  • 智能页面等待 — 使用 networkidle 替代硬编码的 sleep
  • 重试机制 — 页面加载 3 次指数退避重试,图片下载 3 次线性退避重试
  • 验证码检测 — 明确识别验证码页面并给出可操作的错误提示
  • 批量处理 — 支持多个 URL 参数或从文件读取
  • 图片本地化 — 异步并发下载,基于 Content-Type 推断图片格式
  • 代码块保留 — 自动检测编程语言,过滤 CSS 计数器垃圾文本
  • 媒体提取 — 处理微信的 <mpvoice> 音频和 <mpvideo> 视频元素
  • YAML 元数据 — 结构化的 frontmatter(标题、作者、日期、来源)
  • MCP 服务器 — 暴露为工具,供任何 MCP 兼容的 AI 客户端调用
  • SKILL.md — 可直接作为 Claude Code 技能使用

安装

bash
git clone https://github.com/bzd6661/wechat-article-for-ai.git
cd wechat-article-for-ai
pip install -r requirements.txt

Camoufox 浏览器会在首次运行时自动下载。

使用方法

CLI — 单篇文章

bash
python main.py "https://mp.weixin.qq.com/s/文章ID"

CLI — 批量转换

bash
python main.py -f urls.txt -o ./output -v

CLI 参数

参数说明
urls一个或多个微信文章链接
-f, --file 文件包含 URL 的文本文件(每行一个,# 为注释)
-o, --output 目录输出目录(默认:./output)
-c, --concurrency N图片下载最大并发数(默认:5)
--no-images跳过图片下载,保留远程链接
--no-headless显示浏览器窗口(用于手动解决验证码)
--force覆盖已有的输出目录
--no-frontmatter使用引用块格式的元数据,而非 YAML frontmatter
-v, --verbose启用调试日志

MCP 服务器

作为 MCP 服务器运行,供 AI 工具集成:

bash
python mcp_server.py

暴露的工具:

  • convert_article — 转换单篇微信文章为 Markdown
  • batch_convert — 批量转换多篇文章

MCP 客户端配置(如 claude_desktop_config.json):

json
{
  "mcpServers": {
    "wechat-to-md": {
      "command": "python",
      "args": ["mcp_server.py"],
      "cwd": "/path/to/wechat-article-for-ai"
    }
  }
}

输出结构

output/
  <文章标题>/
    <文章标题>.md
    images/
      img_001.png
      img_002.jpg
      ...

项目结构

wechat_to_md/
  __init__.py        # 包初始化,公共 API
  errors.py          # CaptchaError, NetworkError, ParseError
  utils.py           # 日志、文件名清理、时间戳、图片格式推断
  scraper.py         # Camoufox + networkidle + 指数退避重试
  parser.py          # BeautifulSoup:元数据、代码块、媒体、噪音移除
  converter.py       # markdownify + YAML frontmatter + 图片 URL 替换
  downloader.py      # httpx 异步 + 逐图重试 + Content-Type 推断
  cli.py             # argparse CLI,支持批量处理
  mcp_server.py      # FastMCP 服务器
main.py              # CLI 入口
mcp_server.py        # MCP 服务器入口
SKILL.md             # AI 技能定义文件

常见问题

问题解决方法
出现验证码 / 环境异常使用 --no-headless 手动解决验证码
内容为空微信可能在限流,等几分钟再试
图片下载失败失败的图片会保留远程链接,用 --force 重新运行

许可证

MIT

Installation

TypingMind
{
  "mcpServers": {
    "wechat-article-for-ai": {
      "command": "python",
      "args": [
        "mcp_server.py"
      ]
    }
  }
}

Use Wechat Article For Ai MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Wechat Article For Ai is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Wechat Article For Ai as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Wechat Article For Ai MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "wechat-article-for-ai": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Wechat Article For Ai MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Wechat Article For Ai MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Wechat Article For Ai to help me with this task?
Wechat Article For Ai
Sure. I read it.
Here is what I found using Wechat Article For Ai.

Frequently asked questions

What is the Wechat Article For Ai MCP server used for?

Wechat Article For Ai is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Wechat Article For Ai MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Wechat Article For Ai with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Wechat Article For Ai MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Wechat Article For Ai connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Wechat Article For Ai MCP to TypingMind?

Wechat Article For Ai runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Wechat Article For Ai MCP provide in TypingMind?

Wechat Article For Ai exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Wechat Article For Ai MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Wechat Article For Ai requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇