Manage Gemini Notebook sources and check ingestion from the terminal.
Use Google OAuth to work with notebooks and sources. Capture inventories and compare source readiness across runs.
Learn more at Gemini Notebook.
Created by @bobeglz (bobe).
Authentication
Use a personal Google Account that has opened Gemini Notebook at least once. Enable notebook.googleapis.com on a Google Cloud project you can use for quota.
export GEMINI_NOTEBOOK_QUOTA_PROJECT="your-google-cloud-project"
gcloud auth application-default login --scopes="https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/notebook.readonly"
gemini-notebook-pp-cli doctor --json
Use the https://www.googleapis.com/auth/notebook scope when you need to create, rename, or upload. The CLI finds ADC from the standard location or the file named in GOOGLE_APPLICATION_CREDENTIALS. For ADC requests, the CLI uses the file's quota project when GEMINI_NOTEBOOK_QUOTA_PROJECT is absent. A short-lived token in GEMINI_NOTEBOOK_TOKEN takes precedence over ADC. Set the quota project explicitly when supplying a token minted by gcloud.
See Google's authentication guide for preview eligibility and OAuth setup.
Quick Start
# List notebooks accessible to the authenticated account.
gemini-notebook-pp-cli notebooks list --agent
Unique Features
Source preparation
-
sources readiness — Check the processing states of every source in a notebook.
Check the processing states of every source in a notebook.
-
sources reconcile — Check which expected URLs are missing or duplicated.
Check which expected URLs are missing or duplicated.
-
sources inspect-file — Validate the MIME type and byte size of a local file before uploading.
Validate the MIME type and byte size of a local file before uploading.
gemini-notebook-pp-cli sources inspect-file --file=testdata/notebook-reference.txt --json
Inventory
-
notebooks inventory — Export metadata for selected notebooks and their sources.
Export metadata for selected notebooks and their sources.
-
notebooks inventory-diff — Check what changed between two saved inventories.
Check what changed between two saved inventories.
gemini-notebook-pp-cli notebooks inventory-diff --before=testdata/inventory-before.json --after=testdata/inventory-after.json --json
Cookbook
Prepare and check sources
Save a notebook ID from notebooks list in the shell variable NOTEBOOK_ID. Use the part following notebooks/.
gemini-notebook-pp-cli sources create "$NOTEBOOK_ID" --web-content-url https://ai.google.dev/gemini-api/docs --dry-run --json
gemini-notebook-pp-cli sources readiness "$NOTEBOOK_ID" --json
gemini-notebook-pp-cli sources reconcile "$NOTEBOOK_ID" --url https://ai.google.dev/gemini-api/docs --json
gemini-notebook-pp-cli sources inspect-file --file ./report.pdf --json
gemini-notebook-pp-cli sources upload "$NOTEBOOK_ID" --file ./report.pdf --display-name "Research report" --dry-run --json
Omit --dry-run to create the source. Pass --resumable for the two-request upload protocol. Use sources wait with the notebook and source IDs to poll until the source is active or fails. See Google's source guide for file types.
Compare inventories
Capture each inventory with the same account and selection, using --json without field filters.
gemini-notebook-pp-cli notebooks inventory --ownership owned --json > notebooks.json
gemini-notebook-pp-cli notebooks inventory-diff --before notebooks-previous.json --after notebooks.json --json
Use the local MCP server
Point your client at the absolute path to gemini-notebook-pp-mcp for stdio. Pass the quota project and ADC location in the server environment as needed. The code tools preview writes and require boolean confirm: true to send them. File-reading flags are restricted by the command mirror. Use the CLI for local file workflows, including the two-step upload.
Recipes
List owned notebooks
gemini-notebook-pp-cli notebooks list --filter 'notebook.is_owner = true' --agent
Ask Google to return notebooks you own.
Usage
Run gemini-notebook-pp-cli --help for the full command reference and flag list.
Paths & environment variables
This CLI separates local files into four path kinds:
| Kind | Contents |
|---|
config | User-editable settings such as config.toml and saved profiles |
data | Durable local data: credentials.toml, data.db, cookies, browser-session proof files, and other auth sidecars |
state | Runtime state such as persisted queries, jobs, and teach.log |
cache | Regenerable HTTP/cache files |
Each kind resolves independently. The ladder is:
- Per-kind env var:
GEMINI_NOTEBOOK_CONFIG_DIR, GEMINI_NOTEBOOK_DATA_DIR, GEMINI_NOTEBOOK_STATE_DIR, or GEMINI_NOTEBOOK_CACHE_DIR
--home <dir> for this invocation
GEMINI_NOTEBOOK_HOME for a flat relocated root
- XDG env vars:
XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_STATE_HOME, XDG_CACHE_HOME
- Platform defaults matching existing installs
For containers and agent sandboxes, prefer a single relocated root:
export GEMINI_NOTEBOOK_HOME=/srv/gemini-notebook
gemini-notebook-pp-cli doctor
Under GEMINI_NOTEBOOK_HOME=/srv/gemini-notebook, the four dirs resolve to /srv/gemini-notebook/config, /srv/gemini-notebook/data, /srv/gemini-notebook/state, and /srv/gemini-notebook/cache.
On Windows, set the same variable in PowerShell:
$env:GEMINI_NOTEBOOK_HOME = "C:\srv\gemini-notebook"
gemini-notebook-pp-cli doctor
Under $env:GEMINI_NOTEBOOK_HOME = "C:\srv\gemini-notebook", the four dirs resolve to C:\srv\gemini-notebook\config, C:\srv\gemini-notebook\data, C:\srv\gemini-notebook\state, and C:\srv\gemini-notebook\cache.
MCP servers do not receive CLI flags from the host. Put relocation in the host env block:
{
"mcpServers": {
"gemini-notebook": {
"command": "gemini-notebook-pp-mcp",
"env": {
"GEMINI_NOTEBOOK_HOME": "/srv/gemini-notebook"
}
}
}
}
Precedence matters in fleets: an ambient per-kind variable such as GEMINI_NOTEBOOK_DATA_DIR overrides an explicit --home for that kind. Use GEMINI_NOTEBOOK_HOME or the per-kind variables for durable fleet relocation; treat --home as the weaker per-invocation lever.
Relocation is one-way. Unsetting GEMINI_NOTEBOOK_HOME does not move files back to platform defaults, and doctor cannot find credentials left under a former root. Move the files manually before unsetting relocation variables.
Existing installs keep working because the platform-default rung matches the legacy layout. On the first auth write, stored secrets leave config.toml and are consolidated into credentials.toml under the data directory. Run gemini-notebook-pp-cli doctor --fail-on warn to check path and credential-location warnings in automation.
Local data
Framework commands can save API data in the SQLite store (data.db, or data-<hash>.db per credential) in the data directory. The response cache is disabled for ADC and for the inventory and readiness workflows. An ADC file replacement selects a separate local database. Credentials live in credentials.toml in the data directory. The learn journal lives under learn/ in the state directory. gemini-notebook-pp-cli doctor prints the resolved paths, every store file, and the response-cache size.
None of it is encrypted. New files are created owner-only; beyond that the data relies on OS account permissions and full-disk encryption (FileVault, BitLocker, LUKS).
- Erase it:
gemini-notebook-pp-cli local-data purge lists the store files, response cache, and learn journal it would delete; add --yes to delete them, or --only store|cache|journal to narrow it. Config and credentials are kept.
- Run without a local copy: set
GEMINI_NOTEBOOK_NO_LOCAL_DATA=1. Reads go to the API (--data-source live; --data-source local still reads an existing store), the response cache is off (--no-cache), nothing new is written to the store, and sync and workflow archive refuse to run. Set it in an MCP host's env block and every command the server runs inherits it.
- Choose the read source without flags:
GEMINI_NOTEBOOK_DATA_SOURCE=auto|live|local sets the --data-source default; an explicit flag wins.
Commands
notebooks
Manage notebooks.
gemini-notebook-pp-cli notebooks create - Creates a new notebook.
gemini-notebook-pp-cli notebooks get - Gets a specific notebook.
gemini-notebook-pp-cli notebooks list - Lists notebooks accessible to the authenticated user. This includes notebooks owned by the user as well as notebooks shared with them.
gemini-notebook-pp-cli notebooks patch - Updates an existing notebook.
gemini-notebook-pp-cli notebooks inventory - Export metadata for selected notebooks and their sources.
gemini-notebook-pp-cli notebooks inventory-diff - Check what changed between two saved inventories.
sources
Ingest and inspect notebook sources.
gemini-notebook-pp-cli sources create - Creates a new source.
gemini-notebook-pp-cli sources get - Gets a specific source.
gemini-notebook-pp-cli sources list - Lists sources in a notebook.
gemini-notebook-pp-cli sources upload - Upload a local file to a notebook.
gemini-notebook-pp-cli sources wait - Poll for source processing with a deadline.
gemini-notebook-pp-cli sources readiness - Check the processing states of every source in a notebook.
gemini-notebook-pp-cli sources reconcile - Check which expected URLs are missing or duplicated.
gemini-notebook-pp-cli sources inspect-file - Validate the MIME type and byte size of a local file before uploading.
Self-learning loop
This CLI caches per-question discovery so repeat queries skip the walk and structurally similar queries get answered via entity substitution. The loop also self-captures: every invocation is journaled locally, and failed-flag corrections plus fresh teaches surface as candidates on the next recall for confirm/reject judgment. Agents call recall before discovery and fire teach & after answering. See the ## Automatic learning section in SKILL.md for the full protocol.
gemini-notebook-pp-cli recall <query> - Look up cached resources for a query before running discovery
gemini-notebook-pp-cli teach - Record a query -> resource mapping (silent on success, safe to background with &)
gemini-notebook-pp-cli learnings list - Inspect taught rows
gemini-notebook-pp-cli learnings forget <query> - Undo a teach
gemini-notebook-pp-cli learnings candidates - List auto-captured candidates awaiting confirm/reject
gemini-notebook-pp-cli learnings stats - Local loop metrics: recall hit rate, teach-to-reuse, playbook resolution, candidate counts
gemini-notebook-pp-cli teach-pattern - Install a query/resource template up front
gemini-notebook-pp-cli teach-lookup - Add an entity mapping (e.g. country code, team alias) for pattern substitution
Pass --no-learn or set GEMINI_NOTEBOOK_NO_LEARN=true to disable the loop for deterministic flows.
The local store's schema version stamp is one-way: once this version of gemini-notebook-pp-cli opens the database, older binaries refuse it with a version error — upgrade the binary rather than downgrading.
Output Formats
# Human-readable table (default in terminal, JSON when piped)
gemini-notebook-pp-cli notebooks list
# JSON for scripting and agents
gemini-notebook-pp-cli notebooks list --json
# Filter to specific fields
gemini-notebook-pp-cli notebooks list --json --select createTime,displayName,name
# Dry run — show the request without sending
gemini-notebook-pp-cli notebooks list --dry-run
# Agent mode — JSON + compact + no prompts in one flag
gemini-notebook-pp-cli notebooks list --agent
--csv prefixes a leading ' on cells and header keys that start with =, +, -, @, a tab, or a line break (including fullwidth =+-@) so a spreadsheet does not run them as formulas. Plain signed numbers such as -5 and +2.5e3 are left unchanged.
Agent Usage
This CLI is designed for AI agent consumption:
- Non-interactive - never prompts, every input is a flag
- Pipeable -
--json output to stdout, errors to stderr
- Filterable -
--select <field>[,<field>...] returns only fields you need
- Previewable -
--dry-run shows the request without sending
- Explicit confirmation -
--agent does not imply --yes; pass --yes separately only after the target, arguments, and side effects are clear
- Piped input - write commands can accept structured input when their help lists
--stdin
- Offline-friendly - sync/search commands can use the local SQLite store when available
- Agent-safe by default - no colors or formatting unless
--human-friendly is set
Exit codes: 0 success, 2 usage error, 3 not found, 4 auth error, 5 API error, 6 partial failure, 7 rate limited, 10 config error.
Health Check
gemini-notebook-pp-cli doctor
Verifies configuration, credentials, and connectivity to the API.
Configuration
Run gemini-notebook-pp-cli doctor to see the resolved config, data, state, and cache directories. The platform-default config path is ~/.config/gemini-notebook-pp-cli/config.toml on macOS/Linux and %USERPROFILE%\.config\gemini-notebook-pp-cli\config.toml on Windows; --home, GEMINI_NOTEBOOK_HOME, and per-kind env vars can relocate it.
Static request headers can be configured under headers; per-command header overrides take precedence.
--ca-cert, GEMINI_NOTEBOOK_CA_CERT, or ca_cert adds a PEM CA bundle to the system trust roots. --tls-server-name, GEMINI_NOTEBOOK_TLS_SERVER_NAME, or tls_server_name is the name checked against the certificate when the dialed address does not match it. Precedence is flag, then environment, then the config file. A config file other users can change does not supply these settings. Certificate verification failures are not retried.
Environment variables:
| Name | Kind | Required | Description |
|---|
GEMINI_NOTEBOOK_TOKEN | per_call | Optional | Short-lived Google OAuth access token. |
GEMINI_NOTEBOOK_QUOTA_PROJECT | per_call | Required for ADC if its file omits the project | Google Cloud project charged for request quota. |
GOOGLE_APPLICATION_CREDENTIALS | per_call | Optional | Path to a Google ADC file. |
agentcookie (optional)
If you use agentcookie to sync secrets across machines, this CLI auto-adopts agentcookie-managed credentials with no extra setup. When the daemon writes to this CLI's config, gemini-notebook-pp-cli doctor reports agentcookie: detected and auth-status labels the source as agentcookie. Skip this section if you don't use agentcookie - the CLI works the same as any other.
Troubleshooting
Authentication errors (exit code 4)
- Run
gemini-notebook-pp-cli doctor to check credentials
- Check the ADC session or short-lived token and verify that the OAuth scope covers the command.
Not found errors (exit code 3)
- Check the resource ID is correct
- Run the
list command to see available items
API-specific
- ADC refresh failed — Repeat the ADC login with the Notebook OAuth scope and verify the quota project.
- 403 PERMISSION_DENIED — Verify personal-account eligibility, the Notebook scope, API enablement, and permission to use the quota project.
Sources & Inspiration
This CLI was built by studying these projects and resources:
Generated by CLI Printing Press