| English | 简体中文 |
Unified CLI xhs-mcp with built-in MCP server subcommand. Automate XiaoHongShu (xiaohongshu.com) with Puppeteer: login, publishing, search, feed discovery, and commenting via MCP and CLI.
xhs-mcpnpx xhs-mcp <subcommand>npx xhs-mcp mcp [--mode stdio|http] [--port 3000]xhs_auth_login, xhs_auth_logout, xhs_auth_statusxhs_discover_feeds, xhs_search_note, xhs_get_note_detailxhs_comment_on_notexhs_get_user_notes, xhs_delete_note (user note management)xhs_publish_content (unified interface: type, title, content, media_paths, tags)
npx xhs-mcp mcp
# Debug logs
XHS_ENABLE_LOGGING=true npx xhs-mcp mcp
First run tip: if Puppeteer browsers are not installed yet, run
npx xhs-mcp browser # auto-check and install Chromium, shows executable path # or npx puppeteer browsers install chromeOutput example:
{ "success": true, "message": "Chromium is ready", "data": { "installed": true, "executablePath": "/path/to/chromium" } }
Verify MCP connection:
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | npx xhs-mcp mcp
# Auth
npx xhs-mcp login --timeout 120
npx xhs-mcp logout
npx xhs-mcp status
# Browser
npx xhs-mcp browser # check and install Chromium, shows executable path
# Discover
npx xhs-mcp feeds
npx xhs-mcp search -k keyword
# Current user's notes
npx xhs-mcp usernote list [-l 20] [--cursor <cursor>]
# Delete user notes
npx xhs-mcp usernote delete --note-id <id>
npx xhs-mcp usernote delete --last-published
# Interact
npx xhs-mcp comment --feed-id <id> --xsec-token <token> -n "Nice!"
# Publish with local images
npx xhs-mcp publish --type image --title Title --content Content -m path1.jpg,path2.png --tags a,b
# ⭐ Publish with image URLs (auto-download)
npx xhs-mcp publish --type image --title Title --content Content -m "https://example.com/img1.jpg,https://example.com/img2.png" --tags a,b
# Mix URLs and local paths
npx xhs-mcp publish --type image --title Title --content Content -m "https://example.com/img1.jpg,./local/img2.jpg" --tags a,b
# Video
npx xhs-mcp publish --type video --title Title --content Content -m video.mp4 --tags a,b
# Tools
npx xhs-mcp tools [--detailed] [--json]
# MCP Server
npx xhs-mcp mcp --mode http --port 3000
.cursor/mcp.json:
{
"mcpServers": {
"xhs-mcp": {
"command": "npx",
"args": ["xhs-mcp", "mcp"],
"env": { "XHS_ENABLE_LOGGING": "true" }
}
}
}
./temp_images/ directory (cached)config/webpack.config.jsnpm run dev (run TypeScript CLI directly)npm run build (bundle to dist/xhs-mcp.js)npm testBased on and extended from xiaohongshu-mcp (refactored to TypeScript, improved MCP implementation, log cleanup, published to NPM).