How jacob-bd/notebooklm-mcp-cli works
Purpose and Entry Points
This Python package provides programmatic access to Google NotebookLM’s undocumented internal APIs through two installed interfaces: the nlm CLI and notebooklm-mcp MCP server. Packaging and executable definitions are centralized in pyproject.toml; primary entry modules are src/notebooklm_tools/cli/main.py and src/notebooklm_tools/mcp/server.py.
Interface Layer: CLI and MCP
The CLI maps subcommands for notebook, sources, chat, studio, sharing, research, batch, and workflow operations to shared functionality. Command implementations are grouped under src/notebooklm_tools/cli/commands/, with output/rendering separated in src/notebooklm_tools/cli/formatters.py.
The MCP server exposes the same capability set to agent hosts through tool modules. Tool registration/grouping belongs in src/notebooklm_tools/mcp/server.py and src/notebooklm_tools/mcp/tool_groups.py; individual MCP-facing adapters live in src/notebooklm_tools/mcp/tools/. This is a boundary layer: it should translate CLI/MCP-specific inputs and response shapes rather than own NotebookLM protocol logic.
Service Orchestration Layer
Feature-oriented services provide the shared application API used by MCP tools and likely higher-level CLI commands. Core domains include notebooks, chat, source ingestion/sync, studio generation, artifact download/export, research, collaboration, batches, cross-notebook operations, pipelines, and smart selection:
src/notebooklm_tools/services/notebooks.py,
src/notebooklm_tools/services/sources.py,
src/notebooklm_tools/services/studio.py.
This layer coordinates multi-step operations—such as polling generated content, research import, or batch/pipeline execution—and presents stable domain operations above the lower-level client.
NotebookLM Protocol Client
The internal API boundary is implemented in src/notebooklm_tools/core/client.py, backed by reusable RPC/request behavior in src/notebooklm_tools/core/base.py and transport support in src/notebooklm_tools/core/cdp_transport.py. Domain core modules encode NotebookLM-specific request/response operations, including src/notebooklm_tools/core/notebooks.py, src/notebooklm_tools/core/sources.py, and src/notebooklm_tools/core/studio.py.
Data models, constants, typed payloads, retries, and error normalization are concentrated in src/notebooklm_tools/core/models.py, src/notebooklm_tools/core/data_types.py, and src/notebooklm_tools/core/errors.py. This layer isolates the unstable, undocumented Google API contract from public CLI/MCP interfaces.
Authentication and Browser/CDP Boundary
Authentication is cookie-based and supports saved named profiles, manual cookie import, browser extraction, token refresh, and browser-backed replay. Lifecycle and credential behavior span src/notebooklm_tools/core/auth.py, src/notebooklm_tools/core/cookie_rotation.py, and src/notebooklm_tools/services/auth_replay.py.
Browser interaction is explicitly separated into utilities: src/notebooklm_tools/utils/auth_browser.py, src/notebooklm_tools/utils/browser.py, and src/notebooklm_tools/utils/cdp.py. It interfaces with local Chrome DevTools Protocol providers, including external CDP endpoints, to obtain or replay authenticated Google sessions. Google NotebookLM is the essential external service; local browsers and configured AI-agent hosts are material runtime dependencies.
Operational Flows and Boundaries
Typical flow is: CLI command or MCP tool → feature service → core domain/client → authenticated HTTP or CDP-backed NotebookLM RPC → normalized models/results → CLI formatter or MCP response. Auth guards/recovery can intercept requests to reload cookies, renew CSRF/session state, or invoke headless browser refresh before retrying.
Source upload/download and generated Studio artifacts cross a filesystem boundary through src/notebooklm_tools/core/download.py and src/notebooklm_tools/services/downloads.py. Local configuration, profiles, browser selection, environment sanitization, and WSL behavior are contained under src/notebooklm_tools/utils/config.py, src/notebooklm_tools/utils/env_sanitize.py, and src/notebooklm_tools/utils/wsl.py.
Distribution and Desktop Integration
The repository publishes a unified PyPI package, with CI release/publish gates under .github/workflows/. It also supports Claude Desktop packaging via scripts/build_mcpb.py and desktop-extension/manifest.json. The extension’s local server launcher is desktop-extension/run_server.py; it is a deployment wrapper around the MCP runtime rather than a separate application backend.
Main entry points: client.py Protocol client · commands/__init__.py CLI commands · tools/__init__.py MCP tools · notebooks.py Feature services
Components 20
Public Interfaces
- Package & entry points · Defines nlm and notebooklm-mcp executables.
pyproject.toml - nlm CLI
src/notebooklm_tools/cli/main.py - CLI commands
src/notebooklm_tools/cli/commands/__init__.py - CLI rendering
src/notebooklm_tools/cli/formatters.py - MCP server · Registers capability groups for agent hosts.
src/notebooklm_tools/mcp/server.py - MCP tools · Translates MCP inputs and response shapes.
src/notebooklm_tools/mcp/tools/__init__.py
Application Services
- Feature services · Coordinates shared multi-step notebook operations.
src/notebooklm_tools/services/notebooks.py - Source operations
src/notebooklm_tools/services/sources.py - Studio operations
src/notebooklm_tools/services/studio.py - Artifact downloads
src/notebooklm_tools/services/downloads.py
NotebookLM Boundary
- Protocol client · Isolates the undocumented NotebookLM API contract.
src/notebooklm_tools/core/client.py - RPC transport base
src/notebooklm_tools/core/base.py - Core domain operations
src/notebooklm_tools/core/notebooks.py - Auth & session recovery · Reloads or refreshes cookies and session state before retry.
src/notebooklm_tools/core/auth.py
Runtime & Distribution
- Browser/CDP utilities · Extracts and replays authenticated browser sessions.
src/notebooklm_tools/utils/auth_browser.py - Local filesystem · Receives uploaded sources and downloaded artifacts.
- Google NotebookLM · Undocumented RPC endpoint.
- AI-agent hosts
- Claude Desktop extension · Launches the MCP runtime for Claude Desktop.
desktop-extension/run_server.py - MCPB builder
scripts/build_mcpb.py
Connections 26
- Package & entry points → nlm CLI: installs
- Package & entry points → MCP server: installs
- nlm CLI → CLI commands: dispatches
- CLI commands → Feature services: invokes
- CLI commands → Source operations: invokes
- CLI commands → Studio operations: invokes
- nlm CLI → CLI rendering: renders results
- AI-agent hosts → MCP server: MCP requests
- MCP server → MCP tools: registers
- MCP tools → Feature services: adapts to
- MCP tools → Source operations: adapts to
- MCP tools → Studio operations: adapts to
- Feature services → Protocol client: orchestrates via
- Source operations → Protocol client: uses
- Studio operations → Protocol client: uses
- Feature services → Artifact downloads: exports artifacts
- Artifact downloads → Local filesystem: writes
- Source operations → Local filesystem: reads uploads
- Protocol client → RPC transport base: uses
- Protocol client → Core domain operations: delegates operations
- Protocol client → Auth & session recovery: guards requests
- RPC transport base → Google NotebookLM: authenticated RPC
- Auth & session recovery → Browser/CDP utilities: refreshes session through
- Browser/CDP utilities → Google NotebookLM: CDP-backed session
- MCPB builder → Claude Desktop extension: packages
- Claude Desktop extension → MCP server: launches