Skip to main content
Glama

微信公众号文章解析 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

-
security - not tested
F
license - not found
-
quality - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Appeared in Searches

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shiwei73/mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server