Based on xiaohongshu-mcp wrapped shell script toolset.
Prerequisites
cd scripts/
./install-check.sh # 检查依赖(xiaohongshu-mcp、jq、python3)
./start-mcp.sh # 启动 MCP 服务(默认端口 18060)
./status.sh # 确认已登录
When not logged in, scan the QR code:mcp-call.sh get_login_qrcode Get the QR code and scan it with the RedNote App.
The service port can be overridden via the MCP_URL environment variable (default http://localhost:18060/mcp)。
Core data flow
Important: Most operations require the feed_id + xsec_token pair. These two values are obtained from search/recommendation/user profile results,and cannot be constructed on your own。
search_feeds / list_feeds / user_profile
│
▼
返回 feeds 数组,每个 feed 包含:
├── id → 用作 feed_id
├── xsecToken → 用作 xsec_token
└── noteCard → 标题、作者、封面、互动数据
│
▼
get_feed_detail(feed_id, xsec_token)
│
▼
返回完整笔记: 正文、图片列表、评论列表
评论中包含 comment_id、user_id(用于回复评论)
Script reference
| Script | Purpose | Parameters |
|---|---|---|
search.sh <关键词> |
Search notes | Keyword |
recommend.sh |
Homepage recommendations | None |
post-detail.sh <feed_id> <xsec_token> |
Post details + comments | Obtained from search results |
comment.sh <feed_id> <xsec_token> <内容> |
Post a comment | Obtained from search results |
user-profile.sh <user_id> <xsec_token> |
User profile + notes | Obtained from search results |
track-topic.sh <话题> [选项] |
Hot topic analysis report | --limit N --output file --feishu |
export-long-image.sh |
Export post as long image | --posts-file json -o output.jpg |
mcp-call.sh <tool> [json_args] |
Generic MCP call | See the tool table below |
start-mcp.sh |
Start service | --headless=false --port=N |
stop-mcp.sh |
Stop service | None |
status.sh |
Check login | None |
install-check.sh |
Check dependencies | None |
MCP tool detailed parameters
search_feeds — Search notes
{"keyword": "咖啡", "filters": {"sort_by": "最新", "note_type": "图文", "publish_time": "一周内"}}
Optional filters fields:
sort_by: General | Latest | Most liked | Most commented | Most favoritednote_type: All | Video | Image-and-textpublish_time: All | Within a day | Within a week | Within half a yearsearch_scope: All | Viewed | Not viewed | Followinglocation: All | Same city | Nearby
get_feed_detail — Post details
{"feed_id": "...", "xsec_token": "...", "load_all_comments": true, "limit": 20}
load_all_comments: false (default) returns the first 10; true scrolls to load morelimit: Maximum comments to load (only effective when load_all_comments=true), default 20click_more_replies: Whether to expand second-level replies, default falsereply_limit: Skip comments with more replies than this value, default 10scroll_speed: slow | normal | fast
post_comment_to_feed — Post a comment
{"feed_id": "...", "xsec_token": "...", "content": "写得真好!"}
reply_comment_in_feed — Reply to a comment
{"feed_id": "...", "xsec_token": "...", "content": "谢谢!", "comment_id": "...", "user_id": "..."}
comment_id and user_id are obtained from the comment list returned by get_feed_detail.
user_profile — User profile
{"user_id": "...", "xsec_token": "..."}
user_id is obtained from the feed's noteCard.user.userId ,xsec_token uses that feed's xsecToken。
like_feed — Like/Unlike
{"feed_id": "...", "xsec_token": "..."}
{"feed_id": "...", "xsec_token": "...", "unlike": true}
favorite_feed — Favorite/Unfavorite
{"feed_id": "...", "xsec_token": "..."}
{"feed_id": "...", "xsec_token": "...", "unfavorite": true}
publish_content — Publish image-and-text
{"title": "标题(≤20字)", "content": "正文(≤1000字)", "images": ["/path/to/img.jpg"], "tags": ["美食","旅行"]}
images: At least 1, supports local paths or HTTP URLstags: Optional, topic tagsschedule_at: Optional, scheduled publishing (ISO8601, within 1 hour to 14 days)
publish_with_video — Publish video
{"title": "标题", "content": "正文", "video": "/path/to/video.mp4"}
Other tools
| Tool | Parameters | Description |
|---|---|---|
check_login_status |
None | Check login status |
list_feeds |
None | Get homepage recommendations |
get_login_qrcode |
None | Get login QR code (Base64 PNG) |
delete_cookies |
None | Delete cookies, reset login |
Hot topic tracking
Automatic search → fetch details → generate Markdown report.
./track-topic.sh "DeepSeek" --limit 5
./track-topic.sh "春节旅游" --limit 10 --output report.md
./track-topic.sh "iPhone 16" --limit 5 --feishu # 导出飞书
The report includes: overview statistics, hot post details (content + top comments), comment keywords, trend analysis.
Long image export
Export the post as a JPG long image with black text on a white background.
./export-long-image.sh --posts-file posts.json -o output.jpg
posts.json format:
[{
"title": "标题", "author": "作者", "stats": "1.3万赞",
"desc": "正文摘要", "images": ["https://..."],
"per_image_text": {"1": "第2张图的说明"}
}]
Dependencies: Python 3.10+, Pillow.
Notes
- Cookies are valid for about 30 days; after expiration, you need to scan the QR code again
- On first startup, a headless browser will be downloaded (~150MB)
- Avoid operating the same account from multiple clients at the same time
- Posting limits: title ≤20 characters, body ≤1000 characters, ≤50 posts per day
- Linux servers without a desktop environment need xvfb installed (
apt-get install xvfb, managed automatically by the script)