Access Xiaohongshu content through a local MCP server.
Prerequisites
Requires deployment of the xiaohongshu-mcp service.
First use requires login:
cd /path/to/xiaohongshu-mcp
./xiaohongshu-login
After successful login, cookies will be saved to cookies/cookies.json。
Start the service
cd /path/to/xiaohongshu-mcp
./start.sh
The service runs in the background, listening on http://localhost:18060/mcp。
Available Features
1. Search Content
curl -X POST http://localhost:18060/api/search \
-H "Content-Type: application/json" \
-d '{"keyword": "弥勒旅游"}'
Returns search results, including post ID, title, user information, number of likes, etc.
2. Get Post Details
curl -X POST http://localhost:18060/api/feed/detail \
-H "Content-Type: application/json" \
-d '{
"note_id": "帖子ID",
"xsec_token": "从搜索结果获取"
}'
Returns the complete post content, including images, text, comments, etc.
3. Get Recommendation List
curl -X POST http://localhost:18060/api/feeds
Returns recommended content from the Xiaohongshu homepage.
4. Check Login Status
curl http://localhost:18060/api/check-login
Usage Examples
Search
# CLI 搜索
python3 scripts/xhs_search.py "弥勒旅游景点"
# 限制结果数
python3 scripts/xhs_search.py "美食推荐" 5
curl Workflow
# 1. 搜索
curl -X POST http://localhost:18060/api/search \
-H "Content-Type: application/json" \
-d '{"keyword": "弥勒旅游景点"}' | jq .
# 2. 获取帖子详情(从搜索结果中选择)
curl -X POST http://localhost:18060/api/feed/detail \
-H "Content-Type: application/json" \
-d '{
"note_id": "从搜索结果获取",
"xsec_token": "从搜索结果获取"
}' | jq .
Workflow
- Start the service: Start xiaohongshu-mcp
- Search keywords: Get the post list
- Select a post: Choose a post of interest from the list
- Get details: Use
note_idandxsec_tokento get the complete content - Summarize information: Extract key information (attractions, photo spots, tips, etc.)
Notes
- First use requires login: Run
./xiaohongshu-login - Cookies expired: If it returns that login is required, run the login tool again
- Service port: Default 18060; make sure the port is not occupied
- Simultaneous login restriction: Xiaohongshu does not allow the same account to log in on multiple web clients
- Mobile is not affected: the Xiaohongshu App can be used at the same time
Troubleshooting
| Issue | Solution |
|---|---|
| Service fails to start | lsof -i :18060 Check port usage |
| Search returns empty results | curl http://localhost:18060/api/check-login Check login status |
| Cookies expired | Delete cookies/cookies.json then run ./xiaohongshu-login |
API Response Format
Search results
{
"items": [
{
"id": "帖子ID",
"note_card": {
"display_title": "标题",
"user": { "nickname": "作者昵称" },
"interact_info": { "liked_count": "点赞数" }
},
"xsec_token": "用于获取详情的 token"
}
]
}
Post details
{
"note_card": {
"title": "标题",
"desc": "正文内容",
"image_list": [{ "url": "图片URL" }],
"interact_info": {
"liked_count": "点赞数",
"collected_count": "收藏数",
"comment_count": "评论数"
}
},
"comments": {
"comments": [
{ "content": "评论内容", "sub_comments": [] }
]
}
}