xiaohongshu-mcp-steve
v1.1.2
Published
Xiaohongshu MCP server for searching posts and comments
Maintainers
Readme
Xiaohongshu MCP Server
一个基于 Model Context Protocol (MCP) 的小红书搜索服务,支持搜索笔记和获取评论。
功能特性
- 🔍 搜索小红书笔记
- 💬 获取笔记评论
- 🚀 同时搜索笔记和评论
- 📄 基于 MCP 标准协议
- 🔌 支持 stdio 传输
安装
npm install -g @dengpengfei/xiaohongshu-mcp或者使用 npx 直接运行:
npx @dengpengfei/xiaohongshu-mcp使用前准备
获取 Cookie
- 打开浏览器并登录小红书网页版
- 打开开发者工具(F12)
- 切换到 Network(网络)标签
- 刷新页面或进行任意操作
- 找到任意一个对 xiaohongshu.com 的请求
- 在请求头中找到 Cookie 字段,复制整个值
设置环境变量
export XIAOHONGSHU_COOKIE="your_cookie_here"使用方法
作为 MCP 服务器运行
XIAOHONGSHU_COOKIE="your_cookie" npx @dengpengfei/xiaohongshu-mcp在 Claude Desktop 中使用
编辑 Claude Desktop 配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
添加配置:
{
"mcpServers": {
"xiaohongshu": {
"command": "npx",
"args": ["@dengpengfei/xiaohongshu-mcp"],
"env": {
"XIAOHONGSHU_COOKIE": "your_cookie_here"
}
}
}
}- 重启 Claude Desktop
可用工具
search_notes
搜索小红书笔记
参数:
keyword(必需): 搜索关键词page: 页码(默认 1)page_size: 每页数量(默认 20)sort: 排序方式general: 综合排序(默认)time_descending: 最新发布popularity_descending: 最热门
get_note_comments
获取指定笔记的评论
参数:
note_id(必需): 笔记IDcursor: 分页游标(默认空)
search_notes_with_comments
搜索笔记并同时获取每个笔记的评论
参数:
keyword(必需): 搜索关键词page: 页码(默认 1)page_size: 每页数量(默认 5)max_comments_per_note: 每个笔记获取的最大评论数(默认 10)sort: 排序方式
注意事项
- 请求频率限制:API 要求每次调用间隔 3-5 秒,频繁调用可能导致封禁
- Cookie 有效期:Cookie 可能会过期,需要定期更新
- 数据量限制:搜索笔记并获取评论时,建议 page_size 不要设置太大,避免请求过多
开发
本地开发
# 克隆仓库
git clone https://github.com/dengpengfei/xiaohongshu-mcp.git
cd xiaohongshu-mcp
# 安装依赖
npm install
# 构建
npm run build
# 开发模式运行
npm run dev项目结构
xiaohongshu-mcp/
├── src/
│ ├── index.ts # MCP 服务器主文件
│ └── xiaohongshu-client.ts # 小红书 API 客户端
├── package.json
├── tsconfig.json
└── README.mdLicense
MIT
作者
Deng Pengfei
贡献
欢迎提交 Issues 和 Pull Requests!
免责声明
本项目仅供学习和研究使用,请遵守小红书的服务条款和相关法律法规。使用本项目产生的任何后果由使用者自行承担。
