xiaohongshu-skill

xiaohongshu-skill

MCP server for automating Xiaohongshu (RED Note). Publish posts, search content, comment, like, and analyze creator data on China's largest lifestyle social platform.

Category
Visit Server

README

<p align="center"> <h1 align="center">πŸ“• xiaohongshu</h1> <p align="center">AI-powered Xiaohongshu (小纒书/RED) automation β€” publish, search, engage, and analyze.</p> </p>

<p align="center"> <a href="#cli-quick-start">CLI Quick Start</a> β€’ <a href="#features">Features</a> β€’ <a href="#quick-start">Quick Start</a> β€’ <a href="#mcp-tools">MCP Tools</a> β€’ <a href="#cdp-scripts">CDP Scripts</a> β€’ <a href="#openclaw-integration">OpenClaw</a> β€’ <a href="#claude-code-integration">Claude Code</a> β€’ <a href="./LICENSE">License</a> </p>


<p align="center"> <img src="./demo.gif" alt="xiaohongshu demo" width="800"> </p>

CLI Quick Start

The fastest way to get started β€” 3 commands from zero to posting:

# 1. Clone
git clone https://github.com/Youhai020616/xiaohongshu.git
cd xiaohongshu

# 2. One-click install (auto: Python check β†’ venv β†’ pip install β†’ MCP binary)
bash setup.sh

# 3. Initialize (auto: proxy config β†’ start MCP β†’ QR login)
source activate.sh && xhs init

Then just use:

xhs search "AIεˆ›δΈš"                                          # Search
xhs publish -t "Hello" -c "My first post" -i photo.jpg      # Publish
xhs like FEED_ID -t TOKEN                                    # Like
xhs analytics                                                # Dashboard
xhs --help                                                   # All commands

πŸ“– Full CLI guide: docs/cli-guide.md


What is this?

A complete toolkit for automating Xiaohongshu (小纒书/RED Note) operations through two complementary engines:

Engine Technology Use Cases Startup
MCP Server Go binary, JSON-RPC Publish, search, comment, like, follow Always-on daemon
CDP Scripts Python, Chrome DevTools Analytics dashboard, notifications, advanced search On-demand

Built as an OpenClaw Skill, but works standalone or with any MCP-compatible client (Claude Code, Cursor, etc.).

Features

  • πŸ“ Publish β€” Image posts and video posts with tags, scheduling, and visibility control
  • πŸ” Search β€” Keyword search with filters (sort, note type, suggested keywords)
  • πŸ’¬ Engage β€” Comment, reply, like, favorite on any post
  • πŸ‘€ Profile β€” Fetch any user's profile and posts
  • πŸ“Š Analytics β€” Creator dashboard data export (CSV), content performance metrics
  • πŸ”” Notifications β€” Fetch mentions and interaction notifications
  • πŸ‘₯ Multi-Account β€” Isolated Chrome profiles per account
  • πŸ” QR Code Login β€” Scan-to-login, persistent cookie storage

Quick Start

Prerequisites

  • macOS (Apple Silicon) β€” MCP binary is pre-built for darwin-arm64
  • Python 3.9+ (for CDP scripts)
  • Google Chrome (for CDP scripts and QR login)
  • A proxy/VPN if outside China (MCP requires -rod proxy flag)

1. Clone

git clone https://github.com/Youhai020616/xiaohongshu.git
cd xiaohongshu

2. Start MCP Server

cd mcp
chmod +x xiaohongshu-mcp-darwin-arm64

# Without proxy (inside China)
./xiaohongshu-mcp-darwin-arm64 -port :18060

# With proxy (outside China)
./xiaohongshu-mcp-darwin-arm64 -port :18060 -rod "proxy=http://127.0.0.1:7897"

3. Login

On first run, get a QR code to scan with your Xiaohongshu app:

curl -s -X POST http://127.0.0.1:18060/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"cli","version":"1.0"}}}'
# Save the Mcp-Session-Id from response headers

curl -s -X POST http://127.0.0.1:18060/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: YOUR_SESSION_ID" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'

curl -s -X POST http://127.0.0.1:18060/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: YOUR_SESSION_ID" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_login_qrcode","arguments":{}}}'

Or use the login helper binary:

cd mcp
./xiaohongshu-login-darwin-arm64

4. Publish Your First Post

curl -s -X POST http://127.0.0.1:18060/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: YOUR_SESSION_ID" \
  -d '{
    "jsonrpc":"2.0","id":3,
    "method":"tools/call",
    "params":{
      "name":"publish_content",
      "arguments":{
        "title":"Hello from API πŸš€",
        "content":"My first automated post on Xiaohongshu!",
        "images":["/path/to/image.jpg"],
        "tags":["ζ΅‹θ―•","θ‡ͺεŠ¨εŒ–"]
      }
    }
  }'

MCP Tools

The MCP server exposes these tools via the Model Context Protocol:

Tool Description Key Parameters
check_login_status Check if logged in β€”
get_login_qrcode Get QR code for login (base64) β€”
delete_cookies Reset login state β€”
publish_content Publish image post title, content, images, tags?, visibility?, is_original?, schedule_at?
publish_with_video Publish video post title, content, video (local path), tags?, visibility?, schedule_at?
search_feeds Search posts by keyword keyword, filters?
get_feed_detail Get post details + comments feed_id, xsec_token, load_all_comments?
post_comment_to_feed Comment on a post feed_id, xsec_token, content
reply_comment_in_feed Reply to a comment feed_id, xsec_token, comment_id, user_id, content
like_feed Like / unlike a post feed_id, xsec_token, unlike?
favorite_feed Favorite / unfavorite a post feed_id, xsec_token, unfavorite?
list_feeds Get homepage feed β€”
user_profile Get user profile + posts user_id, xsec_token
get_self_info Get own account info β€”

MCP Session Protocol

The MCP server uses Streamable HTTP transport. Every request must include:

Content-Type: application/json
Accept: application/json, text/event-stream
Mcp-Session-Id: <from initialize response header>

Session lifecycle: initialize β†’ notifications/initialized β†’ tools/call (repeat)

Parameters Reference

publish_content

  • title (string, required) β€” Max 20 Chinese characters
  • content (string, required) β€” Post body, max 1000 characters. Do NOT include hashtags here
  • images (string[], required) β€” Local file paths or HTTP URLs (at least 1)
  • tags (string[], optional) β€” Hashtags, e.g. ["ζ—…θ‘Œ", "美食"]
  • visibility (string, optional) β€” 公开可见 (default) / δ»…θ‡ͺ己可见 / δ»…δΊ’ε…³ε₯½ε‹ε―见
  • is_original (bool, optional) β€” Declare as original content
  • schedule_at (string, optional) β€” ISO 8601 datetime, e.g. 2026-03-15T10:30:00+08:00

publish_with_video

  • video (string, required) β€” Local absolute path to video file only

CDP Scripts

For features the MCP server doesn't support (analytics, notifications, suggested keywords), use the Python CDP scripts:

Setup

pip install -r requirements.txt

Chrome Launcher

# Start Chrome with isolated profile
python scripts/chrome_launcher.py

# Headless mode
python scripts/chrome_launcher.py --headless

# Stop Chrome
python scripts/chrome_launcher.py --kill

Available Commands

# Login (scan QR code)
python scripts/cdp_publish.py login

# Creator dashboard data β†’ CSV
python scripts/cdp_publish.py content-data --csv-file output.csv

# Notification mentions
python scripts/cdp_publish.py get-notification-mentions

# Search with filters
python scripts/cdp_publish.py search-feeds --keyword "AIεˆ›δΈš" --sort-by ζœ€ζ–° --note-type ε›Ύζ–‡

# Post detail
python scripts/cdp_publish.py get-feed-detail --feed-id FEED_ID --xsec-token TOKEN

# Comment
python scripts/cdp_publish.py post-comment-to-feed --feed-id FEED_ID --xsec-token TOKEN --content "Great post!"

# Publish via CDP (alternative to MCP)
python scripts/publish_pipeline.py --headless \
  --title-file title.txt --content-file content.txt \
  --image-urls "https://example.com/img.jpg"

Multi-Account

python scripts/cdp_publish.py add-account work --alias "Work Account"
python scripts/cdp_publish.py --account work login
python scripts/cdp_publish.py --account work content-data
python scripts/cdp_publish.py list-accounts

OpenClaw Integration

Install as an OpenClaw skill:

# Copy to skills directory
cp -r xiaohongshu ~/.openclaw/skills/xiaohongshu

# Start MCP server
cd ~/.openclaw/skills/xiaohongshu/mcp
./start.sh

The SKILL.md file provides full instructions for OpenClaw's AI agent to use the tools automatically.

Claude Code Integration

See docs/claude-code-integration.md for setup instructions with Claude Code.

Tips & Known Issues

  • Login verification: check_login_status has a DOM detection bug β€” use search_feeds with any keyword to verify login state
  • Post ID: publish_content may return an empty PostID β€” this is normal. Use search_feeds with your username to verify
  • Don't retry publishing β€” A timeout doesn't mean failure. Always verify before retrying
  • Proxy required: Outside China, the MCP server needs -rod "proxy=..." flag
  • Concurrent sessions: Don't log in to the same account from both MCP and web browser simultaneously
  • visibility values: Must be in Chinese: 公开可见, δ»…θ‡ͺ己可见, δ»…δΊ’ε…³ε₯½ε‹ε―见
  • schedule_at range: Must be between 1 hour and 14 days from now

Platform Support

Component macOS ARM64 macOS x86 Linux Windows
xhs CLI βœ… βœ… βœ… βœ…
MCP Server βœ… ❌ ❌ ❌
CDP Scripts βœ… βœ… βœ… βœ…

Windows / Linux / macOS x86 users: Run xhs init β€” the CLI auto-detects missing MCP binary and switches to CDP-only mode. All features (publish, search, analytics, etc.) work through Chrome.

# Windows
setup.bat                    # One-click install
activate.bat && xhs init    # Initialize (auto CDP mode)

# macOS / Linux
bash setup.sh
source activate.sh && xhs init

Project Structure

xiaohongshu/
β”œβ”€β”€ README.md                          # This file
β”œβ”€β”€ SKILL.md                           # OpenClaw skill definition
β”œβ”€β”€ pyproject.toml                     # CLI package config (pip install -e .)
β”œβ”€β”€ manifest.json                      # Skill metadata
β”œβ”€β”€ LICENSE                            # MIT License
β”œβ”€β”€ requirements.txt                   # Python dependencies (legacy)
β”œβ”€β”€ .gitignore
β”œβ”€β”€ src/xhs_cli/                       # ⭐ CLI package
β”‚   β”œβ”€β”€ main.py                        # Unified entry point (xhs command)
β”‚   β”œβ”€β”€ engines/
β”‚   β”‚   β”œβ”€β”€ mcp_client.py             # MCP JSON-RPC client (auto session)
β”‚   β”‚   └── cdp_client.py             # CDP scripts wrapper
β”‚   β”œβ”€β”€ commands/
β”‚   β”‚   β”œβ”€β”€ init.py                   # xhs init (guided setup)
β”‚   β”‚   β”œβ”€β”€ auth.py                   # xhs login/logout/status
β”‚   β”‚   β”œβ”€β”€ publish.py                # xhs publish (auto engine)
β”‚   β”‚   β”œβ”€β”€ search.py                 # xhs search/detail
β”‚   β”‚   β”œβ”€β”€ interact.py               # xhs like/comment/favorite
β”‚   β”‚   β”œβ”€β”€ analytics.py              # xhs analytics/notifications
β”‚   β”‚   β”œβ”€β”€ account.py                # xhs account management
β”‚   β”‚   β”œβ”€β”€ profile.py                # xhs me/profile
β”‚   β”‚   β”œβ”€β”€ server.py                 # xhs server start/stop/status
β”‚   β”‚   └── config_cmd.py             # xhs config show/set/get
β”‚   └── utils/
β”‚       β”œβ”€β”€ config.py                  # ~/.xhs/config.json management
β”‚       └── output.py                  # Rich formatted output
β”œβ”€β”€ mcp/
β”‚   β”œβ”€β”€ xiaohongshu-mcp-darwin-arm64   # MCP server binary
β”‚   β”œβ”€β”€ xiaohongshu-login-darwin-arm64 # Login helper binary
β”‚   └── start.sh                       # Startup script
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ cdp_publish.py                 # Main CDP automation (2700 lines)
β”‚   β”œβ”€β”€ chrome_launcher.py             # Chrome lifecycle management
β”‚   β”œβ”€β”€ publish_pipeline.py            # High-level publish workflow
β”‚   β”œβ”€β”€ feed_explorer.py               # Feed browsing utilities
β”‚   β”œβ”€β”€ account_manager.py             # Multi-account management
β”‚   β”œβ”€β”€ image_downloader.py            # Image download helper
β”‚   └── run_lock.py                    # Process locking
β”œβ”€β”€ config/
β”‚   └── accounts.json.example          # Account config template
└── docs/
    β”œβ”€β”€ cli-guide.md                   # ⭐ CLI usage guide
    └── claude-code-integration.md     # Claude Code setup guide

Contributing

Issues and PRs welcome! Areas where help is needed:

  • [ ] Cross-platform MCP builds (Linux, Windows, macOS x86)
  • [ ] MCP Go source code release
  • [ ] Video upload improvements
  • [ ] Rate limiting and retry logic
  • [ ] Test suite

License

MIT


<p align="center"> <sub>Built with ❀️ by <a href="https://github.com/Youhai020616">Youhai</a></sub> </p>

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured