Based on xpzouying/xiaohongshu-mcp built
🎯 Core Features
This Skill provides a complete Xiaohongshu automation solution:
| Feature | Status | Description |
|---|---|---|
| 🔐 Login Management | ✅ Tested | Supports sending screenshots to Feishu |
| 🔍 Search Content | ✅ Tested | Keyword search, filtering |
| 📄 Get Details | ✅ Tested | Includes comment list |
| 📤 Publish Image & Text | ✅ Tested | Cover generator integration |
| 👍 Like | ✅ Tested | Like a single post |
| 💬 Post Comment | ✅ Tested | Main comment |
| ↩️ Reply to Comment | ✅ Tested | Sub-comment reply |
| ⭐ Favorite | ✅ Tested | Favorite/Unfavorite |
| 🔄 Get Recommendations | ✅ Tested | Homepage feeds |
All 13 MCP tools are fully available!
🚀 Quick Start
1. Log in
# 方式1:一键登录(推荐)
bash xhs_login.sh --notify
# 方式2:本地登录
bash xhs_login.sh
2. Start the MCP server
./xiaohongshu-mcp-darwin-arm64 &
3. Use the features
# 检查登录状态
python3 scripts/xhs_client.py status
# 搜索内容
python3 scripts/xhs_client.py search "AI"
# 发布内容
python3 scripts/xhs_client.py publish "标题" "内容" "图片URL"
📚 Complete Operation Guide
MCP Tool List
| Tool | Feature | Use Case |
|---|---|---|
check_login_status |
Check login status | Confirm account status |
list_feeds |
Get recommendation list | Discover trending content |
search_feeds |
Search content | Keyword search |
get_feed_detail |
Get post details | View comments |
publish_content |
Publish image & text | Create new content |
publish_with_video |
Publish video | Video content |
post_comment_to_feed |
Post comment | Reply to fans |
reply_comment_in_feed |
Reply to comment | Interaction |
like_feed |
Like | Like post |
favorite_feed |
Favorite | Favorite post |
delete_cookies |
Delete cookies | Reset login |
get_login_qrcode |
Get QR code | Log in again |
user_profile |
Get user profile | View profile |
💬 Comment Interaction Strategy
Persona maintenance
Persona: rational thinker, not a contrarian
Comment section interaction requirements:
- ✅ Rational analysis, respect different opinions
- ✅ Rebuttals backed by data
- ✅ Natural conversational feel
- ❌ Attack commenters
- ❌ Argue unreasonably
Comment rules
| Comment type | Like | Reply |
|---|---|---|
| Agreeing viewpoint | ✅ | ✅ Continuity |
| Partial agreement | ❌ | ✅ Add viewpoint |
| Opposing viewpoint | ❌ | ✅ Respectful expression |
| Question | ✅ | ✅ Direct answer |
| Share experience | ✅ | ✅ Resonance |
Reply Templates
Agreement type:
"说出了我想说的![补充细节]"
"对对对,尤其是[具体例子]..."
Partial agreement type:
"有道理,不过我觉得[补充观点]"
"同意一半吧,另外[补充视角]"
Opposite opinion type:
"你的观点挺有意思,不过我觉得[不同看法]"
"可能我表达不清楚,我想说的是[重新解释]"
Question type:
"好问题!我的看法是[直接回答]"
"这个要分情况,[分情况说明]"
Experience sharing type:
"太真实了![共鸣]"
"你这个经历太有代表性了![延伸]"
Reply Requirements
- Reply to every comment - Show activity
- Topic relevance - Stick to the core of the post
- Continuity - Not perfunctory
- No AI feel - Natural and colloquial
- Maintain persona - Rational thinker
🔧 Technical Implementation
MCP HTTP API
All features can be called via HTTP API:
# MCP Endpoint
http://localhost:18060/mcp
# 格式
curl -X POST http://localhost:18060/mcp \
-H "Content-Type: application/json" \
-H "Mcp-Session-Id: <SESSION_ID>" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_feeds",
"arguments": {
"keyword": "AI"
}
}
}'
MCP Session Retrieval
# 初始化
RESPONSE=$(curl -s -i -X POST http://localhost:18060/mcp \
-H "Content-Type: application/json" \
-c cookies.txt \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}')
# 提取 Session ID
SESSION_ID=$(echo "$RESPONSE" | grep -i "Mcp-Session-Id:" | cut -d' ' -f2)
Example: Complete Publishing Process
#!/bin/bash
MCP_URL="http://localhost:18060/mcp"
COOKIE_FILE="cookies.txt"
# 1. 初始化
RESPONSE=$(curl -s -i -X POST "$MCP_URL" \
-H "Content-Type: application/json" \
-c "$COOKIE_FILE" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}')
SESSION_ID=$(echo "$RESPONSE" | grep -i "Mcp-Session-Id:" | cut -d' ' -f2)
# 2. 发送初始化通知
curl -s -X POST "$MCP_URL" \
-H "Content-Type: application/json" \
-H "Mcp-Session-Id: $SESSION_ID" \
-d '{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}' > /dev/null
# 3. 发布内容
curl -s -X POST "$MCP_URL" \
-H "Content-Type: application/json" \
-H "Mcp-Session-Id: $SESSION_ID" \
-d '{
"jsonrpc": "2.0",
"id": 100,
"method": "tools/call",
"params": {
"name": "publish_content",
"arguments": {
"title": "AI正在毁掉这一代年轻人?",
"content": "🔥 争议话题...\n\n详细内容...",
"images": ["/tmp/cover.jpg"]
}
}
}'
Example: Comment Interaction
#!/bin/bash
MCP_URL="http://localhost:18060/mcp"
COOKIE_FILE="cookies.txt"
SESSION_ID="YOUR_SESSION_ID"
# 1. 获取评论列表
curl -s -X POST "$MCP_URL" \
-H "Content-Type: application/json" \
-H "Mcp-Session-Id: $SESSION_ID" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_feed_detail",
"arguments": {
"feed_id": "698c441c000000002801d381",
"xsec_token": "YOUR_TOKEN",
"load_all_comments": true
}
}
}'
# 2. 点赞
curl -s -X POST "$MCP_URL" \
-H "Content-Type: application/json" \
-H "Mcp-Session-Id: $SESSION_ID" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "like_feed",
"arguments": {
"feed_id": "698c441c000000002801d381",
"xsec_token": "YOUR_TOKEN"
}
}
}'
# 3. 发表评论
curl -s -X POST "$MCP_URL" \
-H "Content-Type: application/json" \
-H "Mcp-Session-Id: $SESSION_ID" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "post_comment_to_feed",
"arguments": {
"feed_id": "698c441c000000002801d381",
"xsec_token": "YOUR_TOKEN",
"content": "说出了我想说的!补充细节..."
}
}
}'
# 4. 回复评论
curl -s -X POST "$MCP_URL" \
-H "Content-Type: application/json" \
-H "Mcp-Session-Id: $SESSION_ID" \
-d '{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "reply_comment_in_feed",
"arguments": {
"feed_id": "68786933000000000d01a693",
"xsec_token": "YOUR_TOKEN",
"comment_id": "68786afc000000001101ada6",
"user_id": "6695e7370000000003032a17",
"content": "说得有道理!补充观点..."
}
}
}'
🛠️ Script Tools
xhs_client.py - Python Client
# 检查状态
python3 scripts/xhs_client.py status
# 搜索
python3 scripts/xhs_client.py search "AI" --sort "最新" --type "图文" --time "一周内"
# 发布
python3 scripts/xhs_client.py publish "标题" "内容" "图片URL" --tags "标签1,标签2"
# 获取详情
python3 scripts/xhs_client.py detail <feed_id> <xsec_token> --comments
xhs_mcp.py - Direct MCP Call
# 列出所有工具
python3 scripts/xhs_mcp.py tools
# 发表评论
python3 scripts/xhs_mcp.py comment <feed_id> <xsec_token> "评论内容"
generate_cover.py - Cover Generator
# 生成封面
python3 generate_cover.py --title "标题" --output /tmp/cover.jpg
# 选项
--font-size 80 # 字体大小
--padding 60 # 内边距
--max-width 600 # 最大宽度
📁 File Structure
xiaohongshu-mcp-skill/
├── SKILL.md # 本文档
├── README.md # 中文文档
├── STRATEGY.md # 运营策略(含评论互动)
├── install.sh # 安装脚本
├── xhs_login.sh # 一键登录
├── generate_cover.py # 封面生成器
├── data/
│ ├── post_history.json # 发布记录
│ ├── hot_topics.json # 热点选题
│ └── cookies.json # 登录 cookies
└── scripts/
├── xhs_client.py # Python 客户端
├── xhs_mcp.py # MCP 直接调用
├── xhs_login_sop.py # 登录 SOP
└── publish_smart.py # 智能发布脚本
📊 Test Records
Tested Features ✅
| Feature | Status | Test Time | Notes |
|---|---|---|---|
| Publish Image and Text | ✅ | 2026-02-11 | 2 posts published |
| Search Content | ✅ | 2026-02-11 | 22 results |
| Get Details | ✅ | 2026-02-11 | Includes comment list |
| Post Comment | ✅ | 2026-02-11 | 6 comments |
| Like | ✅ | 2026-02-11 | API successful |
| Favorite | ✅ | 2026-02-11 | Functioning normally |
| Reply to Comment | ✅ | 2026-02-11 | API successful |
Test Posts
-
"Art academy students are all using AI? I just laughed"
- Feed ID:
698c441c000000002801d381 - Likes: 2, Comments: 6
- Feed ID:
-
"Is AI destroying this generation of young people?"
- Feed ID:
698c76f8000000001a024a93 - Likes: 1, Comments: 0
- Feed ID:
🔗 Related Resources
- GitHub: https://github.com/tclawde/xiaohongshu-mcp-skill
- MCP Server: xpzouying/xiaohongshu-mcp
- OpenClaw: https://github.com/openclaw/openclaw
📝 Changelog
v3.0 (2026-02-11)
- ✅ Added complete comment interaction strategy
- ✅ Added MCP HTTP API call examples
- ✅ Added complete list of 13 tools
- ✅ Added script tool usage instructions
- ✅ Added technical implementation details
- ✅ Added test records
v2.0 (2026-02-11)
- ✅ Login fix (supports Xiaohongshu page changes)
- ✅ Feishu notification integration
- ✅ Python client improvements
v1.0 (2026-02-11)
- ✅ Initial version
- ✅ Basic publishing features
- ✅ Search feature
Maintainer: TClawDE 🦀 Last updated: 2026-02-11