通过 MCP 协议访问小红书内容。集成 rebrowser-playwright + playwright-extra stealth 反检测方案,支持登录态持久化。
本项目是 iFurySt/RedNote-MCP 的持续维护版本。
demo.mp4
| 功能 | 状态 |
|---|---|
| 关键词搜索笔记 | ✅ |
| 获取笔记详情(标题、正文、图片、视频、标签、点赞数) | ✅ |
| 获取笔记评论 | ✅ |
| Cookie 持久化登录 | ✅ |
| 反检测浏览器(rebrowser + stealth plugin + 仿人鼠标) | ✅ |
# 安装 @nodite/rednote-mcp
npm install -g @nodite/rednote-mcp
# 安装匹配版本的 Playwright(rebrowser-playwright 1.52 需要 chromium-1169)
npm install -g [email protected]
npx playwright install chromium# 会自动打开浏览器,扫码或账号密码登录
# Cookie 保存至 ~/.mcp/rednote/cookies.json
rednote-mcp init默认等待时间 60 秒,可通过参数调整:
rednote-mcp init 120
编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"rednote": {
"command": "rednote-mcp",
"args": ["--stdio"]
}
}
}编辑 .cursor/mcp.json 或 Cursor 设置中的 MCP 配置:
{
"mcpServers": {
"rednote": {
"command": "rednote-mcp",
"args": ["--stdio"]
}
}
}编辑 .vscode/mcp.json:
{
"servers": {
"rednote": {
"type": "stdio",
"command": "rednote-mcp",
"args": ["--stdio"]
}
}
}{
"mcpServers": {
"rednote": {
"command": "npx",
"args": ["-y", "@nodite/rednote-mcp", "--stdio"]
}
}
}
--headless参数可让浏览器在后台无界面运行(有 cookie 后推荐开启):{ "mcpServers": { "rednote": { "command": "rednote-mcp", "args": ["--headless", "--stdio"] } } }
配置完成后,MCP 客户端可调用以下工具:
| 工具名 | 说明 | 参数 |
|---|---|---|
search_notes |
关键词搜索笔记 | keywords(必填),limit(可选,默认 10) |
get_note_content |
获取笔记详情 | url(笔记链接) |
get_note_comments |
获取笔记评论 | url(笔记链接) |
login |
在 MCP 客户端内触发登录 | 无 |
git clone https://github.com/nodite/rednote-mcp.git
cd rednote-mcp
npm install
# 安装匹配版本的 Playwright
npm install [email protected] --save-dev
npx playwright install chromium
# 初始化登录
npm run dev -- init登录成功后,在 MCP 客户端配置中将 command 改为 node,args 指向构建产物:
# 先构建
npm run build{
"mcpServers": {
"rednote": {
"command": "node",
"args": ["/path/to/rednote-mcp/dist/cli.js", "--stdio"]
}
}
}或者不构建,直接用 ts-node 运行源码:
{
"mcpServers": {
"rednote": {
"command": "npx",
"args": ["ts-node", "/path/to/rednote-mcp/src/cli.ts", "--stdio"]
}
}
}# 类型检查
npx tsc --noEmit
# 测试
npm test
# 构建
npm run build
# MCP Inspector 调试
npx @modelcontextprotocol/inspector npx @nodite/rednote-mcp --stdio
# 打包日志
rednote-mcp pack-logs
# 打开日志目录
rednote-mcp open-logs~/.mcp/rednote/cookies.json包含登录凭证,勿提交至版本控制- Cookie 过期后重新执行
rednote-mcp init即可 - rebrowser-playwright 需要与 Playwright 版本严格匹配(当前:1.52.0 / chromium-1169)
- Fork 本仓库
- 创建特性分支
git checkout -b feature/your-feature - 提交改动并开 PR