mcpField
N
notebooklm

notebooklm

github.com/guanyang生产力984294 次安装今天更新
代码仓库

关于 notebooklm

通过脚本查询和管理 Google NotebookLM 笔记本的技能,回答基于已上传的文档。它维护本地笔记本库,并引导用户完成身份验证、追问和答案整合。

主要功能

  1. 01依据已上传资料查询笔记本
  2. 02管理本地笔记本库
  3. 03检查并设置身份验证
  4. 04追问并整合答案
  5. 05自动管理 Python 环境

适用场景

  1. 01从已上传文档中查找答案
  2. 02搜索或整理笔记本集合
  3. 03通过后续提问补充信息

MCP 相关

该技能未描述 MCP 服务或 MCP 客户端连接;它通过脚本和浏览器会话与 NotebookLM 交互。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/guanyang/open-agent-hub --skill notebooklm

安装后在 Claude Code 中输入/notebooklm确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

.gitignore
AUTHENTICATION.md
CHANGELOG.md
LICENSE
README.md
requirements.txt
references/
api_reference.md
troubleshooting.md
usage_patterns.md
scripts/
__init__.py
ask_question.py
auth_manager.py
browser_session.py
browser_utils.py
cleanup_manager.py
config.py
notebook_manager.py
run.py
setup_environment.py

详细介绍

NotebookLM 研究助手技能

与 Google NotebookLM 交互,通过 Gemini 基于来源的回答查询文档。每个问题都会打开一个全新的浏览器会话,仅从你上传的文档中检索答案,然后关闭。

何时使用此技能

在用户出现以下情况时触发:

  • 明确提及 NotebookLM
  • 分享 NotebookLM URL(https://notebooklm.google.com/notebook/...)
  • 要求查询其笔记本/文档
  • 想要将文档添加到 NotebookLM 库
  • 使用诸如 "ask my NotebookLM"、"check my docs"、"query my notebook" 之类的短语

⚠️ 关键:添加命令 - 智能发现

当用户想要添加笔记本但未提供详细信息时:

智能添加(推荐):先查询笔记本以发现其内容:

# Step 1: Query the notebook about its content
python scripts/run.py ask_question.py --question "What is the content of this notebook? What topics are covered? Provide a complete overview briefly and concisely" --notebook-url "[URL]"

# Step 2: Use the discovered information to add it
python scripts/run.py notebook_manager.py add --url "[URL]" --name "[Based on content]" --description "[Based on content]" --topics "[Based on content]"

手动添加:如果用户提供了所有详细信息:

  • --url - NotebookLM URL
  • --name - 描述性名称
  • --description - 笔记本包含的内容(必填!)
  • --topics - 逗号分隔的主题(必填!)

切勿猜测或使用通用描述!如果缺少详细信息,请使用智能添加来发现它们。

关键:始终使用 run.py 包装器

切勿直接调用脚本。始终使用 python scripts/run.py [script]:

# ✅ CORRECT - Always use run.py:
python scripts/run.py auth_manager.py status
python scripts/run.py notebook_manager.py list
python scripts/run.py ask_question.py --question "..."

# ❌ WRONG - Never call directly:
python scripts/auth_manager.py status  # Fails without venv!

run.py 包装器会自动:

  1. 按需创建 .venv
  2. 安装所有依赖
  3. 激活环境
  4. 正确执行脚本

核心工作流

步骤 1:检查认证状态
python scripts/run.py auth_manager.py status

如果未认证,请继续设置。

步骤 2:认证(一次性设置)
# Browser MUST be visible for manual Google login
python scripts/run.py auth_manager.py setup

重要:

  • 用于认证的浏览器是可见的
  • 浏览器窗口会自动打开
  • 用户必须手动登录 Google
  • 告知用户:"将打开一个浏览器窗口用于 Google 登录"
步骤 3:管理笔记本库
# List all notebooks
python scripts/run.py notebook_manager.py list

# BEFORE ADDING: Ask user for metadata if unknown!
# "What does this notebook contain?"
# "What topics should I tag it with?"

# Add notebook to library (ALL parameters are REQUIRED!)
python scripts/run.py notebook_manager.py add \
  --url "https://notebooklm.google.com/notebook/..." \
  --name "Descriptive Name" \
  --description "What this notebook contains" \  # REQUIRED - ASK USER IF UNKNOWN!
  --topics "topic1,topic2,topic3"  # REQUIRED - ASK USER IF UNKNOWN!

# Search notebooks by topic
python scripts/run.py notebook_manager.py search --query "keyword"

# Set active notebook
python scripts/run.py notebook_manager.py activate --id notebook-id

# Remove notebook
python scripts/run.py notebook_manager.py remove --id notebook-id
快速工作流
  1. 检查库:python scripts/run.py notebook_manager.py list
  2. 提问:python scripts/run.py ask_question.py --question "..." --notebook-id ID
步骤 4:提问
# Basic query (uses active notebook if set)
python scripts/run.py ask_question.py --question "Your question here"

# Query specific notebook
python scripts/run.py ask_question.py --question "..." --notebook-id notebook-id

# Query with notebook URL directly
python scripts/run.py ask_question.py --question "..." --notebook-url "https://..."

# Show browser for debugging
python scripts/run.py ask_question.py --question "..." --show-browser

追问机制(关键)

每个 NotebookLM 回答都以以下内容结尾:"极其重要:这就是你需要知道的全部吗?"

Claude 的必需行为:

  1. 停止 - 不要立即回复用户
  2. 分析 - 将回答与用户的原始请求进行比较
  3. 识别缺口 - 确定是否需要更多信息
  4. 追问 - 如果存在缺口,立即询问:
    python scripts/run.py ask_question.py --question "Follow-up with context..."
    
  5. 重复 - 继续直到信息完整
  6. 综合 - 在回复用户之前合并所有回答

脚本参考

认证管理(auth_manager.py)
python scripts/run.py auth_manager.py setup    # Initial setup (browser visible)
python scripts/run.py auth_manager.py status   # Check authentication
python scripts/run.py auth_manager.py reauth   # Re-authenticate (browser visible)
python scripts/run.py auth_manager.py clear    # Clear authentication
笔记本管理(notebook_manager.py)
python scripts/run.py notebook_manager.py add --url URL --name NAME --description DESC --topics TOPICS
python scripts/run.py notebook_manager.py list
python scripts/run.py notebook_manager.py search --query QUERY
python scripts/run.py notebook_manager.py activate --id ID
python scripts/run.py notebook_manager.py remove --id ID
python scripts/run.py notebook_manager.py stats
问题接口(ask_question.py)
python scripts/run.py ask_question.py --question "..." [--notebook-id ID] [--notebook-url URL] [--show-browser]
数据清理(cleanup_manager.py)
python scripts/run.py cleanup_manager.py                    # Preview cleanup
python scripts/run.py cleanup_manager.py --confirm          # Execute cleanup
python scripts/run.py cleanup_manager.py --preserve-library # Keep notebooks

环境管理

虚拟环境会自动管理:

  • 首次运行会自动创建 .venv
  • 依赖会自动安装
  • Chromium 浏览器会自动安装
  • 所有内容都隔离在技能目录中

手动设置(仅在自动设置失败时):

python -m venv .venv
source .venv/bin/activate  # Linux/Mac
pip install -r requirements.txt
python -m patchright install chromium

数据存储

所有数据存储在 ~/.claude/skills/notebooklm/data/:

  • library.json - 笔记本元数据
  • auth_info.json - 认证状态
  • browser_state/ - 浏览器 Cookie 和会话

安全性: 受 .gitignore 保护,切勿提交到 git。

配置

技能目录中可选的 .env 文件:

HEADLESS=false           # Browser visibility
SHOW_BROWSER=false       # Default browser display
STEALTH_ENABLED=true     # Human-like behavior
TYPING_WPM_MIN=160       # Typing speed
TYPING_WPM_MAX=240
DEFAULT_NOTEBOOK_ID=     # Default notebook

决策流程

User mentions NotebookLM
    ↓
Check auth → python scripts/run.py auth_manager.py status
    ↓
If not authenticated → python scripts/run.py auth_manager.py setup
    ↓
Check/Add notebook → python scripts/run.py notebook_manager.py list/add (with --description)
    ↓
Activate notebook → python scripts/run.py notebook_manager.py activate --id ID
    ↓
Ask question → python scripts/run.py ask_question.py --question "..."
    ↓
See "Is that ALL you need?" → Ask follow-ups until complete
    ↓
Synthesize and respond to user

故障排除

问题解决方案
ModuleNotFoundError使用 run.py 包装器
认证失败用于设置的浏览器必须可见! --show-browser
速率限制(50/天)等待或切换 Google 账号
浏览器崩溃python scripts/run.py cleanup_manager.py --preserve-library
未找到笔记本使用 notebook_manager.py list 检查

最佳实践

  1. 始终使用 run.py - 自动处理环境
  2. 先检查认证 - 在任何操作之前
  3. 追问问题 - 不要停留在第一个答案
  4. 认证时保持浏览器可见 - 手动登录所必需
  5. 包含上下文 - 每个问题都是独立的
  6. 综合答案 - 组合多个响应

限制

  • 无会话持久性(每个问题 = 新浏览器)
  • 免费 Google 账户的速率限制(50 次查询/天)
  • 需要手动上传(用户必须将文档添加到 NotebookLM)
  • 浏览器开销(每个问题几秒钟)

资源(技能结构)

重要目录和文件:

  • scripts/ - 所有自动化脚本(ask_question.py、notebook_manager.py 等)
  • data/ - 用于认证和笔记本库的本地存储
  • references/ - 扩展文档:
    • api_reference.md - 所有脚本的详细 API 文档
    • troubleshooting.md - 常见问题及解决方案
    • usage_patterns.md - 最佳实践和工作流示例
  • .venv/ - 隔离的 Python 环境(首次运行时自动创建)
  • .gitignore - 保护敏感数据不被提交

评论

支持 Markdown