toutiao-mcp
Click on "Deploy 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., "@toutiao-mcp 请帮我登录今日头条并发布文章,标题:测试标题,内容:测试内容,封面:/tmp/cover.png"
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.
@the-thing/toutiao-mcp
一个 MCP(Model Context Protocol)服务器,通过 Puppeteer 浏览器自动化向今日头条发布文章:扫码登录、上传封面图、填写标题与正文、点击发布,全程模拟真人操作,无需头条开放平台 API Key。
发布机制学习自 jiaqi-lyu-de/news-autopublish-mcp,并做了精简(去掉新闻抓取模块,只保留头条发布能力)。
工作原理
AI 客户端(Claude Desktop / 支持 MCP 的应用)
│ ① 调用 toutiao_login(返回二维码图片)
│ ② 用户手机扫码,Cookie 自动保存到 ~/.toutiao-mcp/cookies.json
│ ③ 调用 toutiao_publish_article(title, content, imagePath)
▼
Puppeteer 打开真实浏览器(复用系统 Chrome/Edge)
▼
打开头条 → 注入 Cookie 校验登录 → 点击"发布" → 上传封面图 → 填标题正文 → 点击发布Related MCP server: toutiao_mcp_server
快速开始
方式一:一行配置(推荐,无需下载代码)
使用者不需要 clone 代码、不需要 npm install,只需在 MCP 客户端配置里加一段,首次运行由 npx 自动拉取:
{
"mcpServers": {
"toutiao": {
"command": "npx",
"args": ["-y", "@the-thing/toutiao-mcp@latest"]
}
}
}使用者环境要求(只需满足两点):
已安装 Node.js 18+(npx 随附)
本机装有 Google Chrome 或 Microsoft Edge(自动探测;或设置环境变量
PUPPETEER_EXECUTABLE_PATH指向浏览器可执行文件)
登录 Cookie 位置:
~/.toutiao-mcp/cookies.json(用户主目录,跨项目共享登录态),登录后自动生成,无需手动配置。
方式二:本地开发(本仓库)
git clone https://github.com/JessYan0913/toutiao-mcp.git
cd toutiao-mcp
npm install
npm run inspect # 打开 MCP Inspector 调试使用教程
第 1 步:登录(toutiao_login)
调用后会自动弹出浏览器窗口并显示今日头条登录二维码,用手机「今日头条 / 抖音」App 扫码确认:
扫码成功后系统自动保存 Cookie,无需其他操作
二维码会同时以图片形式返回给 AI 客户端,可直接在对话界面展示
最长等待 5 分钟,超时需重新调用
第 2 步:检查登录态(toutiao_check_status,可选但推荐)
用无头浏览器验证当前 Cookie 是否有效,返回 { isLoggedIn: true/false }。已登录时会自动刷新保存最新 Cookie。
第 3 步:发布文章(toutiao_publish_article)
必填参数:
参数 | 说明 | 约束 |
| 文章标题 | 2~30 个字,超出会被拒绝 |
| 文章正文 | 纯文本,自动填入富文本编辑器 |
| 本地封面图片路径 | 绝对路径,文件必须存在 |
发布完成后浏览器窗口会保留约 20 秒,请在浏览器中确认发布结果(建议手动检查一次是否成功上架)。
给 AI 客户端的提示词示例
1. 请帮我登录今日头条(调用 toutiao_login)
2. 确认登录成功后,发布一篇头条文章:
- 标题:xxx
- 正文:xxx
- 封面图:C:\Users\me\Pictures\cover.png
(调用 toutiao_publish_article)MCP 工具清单
工具 | 说明 | 参数 |
| 打开浏览器获取登录二维码并等待扫码,成功后自动保存 Cookie | 无 |
| 无头浏览器验证当前登录态,已登录时刷新 Cookie | 无 |
| 删除本地 Cookie(登出) | 无 |
| 发布文章:封面图 + 标题 + 正文,触发发布 |
|
发布流程原理(七步)
校验图片路径存在、标题字数 2~30
启动有头浏览器 + 抗检测(隐藏
navigator.webdriver、伪装 Chrome UA、真实分辨率)注入 Cookie → 校验登录态(未登录直接报错)
首页鼠标「移动 → 悬停 → 点击」发布图标,捕获新弹出的发布窗口
上传封面:点击上传区 → 弹窗上传按钮 →
FileChooser注入图片路径 → 等待处理 → 确认标题输入框三击全选清空后键入;正文富文本编辑器 focus 后键入
点击发布按钮(连点两次兜底),返回成功
项目结构
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 持久化(~/.toutiao-mcp/cookies.json)
└── scripts # 调试与命令行辅助脚本常见问题排查
现象 | 原因与处理 |
报错「未找到可用的 Chrome/Edge 浏览器」 | 本机未装 Chrome/Edge,或安装位置特殊;安装浏览器,或设置环境变量 |
报错「未发现登录信息或登录已失效」 | Cookie 过期,重新调用 |
发布后浏览器里没有文章 | 头条前端改版导致选择器失效;需在 |
登录后 Cookie 在哪 |
|
风险提示(重要)
非官方通道:浏览器自动化模拟人工操作,违反今日头条平台用户协议,账号存在被风控/封禁的风险,请使用小号测试。
选择器脆弱:发布流程依赖硬编码 CSS 类名(集中在
src/toutiao/publish.js顶部TOUTIAO_CONFIG.selectors),头条前端改版后需同步更新。需要图形环境:登录/发布使用有头浏览器,服务器部署需虚拟显示(如 Windows 桌面、Xvfb)。
凭证安全:Cookie 含敏感会话凭证且明文存储,请勿提交到仓库、注意保管。
License
ISC
Available Tools
4 toolstoutiao_check_statusA
检查今日头条登录状态(无头浏览器验证当前 Cookie 是否有效),已登录时会刷新本地 Cookie。
Inputs: no named parameters.
toutiao_loginA
登录今日头条:打开浏览器获取登录二维码并等待扫码,扫码成功后自动保存 Cookie 到本地 cookies.json。
Inputs: no named parameters.
toutiao_logoutA
退出登录:删除本地保存的 Cookie 文件 cookies.json。
Inputs: no named parameters.
toutiao_publish_articleA
发布今日头条文章:通过浏览器自动化设置封面图、标题与正文并触发发布。需要先登录(cookies.json 存在且有效)。
Inputs: title (required), content (required), imagePath (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinct purpose: login, check status, logout, and publish. The boundaries are clear with no overlapping responsibilities.
All tools follow the same verb_noun pattern with a consistent 'toutiao_' prefix (login, check_status, logout, publish_article). Naming is uniform and predictable.
With 4 tools, the set is well-scoped for the authentication and publishing workflow. Each tool fills a clear need without unnecessary bloat.
The tool covers the full login lifecycle (login, check, logout) and the core publishing action. No obvious gaps for the stated purpose of publishing to Toutiao.
Maintenance
Related MCP Connectors
MCP server for real-time Chinese internet hot-search and trending boards across major platforms.
MCP server aggregating hot-search boards from 8 Chinese platforms (Weibo, Zhihu, Bilibili, Douyin).
MCP server for QPost — lets AI agents publish video and image posts to YouTube, TikTok, Instagram.
TikTok Ads MCP server: run TikTok campaigns, ad groups, ads and reports from AI.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAutomates the Douyin Creator Platform to manage login states and publish image-text content via the MCP protocol. It enables users to check authentication status, manage cookies, and automate article publishing with titles, text, and images.-
- FlicenseNot gradedqualityDmaintenanceEnables automated content management for Toutiao (今日头条), including login, article/micro-post publishing, analytics, and multi-platform compatibility with Xiaohongshu data format.-
- AlicenseAqualityCmaintenanceMCP server for reading WeChat public account articles by reusing authenticated browser sessions, handling captchas and rate limits.618MIT
- AlicenseNot gradedqualityDmaintenanceAutomates video and image-text publishing on Douyin's creator platform using Chrome DevTools Protocol, exposed as MCP tools.90AGPL 3.0