微信文章解析服务

一个用于抓取和清理微信公众号文章的MCP服务器,适用于下游处理和Claude Desktop集成。

  • by jerryfound
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 jerryfound/wx-mp-analyzer-mcp

使用说明

wx-mcp分析仪

微信文章解析MCP服务器,获取和清理微信文章以供下游处理。

特性

  • 文章获取:使用Playwright渲染来自的微信文章 mp.weixin.qq.com
  • HTML清理:删除脚本、样式和内联事件;对图像进行标准化处理
  • MCP集成:与Claude Desktop和其他MCP客户端兼容

快速开始

先决条件

安装和运行

# Install dependencies (including Playwright browsers)
uv sync
uv run playwright install chromium

# Run the MCP server
uv run python src/server/app.py

可用工具

  1. health_check:验证服务器状态和环境
  2. fetch_wechat_article:获取并清理微信文章

示例 fetch_wechat_article 用法:

{
  "url": "https://mp.weixin.qq.com/s/article-id",
  "timeout_sec": 20,
  "inline_images": false
}

使用Claude Desktop

有几种方式在 Claude Desktop 中配置此 MCP 服务器:

方式一:使用本地开发模式(推荐用于开发)

{
  "mcpServers": {
    "wx-mcp-analyzer": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/wx-mcp-analyzer-mcp-openspec",
        "run",
        "python",
        "wx_mcp_analyzer/server/app.py"
      ]
    }
  }
}

方式二:使用 uvx 从本地 wheel 文件

{
  "mcpServers": {
    "wx-mcp-analyzer": {
      "command": "uvx",
      "args": [
        "--from",
        "/absolute/path/to/wx-mcp-analyzer-mcp-openspec/dist/wx_mcp_analyzer-0.1.0-py3-none-any.whl",
        "wx-mcp-analyzer"
      ]
    }
  }
}

方式三:使用 uvx 从当前目录(如果在项目目录下)

{
  "mcpServers": {
    "wx-mcp-analyzer": {
      "command": "uvx",
      "args": [
        "--from",
        ".",
        "wx-mcp-analyzer"
      ],
      "cwd": "/absolute/path/to/wx-mcp-analyzer-mcp-openspec"
    }
  }
}

注意: 将 /absolute/path/to/wx-mcp-analyzer-mcp-openspec 替换为此项目的实际绝对路径。

发布到 PyPI(可选)

如果你想发布到 PyPI 以便其他人使用:

# 发布到 PyPI(需要 PyPI 账户和 token)
uv publish

# 然后其他人可以直接使用
uvx wx-mcp-analyzer

Claude Desktop 配置(发布后):

{
  "mcpServers": {
    "wx-mcp-analyzer": {
      "command": "uvx",
      "args": ["wx-mcp-analyzer"]
    }
  }
}

发展

运行测试

# Run fast tests only (recommended for development)
uv run pytest -m "not slow"

# Run all tests including slow integration tests
uv run pytest

# Run specific test file
uv run pytest tests/test_cleaner.py -v

项目结构

src/
├── server/          # FastMCP server and tool definitions
├── fetcher/         # Playwright-based page fetching
└── cleaner/         # HTML cleaning and normalization
tests/
├── test_cleaner.py  # Unit tests for HTML cleaner
└── test_fetcher.py  # Smoke tests for fetcher (marked as slow)