feat: add 'agent-reach configure xhs-cookies' command (#108) (#113)

Adds a proper way for AI agents to import XiaoHongShu cookies into
the xiaohongshu-mcp Docker container. Previously agents had no clear
command to use, leading to confusion loops (issue #108).

Supports two input formats:
- Cookie-Editor JSON export (array of cookie objects)
- Header String format (key1=val1; key2=val2; ...)

The command:
1. Parses and validates the cookie input
2. Finds the running xiaohongshu-mcp container
3. Reads COOKIES_PATH from container env
4. Writes cookies via docker cp
5. Verifies login status via mcporter

Also updates install.md with the new command.

Closes #108

Co-authored-by: Panniantong <panniantong@users.noreply.github.com>
This commit is contained in:
Pnant 2026-03-08 21:19:33 +08:00 committed by GitHub
parent eda80b89b5
commit 4b7d55111f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 180 additions and 3 deletions

View file

@ -148,9 +148,17 @@ mcporter config add xiaohongshu http://localhost:18060/mcp
>
> **登录方式(优先用 Cookie-Editor最简单**
> 1. 用户在自己的浏览器登录小红书 (xiaohongshu.com)
> 2. 用 [Cookie-Editor](https://chromewebstore.google.com/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm) 插件导出 CookieHeader String 格式)
> 2. 用 [Cookie-Editor](https://chromewebstore.google.com/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm) 插件导出 CookieJSON 或 Header String 格式均可
> 3. 把 Cookie 字符串发给 Agent
> 4. Agent 将 Cookie 写入 MCP 服务的 cookie 文件完成登录
> 4. Agent 运行命令完成登录:
>
> ```bash
> # JSON 格式Cookie-Editor → Export → JSON
> agent-reach configure xhs-cookies '[{"name":"web_session","value":"xxx","domain":".xiaohongshu.com",...}]'
>
> # 或 Header String 格式Cookie-Editor → Export → Header String
> agent-reach configure xhs-cookies "key1=val1; key2=val2; ..."
> ```
>
> **备选:** 本地电脑如果有浏览器,也可以打开 http://localhost:18060 扫码登录。