@clawhub-palmpalm7-44e976dc5c
Trigger Gemini Deep Research via browser and save results to Notion. Use when the user asks to "deep research" a topic, says "gemini deep research", or wants...
---
name: gemini-deep-research
description: Trigger Gemini Deep Research via browser and save results to Notion. Use when the user asks to "deep research" a topic, says "gemini deep research", or wants an in-depth research report. Execute ALL steps in the main session (browser tool requires main session access).
---
# Gemini Deep Research → Notion
## Execution Mode
**Run ALL steps in the MAIN SESSION. Do NOT spawn a subagent.**
The browser tool (OpenClaw managed profile) is only available in the main session.
Subagents cannot access the browser, so all browser automation must happen here.
Reply first: "🔬 Deep Research starting for: [topic]. This takes ~25 min. I'll update you when done."
Then execute all phases below sequentially.
---
## Instructions
Complete ALL steps below in the main session.
### Phase 1: Trigger Deep Research
1. `browser action=open profile=openclaw targetUrl="https://gemini.google.com/app"`
2. Snapshot, find the text input, type the research query. **Always prepend "请用中文回答。" to the query** so the research output is in Chinese.
3. Click **"工具" (Tools)** button (has `page_info` icon) → click **"Deep Research"** in the menu
4. Click **Send** to submit the query
5. Wait for research plan to appear (~10s), then click **"Start research"** / **"开始研究"** button
- If snapshot-click doesn't work, use JS: `(() => { var btn = Array.from(document.querySelectorAll('button')).find(b => /Start research|开始研究/.test(b.textContent.trim())); if (btn) { btn.click(); return 'clicked'; } return 'not found'; })()`
6. Verify research started: button should be disabled, status shows "Researching X websites..." or "正在研究..."
7. Save the conversation URL from the browser
### Phase 2: Wait for Completion
1. Run `exec("sleep 1200")` (20 minutes) + `process(poll, timeout=1200000)`
2. After waking, check status via JS: `(() => { var el = document.querySelectorAll('message-content')[1]; return el ? el.innerText.substring(0, 200) : 'NOT_FOUND'; })()`
3. Look for completion signals: "I've completed your research" or "已完成"
4. If still running, sleep another 600s and check again (max 2 retries)
5. If failed/stuck after retries, announce the failure and exit
### Phase 3: Extract Report
1. Count message-content elements: `document.querySelectorAll('message-content').length`
2. The research report is in the LAST `message-content` element (usually index 2)
3. Get total length: `document.querySelectorAll('message-content')[2]?.innerText?.length`
4. Extract in 8000-char chunks using substring: `document.querySelectorAll('message-content')[N]?.innerText?.substring(START, END)`
5. Concatenate all chunks into the full report text
6. Save to a temp file: write full report to `/tmp/deep_research_<timestamp>.md`
### Phase 4: Export to Notion
**Parent page ID:** `31a4cfb5-c92b-809f-9d8a-dd451718a017` (Deep Research Database)
1. Read the Notion API key: `cat ~/.config/notion/api_key`
2. Parse the report into Notion blocks:
- Lines starting with `#` → heading_2/heading_3 blocks
- Bullet points → bulleted_list_item blocks
- Regular text → paragraph blocks
- Add a callout at top: "🔬 Generated by Gemini Deep Research on YYYY-MM-DD"
- Split rich_text at 2000 chars
3. Create the page via Notion API:
```bash
curl -s -X POST "https://api.notion.com/v1/pages" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2025-09-03" \
-H "Content-Type: application/json" \
-d '{"parent":{"page_id":"31a4cfb5-c92b-809f-9d8a-dd451718a017"},"icon":{"type":"emoji","emoji":"🔬"},"properties":{"title":{"title":[{"text":{"content":"TOPIC"}}]}},"children":[BLOCKS]}'
```
4. If >100 blocks, append remaining via PATCH to `/v1/blocks/{page_id}/children`
5. Rate limit: wait 0.5s between batch requests
### Phase 5: Announce
Report back with:
- Research topic
- Brief summary (2-3 key findings)
- Notion page URL: `https://www.notion.so/<page_id_without_dashes>`
## Notes
- Always use `profile="openclaw"` for browser
- Deep Research is under **"工具" (Tools) menu**, NOT the model selector
- If Gemini needs login, announce failure — user must log in manually
- The full pipeline should complete in ~25-30 min total
FILE:README.md
# Gemini Deep Research Skill for OpenClaw
An OpenClaw skill that triggers **Google Gemini Deep Research** via browser automation, extracts the full research report, and exports it to **Notion**.
## Features
- 🔬 Triggers Gemini Deep Research via OpenClaw's managed browser
- ⏳ Automatically waits for research completion (~20 min)
- 📄 Extracts the full report text
- 📝 Exports to Notion with proper formatting (headings, lists, paragraphs)
- 🤖 Runs as a subagent — non-blocking for main session
## Requirements
- **OpenClaw** with browser support (`profile="openclaw"`)
- **Gemini** account logged in via the OpenClaw browser profile
- **Notion API key** stored at `~/.config/notion/api_key`
- A **Notion parent page** to export reports to
## Installation
```bash
# Via ClawHub
clawhub install gemini-deep-research
# Or manually
git clone https://github.com/PalmPalm7/openclaw-gemini-deep-research.git ~/.openclaw/skills/gemini-deep-research
```
## Configuration
Before using, update the Notion parent page ID in `SKILL.md` to your own:
```
Parent page ID: 31a4cfb5-c92b-809f-9d8a-dd451718a017
```
Replace with your Notion page ID where research reports should be created.
## Usage
Just tell your OpenClaw agent:
> "Use Gemini deep research to research [topic]"
The skill will:
1. Open Gemini in the browser
2. Submit the query with Deep Research mode
3. Wait for completion
4. Extract the full report
5. Create a formatted Notion page
6. Report back with key findings and Notion link
## License
MIT
Deep research on Xiaohongshu (小红书) topics. Use when user wants to research a topic, analyze trends, gather insights from top posts, or produce a summary repo...
---
name: xiaohongshu-deep-research
description: Deep research on Xiaohongshu (小红书) topics. Use when user wants to research a topic, analyze trends, gather insights from top posts, or produce a summary report. Crawls posts via search, extracts high-engagement content, generates analysis with post links. Requires xiaohongshu-mcp service running.
---
# xiaohongshu-deep-research
小红书话题研究,自动爬取 + 分析 + 输出报告。
## 前置条件
- xiaohongshu-mcp 服务运行中 (`http://localhost:18060/mcp`)
- 已登录小红书账号
## 存储位置
```
~/xiaohongshu-research/{keyword}_{YYYYMMDD_HHmm}/
├── raw/posts.json # 原始数据
├── analysis/summary.md # 完整报告
└── metadata.json # 研究配置
```
## 研究流程
1. **关键词扩展** — 主词 + 3-4 个相关词
2. **批量搜索** — `POST /api/v1/feeds/search`
3. **去重排序** — 按点赞数取 Top 20-50
4. **生成报告** — 含链接、可转发摘要
## 帖子链接格式
```
https://www.xiaohongshu.com/explore/{note_id}
```
## 报告结构
```markdown
# {主题} 小红书研究
---
## 📱 速览(可直接转发)
{2-3段自然语言总结,像朋友分享一样写}
值得看的几篇:
• {标题} — {链接}
• {标题} — {链接}
---
## 数据概览
采集 {N} 篇帖子,共 {likes} 赞 / {collects} 收藏
## Top 10
1. **{标题}** @{作者}
{likes}👍 {collects}📁 | [查看]({link})
## 发现
{自然语言描述趋势和洞察}
## 数据
原始数据: `{path}`
```
## 写作风格
- 速览部分:像给朋友发消息,口语化,有观点
- 正文部分:简洁,重点突出,避免套话
- 不要用"本报告"、"经过分析"这类官腔
## 限制
⚠️ API 限制:帖子详情和评论无法获取,报告基于搜索结果元数据生成。
## 详细工作流
见 [references/workflow.md](references/workflow.md)
## Credits
基于 [xpzouying/xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp)
FILE:references/workflow.md
# 详细工作流
## 初始化
```bash
mkdir -p ~/xiaohongshu-research/{keyword}_{YYYYMMDD_HHmm}/{raw,analysis}
```
## 关键词扩展
```
输入: "露营"
→ 露营、露营装备推荐、露营好物、新手露营攻略
```
## 搜索 API
```bash
curl -s -X POST "http://localhost:18060/api/v1/feeds/search" \
-H "Content-Type: application/json" \
-d '{"keyword": "露营"}'
```
返回字段:
- `id` — 帖子 ID(用于生成链接)
- `noteCard.displayTitle` — 标题
- `noteCard.user.nickname` — 作者
- `noteCard.interactInfo.*` — 点赞/收藏/评论数
## 帖子链接
```
https://www.xiaohongshu.com/explore/{id}
```
## 数据处理
```bash
# 合并多个搜索结果,去重,按点赞排序
jq -s '
[.[].data.feeds[] | select(.modelType == "note")] |
unique_by(.id) |
sort_by(-(.noteCard.interactInfo.likedCount | tonumber))
' search_*.json > posts.json
```
## 报告模板
```markdown
# {主题} 小红书研究
> {日期} · 关键词: {keywords} · {N} 篇帖子
---
## 📱 速览
{用 2-3 段话总结发现,像给朋友发消息一样写。有观点,有态度,不要官腔。}
**值得看的几篇:**
• [{标题1}](https://www.xiaohongshu.com/explore/{id1})
• [{标题2}](https://www.xiaohongshu.com/explore/{id2})
• [{标题3}](https://www.xiaohongshu.com/explore/{id3})
---
## 数据
{N} 篇帖子 · {total_likes} 赞 · {total_collects} 收藏
## Top 10
1. **{标题}** @{作者}
{likes}👍 {collects}📁 · [看看](https://www.xiaohongshu.com/explore/{id})
2. ...
## 发现
{用自然语言写 3-5 个洞察,不要用 bullet points 堆砌}
## 建议
{如果用户要去/要买/要做什么,给出具体建议}
---
数据: `~/xiaohongshu-research/{keyword}_{date}/raw/posts.json`
```
## 写作指南
### 速览部分(可直接转发)
写法示例:
❌ 不要这样写:
> 经过对20篇小红书帖子的分析,我们发现波士顿美食话题具有较高的用户关注度。头部内容主要集中在龙虾、中餐等品类。
✅ 这样写:
> 刷了一圈小红书,波士顿吃的还挺多的。龙虾当然是必吃,但意外发现羊杂汤特别火——可能华人都馋这口。有个博主吃了100家店做了个系列,挺靠谱的可以参考。
### 正文部分
- 直接说结论,不要铺垫
- 数字要有意义("1489 赞"比"高互动"具体)
- 链接要能点
## 限制
- 帖子正文内容无法获取
- 评论无法获取
- 数据来自搜索结果元数据
Operate Xiaohongshu (小红书/RED) via local MCP service. Use when user wants to search notes, publish content (image/video), interact with posts (like/comment/fa...
---
name: xiaohongshu-mcp
description: Operate Xiaohongshu (小红书/RED) via local MCP service. Use when user wants to search notes, publish content (image/video), interact with posts (like/comment/favorite), or check account status on Xiaohongshu. Requires MCP service running at localhost:18060.
---
# xiaohongshu-mcp
小红书 MCP 服务操作。
## 快速开始
1. **检查服务状态**
```bash
curl -s -X POST http://localhost:18060/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"initialize","params":{},"id":1}'
```
2. **服务未运行时启动**
```bash
cd /Users/handi7/Documents/agentic-coding-projects/projects/xiaohongshu-mcp
nohup ./bin/xiaohongshu-mcp-darwin-arm64 > mcp.log 2>&1 &
```
## 可用工具
| 工具 | 说明 |
|------|------|
| `check_login_status` | 检查登录状态 |
| `get_login_qrcode` | 获取登录二维码 |
| `list_feeds` | 首页推荐 |
| `search_feeds` | 搜索内容 |
| `get_feed_detail` | 笔记详情 |
| `user_profile` | 用户主页 |
| `publish_content` | 发布图文 |
| `publish_with_video` | 发布视频 |
| `post_comment_to_feed` | 发表评论 |
| `reply_comment_in_feed` | 回复评论 |
| `like_feed` | 点赞 |
| `favorite_feed` | 收藏 |
| `delete_cookies` | 重置登录 |
## 内容限制
- 标题 ≤20 字
- 正文 ≤1000 字
- 每日 ≤50 篇
- 图文流量优于视频
## References
- **首次部署**: [references/deploy.md](references/deploy.md) — 下载、登录、启动服务
- **使用指南**: [references/usage.md](references/usage.md) — 工具详解、工作流、运营知识
## Credits
Based on [xpzouying/xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp) by [@xpzouying](https://github.com/xpzouying)
FILE:references/deploy.md
# 首次部署 xiaohongshu-mcp
> Based on [xpzouying/xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp)
## 环境要求
- macOS / Linux / Windows
- 首次运行自动下载 Chromium (~150MB)
## 部署步骤
### 1. 下载预编译二进制
从 [GitHub Releases](https://github.com/xpzouying/xiaohongshu-mcp/releases) 下载对应平台版本:
```bash
# macOS ARM64
gh release download --repo xpzouying/xiaohongshu-mcp \
--pattern "xiaohongshu-mcp-darwin-arm64.tar.gz" --dir /tmp
mkdir -p ~/xiaohongshu-mcp/bin
tar -xzf /tmp/xiaohongshu-mcp-darwin-arm64.tar.gz -C ~/xiaohongshu-mcp/bin/
# macOS Intel: xiaohongshu-mcp-darwin-amd64.tar.gz
# Linux x64: xiaohongshu-mcp-linux-amd64.tar.gz
# Windows x64: xiaohongshu-mcp-windows-amd64.zip
```
解压后包含两个可执行文件:
- `xiaohongshu-login-*` — 登录工具
- `xiaohongshu-mcp-*` — MCP 服务
### 2. 登录小红书
```bash
cd ~/xiaohongshu-mcp
./bin/xiaohongshu-login-darwin-arm64
```
- 首次运行自动下载 Chromium 到 `~/.cache/rod/browser/`
- 浏览器弹出后扫码或手机号登录
- 登录成功后 `cookies.json` 保存在当前目录
- 后续无需重复登录(除非 cookies 过期)
### 3. 启动 MCP 服务 (nohup 后台)
```bash
cd ~/xiaohongshu-mcp
nohup ./bin/xiaohongshu-mcp-darwin-arm64 > mcp.log 2>&1 &
echo $! > mcp.pid
```
服务监听: `http://localhost:18060/mcp`
验证:
```bash
curl -s -X POST http://localhost:18060/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"initialize","params":{},"id":1}'
```
### 4. 配置 MCP 客户端
**Claude Code:**
```bash
claude mcp add --transport http xiaohongshu-mcp http://localhost:18060/mcp
```
**其他 MCP 客户端配置:**
```json
{
"mcpServers": {
"xiaohongshu-mcp": {
"url": "http://localhost:18060/mcp",
"transport": "http"
}
}
}
```
## 本机实际部署路径
项目目录: `/Users/handi7/Documents/agentic-coding-projects/projects/xiaohongshu-mcp`
启动服务:
```bash
cd /Users/handi7/Documents/agentic-coding-projects/projects/xiaohongshu-mcp
nohup ./bin/xiaohongshu-mcp-darwin-arm64 > mcp.log 2>&1 &
```
## 日常运维
| 操作 | 命令 |
|------|------|
| 启动服务 | `nohup ./bin/xiaohongshu-mcp-darwin-arm64 > mcp.log 2>&1 &` |
| 查看日志 | `tail -f mcp.log` |
| 停止服务 | `kill $(lsof -ti:18060)` 或 `kill $(cat mcp.pid)` |
| 重新登录 | `./bin/xiaohongshu-login-darwin-arm64` |
| 查看 PID | `lsof -ti:18060` |
## 注意事项
1. **同账号单端登录**:小红书不允许同一账号在多个 web 端登录,保持 MCP 独占访问
2. **Cookies 过期**:需重新运行登录工具
3. **实名认证**:新号可能触发实名认证提醒,建议先实名
4. **发帖限制**:每天 50 篇上限
FILE:references/usage.md
# xiaohongshu-mcp 使用指南
## 前置条件
- MCP 服务运行在 `http://localhost:18060/mcp`
- 已完成小红书登录(cookies.json 存在)
## 可用工具 (13个)
### 账号管理
| 工具 | 说明 |
|------|------|
| `check_login_status` | 检查登录状态 |
| `get_login_qrcode` | 获取登录二维码(Base64 图片 + 超时时间) |
| `delete_cookies` | 删除 cookies 重置登录状态 |
### 内容浏览
| 工具 | 说明 |
|------|------|
| `list_feeds` | 获取首页推荐 Feeds |
| `search_feeds` | 搜索小红书内容 |
| `get_feed_detail` | 获取笔记详情(内容、图片、互动数据、评论) |
| `user_profile` | 获取用户主页(基本信息、关注/粉丝、笔记列表) |
### 内容发布
| 工具 | 说明 |
|------|------|
| `publish_content` | 发布图文内容 |
| `publish_with_video` | 发布视频内容(仅支持本地文件) |
### 互动操作
| 工具 | 说明 |
|------|------|
| `post_comment_to_feed` | 发表评论 |
| `reply_comment_in_feed` | 回复评论 |
| `like_feed` | 点赞/取消点赞 |
| `favorite_feed` | 收藏/取消收藏 |
## 常用工作流
### 1. 搜索并获取笔记详情
```
1. search_feeds(keyword="xxx") → 获取搜索结果列表
2. 从结果中提取 note_id 和 xsec_token
3. get_feed_detail(note_id, xsec_token) → 获取完整详情
```
### 2. 发布图文笔记
```
publish_content(
title="标题(≤20字)",
content="正文(≤1000字)",
images=["/path/to/img1.jpg", "/path/to/img2.jpg"]
)
```
图片支持:
- 本地绝对路径(推荐)
- HTTP/HTTPS URL
### 3. 发布视频笔记
```
publish_with_video(
title="标题(≤20字)",
content="正文(≤1000字)",
video="/path/to/video.mp4"
)
```
仅支持本地视频文件,建议 <1GB。
### 4. 批量互动
```
1. list_feeds() 或 search_feeds() 获取笔记列表
2. 遍历结果调用 like_feed / favorite_feed / post_comment_to_feed
```
## 重要参数说明
### xsec_token
- 多数操作需要 `xsec_token` 参数
- 从 `list_feeds` 或 `search_feeds` 返回结果中获取
- 与 `note_id` 配对使用
### note_id
- 笔记唯一标识
- 从搜索/推荐结果中获取
## 运营知识
- **标题**:≤20字(硬限制)
- **正文**:≤1000字(硬限制)
- **每日发帖**:≤50篇
- **图文优于视频**:推荐角度图文流量更好
- **Tags**:添加合适标签增加曝光
- **违禁词**:使用前检查内容是否含违禁词
- **禁止行为**:引流、纯搬运会被打击
## 错误排查
| 问题 | 解决 |
|------|------|
| 登录失效 | 运行 `xiaohongshu-login-*` 重新登录 |
| 无法发布 | 检查标题/正文长度限制 |
| 找不到笔记 | 确认 note_id 和 xsec_token 配对正确 |
| 服务不响应 | `tail -f mcp.log` 查看日志 |