- name
- chem-nlm-helper
- description
- Bridges paper-mentor with NotebookLM. Creates notebooks, adds PDF/URL sources, runs queries with citation-grounded answers. Used by `paper-mentor` Phase 2 to build a literature library and run the 4-question summary on each paper. Triggers on phrases involving NotebookLM operations + chemistry/materials context.
- version
- 0.1.0
# chem-nlm-helper — NotebookLM Helper for Chemistry Papers
## What this does
This skill is a thin adapter between `paper-mentor` and NotebookLM. It handles:
1. Detecting whether NotebookLM CLI / MCP is installed
2. Creating notebooks
3. Adding sources (PDFs, URLs, abstracts)
4. Running structured queries (the 4-question summary)
5. Returning citation-grounded answers
If NotebookLM is not installed, this skill guides the user through install before doing anything else.
---
## Pre-flight check
**ALWAYS run before any NotebookLM call:**
1. Check for MCP tools: look for `mcp__notebooklm-mcp__*` tools in the available tool list
2. Check for CLI: run `which nlm` via Bash
3. Decide:
```
if has_mcp_tools:
use_mode = "mcp"
elif has_cli:
use_mode = "cli"
else:
# NotebookLM not installed
return install_guidance()
```
### Install guidance (when both missing)
Tell the user:
> 「我看起來找不到 NotebookLM 工具。Phase 2 文獻陪讀需要它。
>
> 你有兩個選擇:
> A. 跑 `bash INSTALL.sh`(或 Windows 上 `INSTALL.ps1`)一鍵裝起來
> B. 跳過 NotebookLM,我幫你手動讀 abstract(會慢一點,但可以)
>
> 要選哪個?」
If they choose A, point them to:
> 「在 paper-mentor/ 資料夾下跑 `bash tools/install_nlm.sh`,會自動裝好 nlm CLI 和 MCP server。完成後跑 `nlm login` 連 Google 帳號,然後重新進來就可以了。」
If they choose B, fall back to manual mode (skip Steps 2-4 below; do summaries by reading abstracts via WebFetch).
---
## Step 1: Create notebook
```python
# MCP mode
mcp__notebooklm-mcp__notebook_create(
title="[student topic] — literature review",
description="Auto-generated by paper-mentor for Phase 2"
)
# Returns notebook_id
# CLI mode
nlm notebook create "[student topic] — literature review"
```
Save the notebook_id for subsequent calls.
---
## Step 2: Add sources
For each paper from `chem-paper-search` results:
| Source type | Best | Fallback |
|-------------|------|----------|
| Has openAccessPdf URL | Add as `url` | — |
| Has Semantic Scholar page only | Add the page URL as `url` | abstract as `text` |
| Has DOI only | Construct DOI URL → add as `url` | abstract as `text` |
| Nothing | Add abstract as `text` source | — |
```python
# MCP mode
mcp__notebooklm-mcp__source_add(
notebook_id=notebook_id,
source_type="url",
url="https://example.com/paper.pdf",
wait=True
)
# CLI mode
nlm source add --notebook {id} --url {pdf_url}
```
**Batch processing**: add all sources before running queries (NotebookLM processing time can be 30s-2min per source).
**Size limits**:
- PDF >50MB → split or use abstract instead
- Total sources per notebook → ≤50 (NotebookLM limit)
---
## Step 3: Run the 4-question summary
For **each paper**, run a NotebookLM query restricted to that one source. Use these 4 questions (the chieh-ting-lin profile may customize wording):
```
1. 用什麼方法解什麼問題?(具體技術 + 具體挑戰)
2. 結果改進多少?(要具體數字,PCE / 效率 / 穩定性)
3. 機制解釋夠扎實嗎?(只是現象學描述還是有 cross-characterization?)
4. 跟我們的研究方向是補充 / 競爭 / 啟發?
```
```python
# MCP mode — exact parameter name varies by MCP server version.
# Try in order: source_ids, source_filter, sources. Inspect the tool schema first
# via ListMcpResourcesTool / look at notebook_query docstring before calling.
mcp__notebooklm-mcp__notebook_query(
notebook_id=notebook_id,
query="用什麼方法解什麼問題?...",
# parameter name to be confirmed at call time:
source_ids=[paper_source_id] # or source_filter=, depending on MCP version
)
# CLI mode (canonical)
nlm chat {notebook_id} "用什麼方法解什麼問題?" --sources {source_id}
```
**Important**: if you cannot confirm the per-source restriction parameter, fall back to CLI mode (which is well-documented). Per-source restriction is required — without it, queries mix all papers in the notebook and the per-paper summary is meaningless.
**Output structure** (per paper):
```markdown
### [Paper title] ([Year])
**Method**: [from Q1, with citations]
**Result (numbers)**: [from Q2]
**Mechanism rigor**: ⭐⭐⭐ (3/5) — [reasoning from Q3]
**Relation**: 補充 / 競爭 / 啟發 — [from Q4, one-line why]
```
---
## Step 4: Cross-paper synthesis (optional)
If user wants a literature map (not just per-paper summaries), run synthesis queries on the WHOLE notebook (not source-restricted):
```
1. 「這些論文最有共識的發現是什麼?」
2. 「最有爭議或矛盾的點是什麼?」
3. 「哪些方法是重複出現的標配?」
4. 「最近 2 年的趨勢跟更早的有什麼不同?」
```
This produces the **gap report** input for `paper-mentor` Phase 2 Step 5.
---
## Step 5: Cleanup (optional)
When done with the project:
```python
# MCP mode
mcp__notebooklm-mcp__notebook_delete(notebook_id=notebook_id, confirm=True)
```
Don't auto-delete — students may want to come back. Only delete on explicit request.
---
## Common issues
| Issue | Fix |
|-------|-----|
| `nlm login` failed | Check Google account permissions for NotebookLM. Try again. |
| PDF processing stuck | Wait up to 2 min, then check `nlm source list`. If stuck, re-add. |
| Query returns no citations | Source may have failed processing. Re-check source status. |
| MCP tool not responding | Restart Claude Code session; MCP server may have died. |
| Quota exceeded | Free tier of NotebookLM has limits. Upgrade or use less. |
---
## Hard rules
1. **Never run queries without sources** — they will hallucinate.
2. **Always check `wait=True` succeeded** before querying — querying mid-processing returns garbage.
3. **Always pass `source_filter`** for per-paper questions (Step 3) — without it, NotebookLM mixes papers.
4. **Quote citations exactly** as NotebookLM returns them — do not paraphrase paper titles.
5. **If install was skipped, fall back gracefully** — don't crash.
Auf GitHub ansehen