# jacob-bd/notebooklm-mcp-cli architecture

> Architecture diagram of the GitHub repository jacob-bd/notebooklm-mcp-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jacob-bd/notebooklm-mcp-cli
- Repository: https://github.com/jacob-bd/notebooklm-mcp-cli

## Overview

#### 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: [`src/notebooklm_tools/core/client.py`](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/core/client.py) (Protocol client), [`src/notebooklm_tools/cli/commands/__init__.py`](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/cli/commands/__init__.py) (CLI commands), [`src/notebooklm_tools/mcp/tools/__init__.py`](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/mcp/tools/__init__.py) (MCP tools), [`src/notebooklm_tools/services/notebooks.py`](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/services/notebooks.py) (Feature services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Public Interfaces"]
  node_package["Package &amp; entry points<br/>Python packaging<br/>[pyproject.toml]"]
  node_cli["nlm CLI<br/>CLI entry<br/>[main.py]"]
  node_cli_commands["CLI commands<br/>command handlers<br/>[__init__.py]"]
  node_cli_formatters["CLI rendering<br/>output formatter<br/>[formatters.py]"]
  node_mcp_server["MCP server<br/>MCP entry<br/>[server.py]"]
  node_mcp_tools["MCP tools<br/>MCP adapters<br/>[__init__.py]"]
end

subgraph group_application["Application Services"]
  node_services["Feature services<br/>application API<br/>[notebooks.py]"]
  node_source_service["Source operations<br/>application service<br/>[sources.py]"]
  node_studio_service["Studio operations<br/>application service<br/>[studio.py]"]
  node_downloads["Artifact downloads<br/>filesystem service<br/>[downloads.py]"]
end

subgraph group_protocol["NotebookLM Boundary"]
  node_client{{"Protocol client<br/>NotebookLM RPC client<br/>[client.py]"}}
  node_core_rpc["RPC transport base<br/>request infrastructure<br/>[base.py]"]
  node_core_domains["Core domain operations<br/>NotebookLM RPC modules<br/>[notebooks.py]"]
  node_auth_recovery["Auth &amp; session recovery<br/>credential lifecycle<br/>[auth.py]"]
end

subgraph group_runtime["Runtime &amp; Distribution"]
  node_browser_cdp["Browser/CDP utilities<br/>local browser bridge<br/>[auth_browser.py]"]
  node_filesystem[("Local filesystem<br/>runtime boundary")]
  node_notebooklm{{"Google NotebookLM<br/>external service"}}
  node_agent_hosts["AI-agent hosts<br/>external MCP clients"]
  node_desktop_extension["Claude Desktop extension<br/>deployment wrapper<br/>[run_server.py]"]
  node_mcpb_build["MCPB builder<br/>packaging script<br/>[build_mcpb.py]"]
end

node_package -->|"installs"| node_cli
node_package -->|"installs"| node_mcp_server
node_cli -->|"dispatches"| node_cli_commands
node_cli_commands -->|"invokes"| node_services
node_cli_commands -->|"invokes"| node_source_service
node_cli_commands -->|"invokes"| node_studio_service
node_cli -->|"renders results"| node_cli_formatters
node_agent_hosts -->|"MCP requests"| node_mcp_server
node_mcp_server -->|"registers"| node_mcp_tools
node_mcp_tools -->|"adapts to"| node_services
node_mcp_tools -->|"adapts to"| node_source_service
node_mcp_tools -->|"adapts to"| node_studio_service
node_services -->|"orchestrates via"| node_client
node_source_service -->|"uses"| node_client
node_studio_service -->|"uses"| node_client
node_services -->|"exports artifacts"| node_downloads
node_downloads -->|"writes"| node_filesystem
node_source_service -->|"reads uploads"| node_filesystem
node_client -->|"uses"| node_core_rpc
node_client -->|"delegates operations"| node_core_domains
node_client -.->|"guards requests"| node_auth_recovery
node_core_rpc -->|"authenticated RPC"| node_notebooklm
node_auth_recovery -.->|"refreshes session through"| node_browser_cdp
node_browser_cdp -->|"CDP-backed session"| node_notebooklm
node_mcpb_build -->|"packages"| node_desktop_extension
node_desktop_extension -->|"launches"| node_mcp_server

click node_package "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/pyproject.toml"
click node_cli "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/cli/main.py"
click node_cli_commands "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/cli/commands/__init__.py"
click node_cli_formatters "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/cli/formatters.py"
click node_mcp_server "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/mcp/server.py"
click node_mcp_tools "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/mcp/tools/__init__.py"
click node_services "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/services/notebooks.py"
click node_source_service "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/services/sources.py"
click node_studio_service "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/services/studio.py"
click node_downloads "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/services/downloads.py"
click node_client "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/core/client.py"
click node_core_rpc "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/core/base.py"
click node_core_domains "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/core/notebooks.py"
click node_auth_recovery "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/core/auth.py"
click node_browser_cdp "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/utils/auth_browser.py"
click node_desktop_extension "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/desktop-extension/run_server.py"
click node_mcpb_build "https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/scripts/build_mcpb.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_package,node_cli,node_cli_commands,node_cli_formatters,node_mcp_server,node_mcp_tools toneBlue
class node_services,node_source_service,node_studio_service,node_downloads toneAmber
class node_client,node_core_rpc,node_core_domains,node_auth_recovery toneMint
class node_browser_cdp,node_filesystem,node_notebooklm,node_agent_hosts,node_desktop_extension,node_mcpb_build toneRose
```

## Components

### Public Interfaces

- [Package & entry points](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/pyproject.toml): Python packaging · Defines nlm and notebooklm-mcp executables. · `pyproject.toml`
- [nlm CLI](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/cli/main.py): CLI entry · `src/notebooklm_tools/cli/main.py`
- [CLI commands](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/cli/commands/__init__.py): command handlers · `src/notebooklm_tools/cli/commands/__init__.py`
- [CLI rendering](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/cli/formatters.py): output formatter · `src/notebooklm_tools/cli/formatters.py`
- [MCP server](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/mcp/server.py): MCP entry · Registers capability groups for agent hosts. · `src/notebooklm_tools/mcp/server.py`
- [MCP tools](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/mcp/tools/__init__.py): MCP adapters · Translates MCP inputs and response shapes. · `src/notebooklm_tools/mcp/tools/__init__.py`

### Application Services

- [Feature services](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/services/notebooks.py): application API · Coordinates shared multi-step notebook operations. · `src/notebooklm_tools/services/notebooks.py`
- [Source operations](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/services/sources.py): application service · `src/notebooklm_tools/services/sources.py`
- [Studio operations](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/services/studio.py): application service · `src/notebooklm_tools/services/studio.py`
- [Artifact downloads](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/services/downloads.py): filesystem service · `src/notebooklm_tools/services/downloads.py`

### NotebookLM Boundary

- [Protocol client](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/core/client.py): NotebookLM RPC client · Isolates the undocumented NotebookLM API contract. · `src/notebooklm_tools/core/client.py`
- [RPC transport base](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/core/base.py): request infrastructure · `src/notebooklm_tools/core/base.py`
- [Core domain operations](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/core/notebooks.py): NotebookLM RPC modules · `src/notebooklm_tools/core/notebooks.py`
- [Auth & session recovery](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/core/auth.py): credential lifecycle · Reloads or refreshes cookies and session state before retry. · `src/notebooklm_tools/core/auth.py`

### Runtime & Distribution

- [Browser/CDP utilities](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/src/notebooklm_tools/utils/auth_browser.py): local browser bridge · Extracts and replays authenticated browser sessions. · `src/notebooklm_tools/utils/auth_browser.py`
- **Local filesystem**: runtime boundary · Receives uploaded sources and downloaded artifacts.
- **Google NotebookLM**: external service · Undocumented RPC endpoint.
- **AI-agent hosts**: external MCP clients
- [Claude Desktop extension](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/desktop-extension/run_server.py): deployment wrapper · Launches the MCP runtime for Claude Desktop. · `desktop-extension/run_server.py`
- [MCPB builder](https://github.com/jacob-bd/notebooklm-mcp-cli/blob/main/scripts/build_mcpb.py): packaging script · `scripts/build_mcpb.py`

## Connections

- 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
