Skip to main content

MCP service for WeChat Official Account (微信公众号) content retrieval

Project description

wechatmp-mcp

wechatmp-mcp 是一个面向 MCP 客户端使用者的微信公众号 MCP Server。它通过微信公众号后台接口,提供扫码登录、搜索公众号、获取文章列表、读取文章正文、批量抓取多账号近期文章等能力。

你可以把它接入支持 MCP 的客户端,例如 Claude Code、Cline、MCP Inspector,或任何兼容 stdio 的 MCP 工具。

它能做什么

  • 获取微信公众号后台登录二维码,扫码完成登录,自动保存登录态到本地
  • 登录态保存在 ~/.wechat-mcp/,重启后无需重新登录
  • 按关键词搜索公众号,获取 fakeid、昵称、简介等信息
  • 获取指定公众号的文章列表(标题、链接、摘要、封面、发布时间)
  • 读取指定文章 URL 的正文,以 Markdown 格式返回
  • 批量获取多个公众号的近期文章摘要

当前项目实际注册了 7 个 MCP tools

环境要求

  • Python 3.10 或更高版本
  • 能访问微信公众号网页(mp.weixin.qq.com)

通过 uvx 使用(推荐)

无需手动安装,uvx 会自动处理。

Claude Code 配置

claude mcp add wechat -- uvx wechatmp-mcp

快速调试

npx @modelcontextprotocol/inspector uvx wechatmp-mcp

⚠️ 注意: 请务必先使用 get_login_qrcode + check_login_status 完成登录后再使用其他工具!

MCP 客户端配置

Claude Code

claude mcp add wechat -- uvx wechatmp-mcp

Cline / JSON 配置

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

Tools 一览

账号登录

  • get_login_qrcode:获取微信公众号后台登录二维码,图片保存到本地,返回文件路径
  • check_login_status:检查登录状态;若用户已扫码则完成登录并保存 auth,否则验证已保存 auth 是否有效
  • logout:清除本地保存的 auth(token + cookies),退出登录

公众号搜索

  • search_account:按关键词搜索公众号,返回 fakeid、nickname、alias、intro、avatar

文章获取

  • get_account_articles:获取指定公众号的文章列表(按发布时间倒序),支持按 fakeid 或公众号名称查询,支持翻页
  • get_article_content:传入文章 URL,返回清洗后的 Markdown 正文
  • batch_get_articles:传入公众号名称列表,批量获取近期文章摘要

发布新版本到 PyPI

修改代码后,更新 src/wechat_mcp/__init__.py 中的版本号,然后:

# 安装构建工具(首次需要)
pip install hatch twine -i https://pypi.org/simple/

# 构建
hatch build

# 上传到 PyPI
# Username: __token__
# Password: 在 https://pypi.org/manage/account/ 的 API tokens 中创建
python -m twine upload dist/*

# 验证上传成功
uvx wechatmp-mcp==<新版本号> --help

注意:上传后 PyPI 同步约需 1-2 分钟,验证前稍等片刻。

使用建议

  • 使用其他工具前,请先通过 get_login_qrcode 获取二维码并扫码,再调用 check_login_status 完成登录
  • 登录态保存在 ~/.wechat-mcp/,重启服务后无需重新登录
  • get_account_articles 需要先通过 search_account 获取公众号的 fakeid

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wechatmp_mcp-0.0.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wechatmp_mcp-0.0.1-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file wechatmp_mcp-0.0.1.tar.gz.

File metadata

  • Download URL: wechatmp_mcp-0.0.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wechatmp_mcp-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8f58559771f3d1e601c9269cc29b35dd5f5647fb59ad5bab426274ce3199587a
MD5 39e242c58316bed609c77c9af3e356a7
BLAKE2b-256 5eba656e9843844e6ec4bf1755843059633985d3bea8e659400b4f274c8a6a9d

See more details on using hashes here.

File details

Details for the file wechatmp_mcp-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: wechatmp_mcp-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wechatmp_mcp-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c69ec02576dddd298503282ec9ac6faaec4de8e50c2692d846cc07714c5a329
MD5 ea885fcce81b8a9a09c11cc105a4047a
BLAKE2b-256 b55a347b11a3c5fd47e859a2450652b373e79b4ca377e23bb1703b9d56fc5573

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page