Enables parsing and extraction of WeChat official account articles, including title, author, content, and media resources, with support for multiple output formats (JSON, Markdown, HTML, plain text).
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@WeChat Article Parserparse this WeChat article and give me the content in markdown format: https://mp.weixin.qq.com/s/abc123def456"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
微信公众号文章解析 MCP 服务器
基于 FastMCP 框架的微信公众号文章解析服务器,可以模拟浏览器访问微信公众号文章,提取文章内容、媒体资源等信息。
功能特点
使用 Playwright 模拟浏览器访问微信公众号文章
提取文章标题、作者、发布日期、正文内容等信息
支持多种输出格式:JSON、Markdown、HTML、纯文本
可提取文章中的图片、视频等媒体资源
支持清理广告、推荐等干扰内容
支持 HTTP 和 STDIO 两种传输协议
安装
环境要求
Python 3.10 或更高版本
Playwright 支持的操作系统
安装步骤
克隆仓库
git clone https://github.com/yourusername/mcp-server-wechat-article.git
cd mcp-server-wechat-article安装依赖
pip install -e .安装 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配置传输协议
服务器支持两种传输协议:
STDIO(默认):适用于本地/Claude Desktop
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: 微信公众号文章的完整URLformat: 输出格式,可选 '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: 微信公众号文章的完整URLformat: 输出格式,可选 'text', 'json', 'markdown', 或 'html'extract_images: 是否提取图片URLclean_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 服务器端口,默认为 8000BROWSER_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/添加新工具
要添加新工具,请按照以下步骤操作:
在
tools/目录下创建新的工具文件使用 Pydantic 定义输入模型
实现工具逻辑
在
server.py中注册工具
许可证
MIT