npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@siact/toutiao-mcp

v1.0.0

Published

An MCP server that publishes articles to Toutiao (今日头条) via browser automation. 扫码登录+发布文章,只需配置一行 MCP 即可使用。

Readme

toutiao-mcp

一个 MCP(Model Context Protocol)服务器,通过 Puppeteer 浏览器自动化 向今日头条发布文章——扫码登录、上传封面、填写标题正文、点击发布,全程模拟真人操作,无需头条开放平台 API Key

⚠️ 本项目发布机制学习自 jiaqi-lyu-de/news-autopublish-mcp,并做了精简(去掉新闻抓取模块,只保留头条发布能力)。

快速开始

环境要求:Node.js 18+(推荐 LTS)。浏览器自动复用系统已安装的 Chrome / Edge(无需下载 Chromium)。

cd E:\toutiao-mcp
npm install

1) 调试模式(推荐先跑通)

npm run inspect

会启动 MCP Inspector,在网页界面里调用 toutiao_login 扫码登录,再调用 toutiao_publish_article 发布。

2) 接入 Claude Desktop

编辑 claude_desktop_config.json(Claude Desktop → Settings → Developer → Edit Config):

{
  "mcpServers": {
    "toutiao-mcp": {
      "command": "node",
      "args": ["E:\\toutiao-mcp\\src\\server.js"],
      "cwd": "E:\\toutiao-mcp"
    }
  }
}

注意:cwd 必须指向项目目录,因为登录 Cookie 会保存在该目录下的 cookies.json

重启 Claude Desktop 后即可让 AI 调用这 4 个工具。

MCP 工具清单

| 工具 | 说明 | 参数 | | :--- | :--- | :--- | | toutiao_login | 打开浏览器获取登录二维码并等待扫码,成功后自动保存 Cookie | 无 | | toutiao_check_status | 无头浏览器验证当前登录态,已登录时刷新 Cookie | 无 | | toutiao_logout | 删除本地 cookies.json(登出) | 无 | | toutiao_publish_article | 发布文章:封面图 + 标题 + 正文,触发发布 | titlecontentimagePath(均必填) |

使用流程

1. toutiao_login        → 手机扫码(二维码会直接显示在 AI 客户端界面)
2. toutiao_check_status → 确认已登录(可选,但推荐)
3. toutiao_publish_article(title, content, imagePath) → 发布

参数约束

  • title2~30 个字,超出会被拒绝
  • imagePath:本地图片绝对路径(发布页通过 FileChooser 注入,无需手动选文件)
  • content:纯文本正文,发布页自动填入 ProseMirror 富文本编辑器

项目结构

E:\toutiao-mcp
├── client.js               # 冒烟测试:列出已注册工具(node client.js)
├── src
│   ├── server.js           # MCP server 入口(stdio 传输,注册 4 个工具)
│   ├── toutiao
│   │   ├── login.js        # 扫码登录 + 后台轮询监听 + 自动存 Cookie
│   │   ├── status.js       # 登录态判定(无头浏览器)
│   │   ├── logout.js       # 登出(删 Cookie 文件)
│   │   └── publish.js      # 核心:七步发布流程(Puppeteer 自动化)
│   └── utils
│       ├── browser.js      # 浏览器启动:自动探测系统 Chrome/Edge
│       └── cookies.js      # Cookie 持久化(cookies.json)
└── cookies.json            # 登录凭证(自动生成,已被 .gitignore 忽略)

发布流程原理(七步)

  1. 校验图片路径存在、标题 2~30 字
  2. 启动有头浏览器 + 抗检测(隐藏 navigator.webdriver、伪装 Chrome UA、真实分辨率)
  3. 注入 Cookie → 校验登录态
  4. 首页鼠标「移动 → 悬停 → 点击」发布图标,捕获新弹出的发布窗口
  5. 上传封面:点击上传区 → 弹窗上传按钮 → FileChooser 注入图片路径 → 等处理 → 确认
  6. 标题输入框三击全选清空后键入;正文富文本编辑器 focus 后键入
  7. 点击发布按钮(连点两次兜底),返回成功

风险提示(重要)

  • 非官方通道:浏览器自动化模拟操作,违反今日头条平台协议,账号存在被风控/封禁的风险,请使用小号测试。
  • 选择器脆弱:发布流程依赖硬编码 CSS 类名(集中在 src/toutiao/publish.js 顶部 TOUTIAO_CONFIG.selectors),头条前端改版后需同步更新。
  • 需要图形环境:登录/发布使用有头浏览器,服务器部署需虚拟显示(如 Windows 桌面、Xvfb)。
  • 凭证安全cookies.json 含敏感会话凭证且明文存储,请勿提交到仓库、注意保管。

License

ISC

他人使用:一行配置接入(无需下载代码)

本项目可发布为 npm 包,使用者不需要 clone 代码、不需要 npm install,只需在 MCP 客户端配置里加一段,首次运行由 npx 自动拉取依赖:

{
  "mcpServers": {
    "toutiao": {
      "command": "npx",
      "args": ["-y", "@siact/toutiao-mcp@latest"]
    }
  }
}

使用者环境要求(只需满足这两点):

  1. 已安装 Node.js 18+(npx 随附)
  2. 本机装有 Google Chrome 或 Microsoft Edge(自动探测;或设置环境变量 PUPPETEER_EXECUTABLE_PATH 指向浏览器可执行文件)

登录 Cookie 位置~/.toutiao-mcp/cookies.json(用户主目录,跨项目共享登录态),发布后会自动生成,无需手动配置。

使用流程与本地版完全一致:toutiao_login 扫码登录 → toutiao_check_status 确认 → toutiao_publish_article 发布。

发布到 npm 公共仓库前需填写 package.jsonrepository 地址与 author。私有 npm registry(如 Verdaccio/GitHub Packages)同样适用。