xhs-mcp 0.7.3 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +65 -13
- package/README.md +46 -4
- package/dist/{942.js → 449.js} +15 -7
- package/dist/xhs-mcp.js +267 -0
- package/docs/HTTP_TRANSPORTS.md +0 -4
- package/docs/PUBLISH_GUIDE.md +0 -6
- package/docs/USAGE_GUIDE.md +336 -0
- package/package.json +9 -14
- package/dist/xhs-cli.js +0 -267
- package/docs/PROJECT_STRUCTURE.md +0 -202
- package/docs/WEBPACK_OPTIMIZATION.md +0 -156
package/README.en.md
CHANGED
|
@@ -17,7 +17,13 @@ Unified CLI `xhs-mcp` with built-in MCP server subcommand. Automate XiaoHongShu
|
|
|
17
17
|
## ✨ Features
|
|
18
18
|
|
|
19
19
|
- Auth: login, logout, status check
|
|
20
|
-
- Publish: unified content publishing
|
|
20
|
+
- Publish: unified content publishing
|
|
21
|
+
- **Images**: 1-18 files or URLs
|
|
22
|
+
- **Videos**: exactly 1 file
|
|
23
|
+
- ⭐ **New**: Auto-download image URLs (HTTP/HTTPS)
|
|
24
|
+
- ⭐ **New**: Precise title width validation (CJK: 2 units, ASCII: 1 unit)
|
|
25
|
+
- Support local paths and URLs mixed
|
|
26
|
+
- Smart caching to avoid duplicate downloads
|
|
21
27
|
- Discover: home feeds, keyword search, note detail, comment
|
|
22
28
|
- Automation: Puppeteer-driven, headless mode, cookie management
|
|
23
29
|
|
|
@@ -27,8 +33,9 @@ Unified CLI `xhs-mcp` with built-in MCP server subcommand. Automate XiaoHongShu
|
|
|
27
33
|
- `xhs_discover_feeds`, `xhs_search_note`, `xhs_get_note_detail`
|
|
28
34
|
- `xhs_comment_on_note`
|
|
29
35
|
- `xhs_publish_content` (unified interface: `type`, `title`, `content`, `media_paths`, `tags`)
|
|
30
|
-
- Images
|
|
31
|
-
- Videos
|
|
36
|
+
- **Images**: 1-18 image files or URLs
|
|
37
|
+
- **Videos**: exactly 1 video file
|
|
38
|
+
- **Mixed**: Support image URLs and local paths together
|
|
32
39
|
|
|
33
40
|
## 🚀 Quick Start (MCP)
|
|
34
41
|
|
|
@@ -68,18 +75,37 @@ echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | npx xhs-mcp mcp
|
|
|
68
75
|
## 🧰 CLI
|
|
69
76
|
|
|
70
77
|
```bash
|
|
78
|
+
# Auth
|
|
71
79
|
npx xhs-mcp login --timeout 120
|
|
72
80
|
npx xhs-mcp logout
|
|
73
81
|
npx xhs-mcp status
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
|
|
83
|
+
# Browser
|
|
84
|
+
npx xhs-mcp browser # check and install Chromium, shows executable path
|
|
85
|
+
|
|
86
|
+
# Discover
|
|
87
|
+
npx xhs-mcp feeds
|
|
88
|
+
npx xhs-mcp search -k keyword
|
|
89
|
+
npx xhs-mcp note-detail --feed-id <id> --xsec-token <token>
|
|
90
|
+
npx xhs-mcp comment --feed-id <id> --xsec-token <token> -n "Nice!"
|
|
91
|
+
|
|
92
|
+
# Publish with local images
|
|
93
|
+
npx xhs-mcp publish --type image --title Title --content Content -m path1.jpg,path2.png --tags a,b
|
|
94
|
+
|
|
95
|
+
# ⭐ Publish with image URLs (auto-download)
|
|
96
|
+
npx xhs-mcp publish --type image --title Title --content Content -m "https://example.com/img1.jpg,https://example.com/img2.png" --tags a,b
|
|
97
|
+
|
|
98
|
+
# Mix URLs and local paths
|
|
99
|
+
npx xhs-mcp publish --type image --title Title --content Content -m "https://example.com/img1.jpg,./local/img2.jpg" --tags a,b
|
|
100
|
+
|
|
101
|
+
# Video
|
|
102
|
+
npx xhs-mcp publish --type video --title Title --content Content -m video.mp4 --tags a,b
|
|
103
|
+
|
|
104
|
+
# Tools
|
|
105
|
+
npx xhs-mcp tools [--detailed] [--json]
|
|
106
|
+
|
|
107
|
+
# MCP Server
|
|
108
|
+
npx xhs-mcp mcp --mode http --port 3000
|
|
83
109
|
```
|
|
84
110
|
|
|
85
111
|
## 🔧 Client Integration (Cursor)
|
|
@@ -100,9 +126,35 @@ npx xhs-mcp status
|
|
|
100
126
|
|
|
101
127
|
## ⚠️ Notes
|
|
102
128
|
|
|
103
|
-
- Title≤20, content≤1000,
|
|
129
|
+
- **Images**: Title≤20 chars (40 display units), content≤1000, 1-18 images
|
|
130
|
+
- **Videos**: exactly 1 video file, recommended size ≤500MB
|
|
104
131
|
- Avoid multiple web logins for the same account simultaneously
|
|
105
132
|
- Keep reasonable posting frequency
|
|
133
|
+
- Image URLs auto-download to `./temp_images/` directory (cached)
|
|
134
|
+
- Supported image formats: JPEG, PNG, GIF, WebP, BMP
|
|
135
|
+
|
|
136
|
+
## 📖 Documentation and Examples
|
|
137
|
+
|
|
138
|
+
### 📚 Documentation
|
|
139
|
+
- [Usage Guide](./docs/USAGE_GUIDE.md) - Detailed usage and best practices
|
|
140
|
+
- [HTTP Transports](./docs/HTTP_TRANSPORTS.md) - HTTP/SSE mode configuration
|
|
141
|
+
- [Publish Guide](./docs/PUBLISH_GUIDE.md) - NPM publishing process
|
|
142
|
+
|
|
143
|
+
## 🛠️ Build Notes
|
|
144
|
+
|
|
145
|
+
- Unified single production build config: `config/webpack.config.js`
|
|
146
|
+
- Development and optimized variants have been removed.
|
|
147
|
+
- For development:
|
|
148
|
+
- `npm run dev` (run TypeScript CLI directly)
|
|
149
|
+
- `npm run build` (bundle to `dist/xhs-mcp.js`)
|
|
150
|
+
|
|
151
|
+
### 🎨 Examples
|
|
152
|
+
- [Examples](./examples/README.md) - Image and publishing examples
|
|
153
|
+
- [Sample Images](./examples/images/) - Test images
|
|
154
|
+
|
|
155
|
+
### 🧪 Tests
|
|
156
|
+
- [Run Tests](./tests/README.md) - Testing guide
|
|
157
|
+
- Run all tests: `npm test`
|
|
106
158
|
|
|
107
159
|
## 🙏 Acknowledgments
|
|
108
160
|
|
package/README.md
CHANGED
|
@@ -17,7 +17,14 @@
|
|
|
17
17
|
## ✨ 功能
|
|
18
18
|
|
|
19
19
|
- 认证:登录、登出、状态检查
|
|
20
|
-
-
|
|
20
|
+
- 发布:图文和视频发布
|
|
21
|
+
- **图文发布**:标题≤20字符(40显示单位)、内容≤1000、最多18图
|
|
22
|
+
- **视频发布**:支持 MP4、MOV、AVI、MKV、WebM、FLV、WMV 格式
|
|
23
|
+
- ⭐ **新功能**: 支持图片 URL 自动下载(HTTP/HTTPS)
|
|
24
|
+
- ⭐ **新功能**: 标题宽度精确验证(CJK字符2单位,ASCII字符1单位)
|
|
25
|
+
- 支持本地图片路径
|
|
26
|
+
- 支持 URL 和本地路径混合使用
|
|
27
|
+
- 智能缓存机制,避免重复下载
|
|
21
28
|
- 发现:推荐、搜索、详情、评论
|
|
22
29
|
- 自动化:Puppeteer 驱动、无头模式、Cookie 管理
|
|
23
30
|
|
|
@@ -27,8 +34,9 @@
|
|
|
27
34
|
- `xhs_discover_feeds`、`xhs_search_note`、`xhs_get_note_detail`
|
|
28
35
|
- `xhs_comment_on_note`
|
|
29
36
|
- `xhs_publish_content`(统一发布接口:`type`、`title`、`content`、`media_paths`、`tags`)
|
|
30
|
-
-
|
|
31
|
-
-
|
|
37
|
+
- **图片发布**:1-18个图片文件或URL
|
|
38
|
+
- **视频发布**:恰好1个视频文件
|
|
39
|
+
- **混合使用**:支持图片URL和本地路径混合
|
|
32
40
|
|
|
33
41
|
## 🚀 快速开始(MCP)
|
|
34
42
|
|
|
@@ -107,7 +115,16 @@ npx xhs-mcp note-detail --feed-id <id> --xsec-token <token> [-b /path/to/chromiu
|
|
|
107
115
|
npx xhs-mcp comment --feed-id <id> --xsec-token <token> -n "Nice!" [-b /path/to/chromium]
|
|
108
116
|
|
|
109
117
|
# 发布
|
|
118
|
+
# 使用本地图片
|
|
110
119
|
npx xhs-mcp publish --type image --title 标题 --content 内容 -m path1.jpg,path2.png --tags a,b [-b /path/to/chromium]
|
|
120
|
+
|
|
121
|
+
# ⭐ 使用图片 URL(自动下载)
|
|
122
|
+
npx xhs-mcp publish --type image --title 标题 --content 内容 -m "https://example.com/img1.jpg,https://example.com/img2.png" --tags a,b
|
|
123
|
+
|
|
124
|
+
# 混合使用 URL 和本地路径
|
|
125
|
+
npx xhs-mcp publish --type image --title 标题 --content 内容 -m "https://example.com/img1.jpg,./local/img2.jpg" --tags a,b
|
|
126
|
+
|
|
127
|
+
# 发布视频
|
|
111
128
|
npx xhs-mcp publish --type video --title 视频标题 --content 视频描述 -m path/to/video.mp4 --tags a,b [-b /path/to/chromium]
|
|
112
129
|
|
|
113
130
|
# 查看可用工具
|
|
@@ -165,9 +182,34 @@ npx xhs-mcp mcp [--mode stdio|http] [--port 3000]
|
|
|
165
182
|
|
|
166
183
|
## ⚠️ 注意事项
|
|
167
184
|
|
|
168
|
-
-
|
|
185
|
+
- **图文发布**:标题≤20、内容≤1000、图片≤18
|
|
186
|
+
- **视频发布**:支持多种格式,文件大小建议≤500MB
|
|
169
187
|
- 避免同账号多端同时网页登录
|
|
170
188
|
- 合理控制发帖频率
|
|
189
|
+
- 图片 URL 自动下载到 `./temp_images/` 目录(自动缓存)
|
|
190
|
+
- 图片 URL 支持格式:JPEG、PNG、GIF、WebP、BMP
|
|
191
|
+
|
|
192
|
+
## 📖 文档和示例
|
|
193
|
+
|
|
194
|
+
### 📚 文档
|
|
195
|
+
- [完整使用指南](./docs/USAGE_GUIDE.md) - 详细的使用说明和最佳实践
|
|
196
|
+
- [HTTP 传输文档](./docs/HTTP_TRANSPORTS.md) - HTTP/SSE 模式配置
|
|
197
|
+
- [发布指南](./docs/PUBLISH_GUIDE.md) - NPM 发布流程
|
|
198
|
+
|
|
199
|
+
### 🎨 示例
|
|
200
|
+
- [使用示例](./examples/README.md) - 图片和发布示例
|
|
201
|
+
- [示例图片](./examples/images/) - 可用于测试的示例图片
|
|
202
|
+
|
|
203
|
+
### 🧪 测试
|
|
204
|
+
- [运行测试](./tests/README.md) - 测试说明和用法
|
|
205
|
+
- 运行所有测试:`npm test`
|
|
206
|
+
|
|
207
|
+
## 🛠️ 构建说明
|
|
208
|
+
|
|
209
|
+
- 统一使用单一生产构建配置:`config/webpack.config.js`
|
|
210
|
+
- 已移除开发与优化变体;开发请直接运行:
|
|
211
|
+
- `npm run dev`(直接运行 TypeScript CLI)
|
|
212
|
+
- `npm run build`(打包到 `dist/xhs-mcp.js`)
|
|
171
213
|
|
|
172
214
|
## 🙏 致谢
|
|
173
215
|
|