fix(xiaohongshu): switch from Docker MCP to xhs-cli (pipx install) (#236)

Docker + Cookie import → `pipx install xiaohongshu-cli` + `xhs login`.
Tier downgraded from 2 to 1. xhs-cli (1,477 stars) auto-extracts
cookies from browser, supports search/read/comment/post/hot/feed.

- xiaohongshu.py: check() detects `xhs` binary, parses `xhs status`
- cli.py: install via pipx instead of Docker
- skill/references/social.md: updated XHS commands
- tests: 3 new tests for CLI-based check()
- 77 tests passing

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pnant
2026-03-31 17:17:19 +08:00
committed by GitHub
parent 15f161e5b5
commit bc2d554e13
4 changed files with 88 additions and 126 deletions
+14 -20
View File
@@ -871,30 +871,24 @@ def _install_mcporter():
except Exception:
print(" [!] Could not configure Exa. Run manually: mcporter config add exa https://mcp.exa.ai/mcp")
# Check XiaoHongShu MCP (only if server is running)
try:
r = subprocess.run(
["mcporter", "config", "list"], capture_output=True, encoding="utf-8", errors="replace", timeout=5
)
if "xiaohongshu" in r.stdout:
print(" ✅ XiaoHongShu MCP already configured")
else:
# Check if XHS MCP server is running on localhost:18060
import requests
# Check XiaoHongShu CLI
if shutil.which("xhs"):
print(" ✅ xhs-cli already installed (xiaohongshu-cli)")
else:
if shutil.which("pipx"):
try:
requests.get("http://localhost:18060/", timeout=3)
subprocess.run(
["mcporter", "config", "add", "xiaohongshu", "http://localhost:18060/mcp"],
capture_output=True, encoding="utf-8", errors="replace", timeout=10,
["pipx", "install", "xiaohongshu-cli"],
capture_output=True, encoding="utf-8", errors="replace", timeout=120,
)
print(" ✅ XiaoHongShu MCP auto-detected and configured")
if shutil.which("xhs"):
print(" ✅ xhs-cli installed (run `xhs login` to authenticate)")
else:
print(" -- xhs-cli install failed (optional). Run: pipx install xiaohongshu-cli")
except Exception:
print(" -- XiaoHongShu MCP not detected (optional)")
print(" Install: docker run -d --name xiaohongshu-mcp -p 18060:18060 xpzouying/xiaohongshu-mcp")
print(" Then: mcporter config add xiaohongshu http://localhost:18060/mcp")
print(" Repo: https://github.com/xpzouying/xiaohongshu-mcp")
except Exception:
pass
print(" -- xhs-cli install failed (optional). Run: pipx install xiaohongshu-cli")
else:
print(" -- xhs-cli requires pipx (optional). Run: pipx install xiaohongshu-cli")
def _install_mcporter_safe():