今日头条公开内容 MCP Server
概述
Astron-toutiao-mcp 是一个基于 MCP 协议的今日头条工具服务,直接调用今日头条公开热榜、推荐流、搜索页和移动端详情接口,不依赖额外的 Astron 后端服务。
当前工程形态:
- 使用
MCP Python SDK - 使用单文件
server.py承载工具定义、搜索解析和 HTTP 调用 - 通过独立
pyproject打包 - 支持
uvx一键启动 - 通过环境变量配置超时和 User-Agent
当前提供 6 个原子工具:
get_hot_listget_feed_listsearch_contentget_content_detailget_author_profileget_author_content_list
工具列表
1. 获取热榜 get_hot_list
- 描述:读取今日头条热榜。
- 参数:
limit:返回条数,默认20refresh:是否刷新,默认False
2. 获取推荐流 get_feed_list
- 描述:读取今日头条推荐流。
- 参数:
channel:兼容保留参数,当前未启用cursor:分页游标,对应max_behot_timelimit:返回条数,默认20refresh:是否刷新,默认False
3. 搜索内容 search_content
- 描述:搜索今日头条公开内容。
- 参数:
query:搜索词,必填cursor:兼容保留参数,当前未启用limit:返回条数,默认20
4. 获取内容详情 get_content_detail
- 描述:读取今日头条内容详情。
- 参数:
content_id:内容 IDurl:内容完整 URL
5. 获取作者主页 get_author_profile
- 描述:读取作者公开信息。
- 参数:
author_id:作者检索标识,推荐直接传作者名url:作者相关 URL,也支持传文章 URL 让服务自动解析作者
- 说明:
- 支持直接传头条 PC 作者主页链接,例如
https://www.toutiao.com/c/user/token/<token>/...
- 支持直接传头条 PC 作者主页链接,例如
6. 获取作者作品列表 get_author_content_list
- 描述:读取作者公开作品列表。
- 参数:
author_id:作者检索标识,推荐直接传作者名url:作者相关 URL,也支持传文章 URL 让服务自动解析作者cursor:兼容保留参数,当前未启用limit:返回条数,默认20
- 说明:
- 传作者主页链接时,会优先解析作者主页首屏数据,并尽量优先使用作者侧接口获取作品
环境变量
这个包默认不需要认证信息。
可选环境变量:
export TOUTIAO_MCP_TIMEOUT_SECONDS="30"
export TOUTIAO_MCP_USER_AGENT="Mozilla/5.0 ..."
export TOUTIAO_MCP_MOBILE_USER_AGENT="Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) ..."
说明:
TOUTIAO_MCP_TIMEOUT_SECONDS控制 API 和页面请求超时。TOUTIAO_MCP_USER_AGENT用于覆盖默认桌面请求头。TOUTIAO_MCP_MOBILE_USER_AGENT用于覆盖移动端详情接口请求头。
安装与启动
推荐方式:使用 uvx 一键启动
uvx --from astron-toutiao-mcp astron-toutiao-mcp
如果你还没有安装 uv / uvx,可先执行:
curl -fsSL https://install.astral.sh/uv | bash
使用 pip 安装
pip install astron-toutiao-mcp
toutiao-mcp
本地源码运行
cd MCP/toutiao-mcp
PYTHONPATH=src python3 -m toutiao_mcp.server
客户端配置
使用 uvx
{
"mcpServers": {
"toutiao-mcp": {
"command": "uvx",
"args": ["--from", "astron-toutiao-mcp", "astron-toutiao-mcp"],
"env": {
"TOUTIAO_MCP_TIMEOUT_SECONDS": "30"
}
}
}
}
使用本地源码
{
"mcpServers": {
"toutiao-mcp": {
"command": "python3",
"args": ["-m", "toutiao_mcp.server"],
"env": {
"PYTHONPATH": "/path/to/MCP/toutiao-mcp/src",
"TOUTIAO_MCP_TIMEOUT_SECONDS": "30"
}
}
}
}
平台差异说明
- 这个 MCP 直接请求今日头条公开接口和公开页面,不依赖额外的 Astron 后端服务。
- 当前仅面向公开内容能力,不包含登录态、私有内容或用户专属数据。
- 内容详情优先走
m.toutiao.com/i{gid}/info/,避免依赖 Playwright 或 PC 壳页渲染。 - Toutiao 的数字
media_id/creator_uid对外复用性较差,所以结果里的author_id默认更偏向“可继续检索作者”的作者名;底层数字 ID 保留在raw。 get_author_profile和get_author_content_list当前主要通过作者名搜索和详情页作者数据聚合实现;如果头条搜索结构变化,作者相关能力可能需要同步调整。
发布说明
cd MCP/toutiao-mcp
rm -rf build dist src/*.egg-info
python3 -m build --no-isolation
python3 -m twine check dist/*
python3 -m twine upload dist/*
License
Apache License 2.0. See LICENSE.
Metadata
Release files for astron-toutiao-mcp 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| astron_toutiao_mcp-0.1.5.tar.gz | 19.5 kB | Without provenance | Details for astron_toutiao_mcp-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| astron_toutiao_mcp-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for astron_toutiao_mcp-0.1.5-py3-none-any.whl |
Total release size: 39.5 kB
Release files / astron_toutiao_mcp-0.1.5.tar.gz
| Download URL | astron_toutiao_mcp-0.1.5.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f19a5f56fb00810f13d99db0be814d223bb3ee237890fe19b92289a1223c4c2c
|
|
BLAKE2b-256 checksum How to use checksums |
c9c5f52e84a9a8a5b475ff2c44cc98b5380c55c73bff6cdf6129a26a9dad3aa1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0rc1
|
Release files / astron_toutiao_mcp-0.1.5-py3-none-any.whl
| Download URL | astron_toutiao_mcp-0.1.5-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdc0e71a58ebcf9d0752209829d400fd756ec9e586140df41d016c1c50adc0e4
|
|
BLAKE2b-256 checksum How to use checksums |
4bfd316d6462338a43ece7472358d25fb8e15d6688255bd6559bf5d14c73141e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0rc1
|
Security for astron-toutiao-mcp 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.