WeChat Article Parser

WeChat Article Parser

Enables parsing and extracting content from WeChat public account articles using browser simulation, supporting multiple output formats (JSON, Markdown, HTML) and media resource extraction.

Category
Visit Server

README

微信公众号文章解析 MCP 服务器

基于 FastMCP 框架的微信公众号文章解析服务器,可以模拟浏览器访问微信公众号文章,提取文章内容、媒体资源等信息。

功能特点

  • 使用 Playwright 模拟浏览器访问微信公众号文章
  • 提取文章标题、作者、发布日期、正文内容等信息
  • 支持多种输出格式:JSON、Markdown、HTML、纯文本
  • 可提取文章中的图片、视频等媒体资源
  • 支持清理广告、推荐等干扰内容
  • 支持 HTTP 和 STDIO 两种传输协议

安装

环境要求

  • Python 3.10 或更高版本
  • Playwright 支持的操作系统

安装步骤

  1. 克隆仓库
git clone https://github.com/yourusername/mcp-server-wechat-article.git
cd mcp-server-wechat-article
  1. 安装依赖
pip install -e .
  1. 安装 Playwright 浏览器
playwright install chromium

使用方法

使用 fastmcp dev 进行调试

FastMCP 提供了便捷的开发工具,可以快速启动服务器并进行交互式调试:

# 进入项目目录
cd mcp-server-wechat-article

# 使用 fastmcp dev 启动服务器
fastmcp dev src/mcp_server_wechat_article/server.py

这将启动 MCP Inspector UI(通常在端口 5173),你可以通过浏览器访问并测试服务器功能。

安装到 Claude Desktop

使用 fastmcp install 命令可以将服务器安装到 Claude Desktop:

fastmcp install src/mcp_server_wechat_article/server.py

配置传输协议

服务器支持两种传输协议:

  1. STDIO(默认):适用于本地/Claude Desktop
  2. HTTP:适用于远程访问/多客户端

可以通过环境变量配置传输协议:

# 使用 HTTP 传输协议
export MCP_TRANSPORT=http
export MCP_HOST=127.0.0.1
export MCP_PORT=8000

# 启动服务器
python -m mcp_server_wechat_article.server

可用工具

parse_article

解析微信公众号文章,提取标题、作者、内容等信息。

参数

  • url: 微信公众号文章的完整URL
  • format: 输出格式,可选 'json', 'markdown', 或 'html'
  • include_media: 是否包含媒体资源信息
  • response_type: 响应详细程度,可选 'concise' 或 'detailed'

示例

parse_article(url="https://mp.weixin.qq.com/s/example123")
parse_article(url="https://mp.weixin.qq.com/s/example123", format="markdown", include_media=True)

extract_article_content

提取微信公众号文章的纯内容,支持多种格式输出。

参数

  • url: 微信公众号文章的完整URL
  • format: 输出格式,可选 'text', 'json', 'markdown', 或 'html'
  • extract_images: 是否提取图片URL
  • clean_content: 是否清理内容(移除广告、推荐等)
  • include_metadata: 是否包含元数据(标题、作者等)

示例

extract_article_content(url="https://mp.weixin.qq.com/s/example123")
extract_article_content(url="https://mp.weixin.qq.com/s/example123", format="markdown", extract_images=True)

环境变量

  • MCP_TRANSPORT: 传输协议,可选 'stdio' 或 'http',默认为 'http'
  • MCP_HOST: HTTP 服务器主机,默认为 '127.0.0.1'
  • MCP_PORT: HTTP 服务器端口,默认为 8000
  • BROWSER_TYPE: 浏览器类型,可选 'chromium', 'firefox', 或 'webkit',默认为 'chromium'
  • BROWSER_HEADLESS: 是否使用无头模式,可选 'true' 或 'false',默认为 'true'
  • DOCKER_ENV: 是否在 Docker 环境中运行,可选 'true' 或 'false',默认为 'false'

开发

项目结构

mcp-server-wechat-article/
├── src/
│   └── mcp_server_wechat_article/
│       ├── server.py          # MCP server 主文件
│       ├── tools/
│       │   ├── __init__.py
│       │   ├── parse_article.py
│       │   └── extract_article_content.py
│       └── utils/
│           ├── __init__.py
│           ├── api_client.py  # API 请求辅助
│           ├── browser_manager.py # 浏览器管理
│           ├── formatters.py  # 响应格式化
│           └── errors.py      # 错误处理
├── pyproject.toml
├── README.md
└── tests/

添加新工具

要添加新工具,请按照以下步骤操作:

  1. tools/ 目录下创建新的工具文件
  2. 使用 Pydantic 定义输入模型
  3. 实现工具逻辑
  4. server.py 中注册工具

许可证

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured