# pleaseprompto/notebooklm-mcp architecture

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

- Interactive diagram: https://gitdiagram.com/pleaseprompto/notebooklm-mcp
- Repository: https://github.com/pleaseprompto/notebooklm-mcp

## Overview

#### Purpose and entry points
NotebookLM MCP Server exposes Google NotebookLM capabilities to MCP clients. It automates a real Chrome through Patchright, rather than using a NotebookLM API. The process starts in `src/index.ts`, which parses CLI/configuration, creates MCP server capabilities, registers filtered tools/resources, and chooses stdio or HTTP transport. Core configuration is centralized in `src/config.ts`.

#### MCP surface and transport boundary
Tool schemas are defined separately from execution, allowing profile-based and disabled-tool filtering before exposure to clients. `src/tools/index.ts` composes the tool catalog; `src/tools/definitions.ts` and `src/tools/definitions/` define MCP-facing contracts; `src/tools/handlers.ts` dispatches implementations. Stdio is the default process transport; `src/transport/http.ts` hosts Streamable HTTP `/mcp` sessions and health probing.

#### Browser automation runtime
NotebookLM interaction crosses a DOM-automation boundary. `src/browser/chromium-fallback.ts` launches preferred system Chrome or bundled Chromium fallback, while `src/browser/watchdog.ts` monitors browser health. Page-specific workflows are split by NotebookLM capability: `src/notebooklm/chat.ts`, `src/notebooklm/sources.ts`, and `src/notebooklm/audio.ts`; selectors and citation DOM extraction live in `src/notebooklm/selectors.ts` and `src/notebooklm/citations.ts`. External dependencies are Google NotebookLM, Chrome/Patchright, and the MCP SDK.

#### Session and conversation lifecycle
A session owns browser/page state and supports reused NotebookLM chat context. `src/session/browser-session.ts` represents browser-backed work; `src/session/session-manager.ts` creates, limits, resets, closes, and garbage-collects sessions; `src/session/shared-context-manager.ts` coordinates shared browser context. Tool calls flow from handlers into this layer, then into NotebookLM DOM operations, enforcing configured timeouts and session limits.

#### Authentication and account isolation
Authentication uses persistent Chrome-profile cookies, with an interactive visible-browser bootstrap. `src/auth/auth-manager.ts` manages setup, re-authentication, and auth state; `src/auth/account-switcher.ts` derives per-account data/profile locations. This is profile-directory isolation, not an encrypted credential service. Browser launch and auth boundaries must preserve account-specific persistent state.

#### Local notebook library and MCP resources
The server maintains a local metadata library of NotebookLM share URLs; it does not own or delete remote notebooks. `src/library/notebook-library.ts` performs persistence and query/update operations, with domain shapes in `src/library/types.ts` and metadata handling in `src/library/metadata.ts`. Read-only MCP resources expose this local library and compatibility metadata; notebook selection supplies defaults for question tools.

#### Response safety, persistence, and shutdown
Question results are postprocessed with citation formats and provenance/AI-generated labeling before returning through MCP. Cleanup and process-lifetime concerns are centralized in `src/utils/cleanup-manager.ts`; persistent tool-profile settings are managed by `src/utils/settings-manager.ts`. `src/resources/resource-handlers.ts` serves read-only resource requests, while `src/errors.ts` provides shared failure semantics across transport, browser, and tool boundaries.

Main entry points: [`src/index.ts`](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/index.ts) (Server entrypoint), [`src/browser/chromium-fallback.ts`](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/browser/chromium-fallback.ts) (Chromium launcher), [`src/tools/index.ts`](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/tools/index.ts) (Tool catalog), [`src/tools/handlers.ts`](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/tools/handlers.ts) (Tool handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mcp["MCP Interface"]
  node_entry["Server entrypoint<br/>CLI bootstrap<br/>[index.ts]"]
  node_config["Configuration<br/>[config.ts]"]
  node_tool_catalog["Tool catalog<br/>MCP tools<br/>[index.ts]"]
  node_tool_contracts["Tool contracts<br/>MCP schemas<br/>[definitions.ts]"]
  node_tool_handlers["Tool handlers<br/>dispatcher<br/>[handlers.ts]"]
  node_http["HTTP transport<br/>Streamable HTTP<br/>[http.ts]"]
  node_resources["Resource handlers<br/>MCP resources"]
end

subgraph group_runtime["Browser Runtime"]
  node_auth["Authentication manager<br/>profile auth<br/>[auth-manager.ts]"]
  node_account_switcher["Account switcher<br/>profile isolation"]
  node_browser_launch["Chromium launcher<br/>Patchright launcher"]
  node_watchdog["Browser watchdog<br/>health monitor<br/>[watchdog.ts]"]
end

subgraph group_notebooklm["NotebookLM Automation"]
  node_notebook_ops["NotebookLM workflows<br/>DOM automation<br/>[chat.ts]"]
  node_citations["Citation extraction<br/>DOM parsing<br/>[citations.ts]"]
end

subgraph group_state["Sessions &amp; Local State"]
  node_session_manager["Session manager<br/>lifecycle manager<br/>[session-manager.ts]"]
  node_browser_session["Browser session<br/>browser state<br/>[browser-session.ts]"]
  node_shared_context["Shared context manager<br/>browser context"]
  node_library[("Notebook library<br/>local metadata store")]
  node_cleanup["Cleanup manager<br/>shutdown lifecycle<br/>[cleanup-manager.ts]"]
end

node_notebooklm_external{{"Google NotebookLM<br/>external service"}}
node_mcp_clients(("MCP clients<br/>external clients"))

node_mcp_clients -->|"stdio"| node_entry
node_mcp_clients -->|"HTTP /mcp"| node_http
node_entry -->|"loads"| node_config
node_entry -->|"registers"| node_tool_catalog
node_entry -->|"selects"| node_http
node_tool_catalog -->|"uses schemas"| node_tool_contracts
node_tool_catalog -->|"binds"| node_tool_handlers
node_tool_handlers -->|"tool calls"| node_session_manager
node_tool_handlers -->|"notebook defaults"| node_library
node_resources -->|"read-only queries"| node_library
node_session_manager -->|"manages"| node_browser_session
node_browser_session -->|"uses"| node_shared_context
node_shared_context -->|"launches"| node_browser_launch
node_browser_launch -->|"profile location"| node_account_switcher
node_auth -->|"isolates accounts"| node_account_switcher
node_auth -->|"visible auth bootstrap"| node_browser_launch
node_watchdog -.->|"monitors"| node_browser_launch
node_browser_session -->|"executes workflows"| node_notebook_ops
node_notebook_ops -->|"extracts provenance"| node_citations
node_notebook_ops -->|"automates UI"| node_notebooklm_external
node_cleanup -->|"closes sessions"| node_session_manager

click node_entry "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/index.ts"
click node_config "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/config.ts"
click node_tool_catalog "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/tools/index.ts"
click node_tool_contracts "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/tools/definitions.ts"
click node_tool_handlers "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/tools/handlers.ts"
click node_http "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/transport/http.ts"
click node_resources "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/resources/resource-handlers.ts"
click node_session_manager "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/session/session-manager.ts"
click node_browser_session "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/session/browser-session.ts"
click node_shared_context "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/session/shared-context-manager.ts"
click node_auth "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/auth/auth-manager.ts"
click node_account_switcher "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/auth/account-switcher.ts"
click node_browser_launch "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/browser/chromium-fallback.ts"
click node_watchdog "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/browser/watchdog.ts"
click node_notebook_ops "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/notebooklm/chat.ts"
click node_citations "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/notebooklm/citations.ts"
click node_library "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/library/notebook-library.ts"
click node_cleanup "https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/utils/cleanup-manager.ts"

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_entry,node_config,node_tool_catalog,node_tool_contracts,node_tool_handlers,node_http,node_resources toneBlue
class node_auth,node_account_switcher,node_browser_launch,node_watchdog toneAmber
class node_notebook_ops,node_citations toneMint
class node_session_manager,node_browser_session,node_shared_context,node_library,node_cleanup toneRose
class node_notebooklm_external,node_mcp_clients toneNeutral
```

## Components

### MCP Interface

- [Server entrypoint](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/index.ts): CLI bootstrap · Builds capabilities and selects the process transport. · `src/index.ts`
- [Configuration](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/config.ts): config · Centralized limits, profiles, and transport settings. · `src/config.ts`
- [Tool catalog](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/tools/index.ts): MCP tools · Composes tools after profile and disabled-tool filtering. · `src/tools/index.ts`
- [Tool contracts](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/tools/definitions.ts): MCP schemas · Separates MCP-facing definitions from execution. · `src/tools/definitions.ts`
- [Tool handlers](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/tools/handlers.ts): dispatcher · Dispatches tool calls into session-backed workflows. · `src/tools/handlers.ts`
- [HTTP transport](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/transport/http.ts): Streamable HTTP · Hosts /mcp sessions and health probes. · `src/transport/http.ts`
- [Resource handlers](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/resources/resource-handlers.ts): MCP resources · Serves read-only library and compatibility resources. · `src/resources/resource-handlers.ts`

### Browser Runtime

- [Authentication manager](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/auth/auth-manager.ts): profile auth · Bootstraps and maintains persistent-cookie authentication. · `src/auth/auth-manager.ts`
- [Account switcher](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/auth/account-switcher.ts): profile isolation · Derives account-specific data and profile locations. · `src/auth/account-switcher.ts`
- [Chromium launcher](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/browser/chromium-fallback.ts): Patchright launcher · Uses system Chrome or bundled Chromium fallback. · `src/browser/chromium-fallback.ts`
- [Browser watchdog](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/browser/watchdog.ts): health monitor · `src/browser/watchdog.ts`

### NotebookLM Automation

- [NotebookLM workflows](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/notebooklm/chat.ts): DOM automation · Chat, source, and audio workflows against the live NotebookLM UI. · `src/notebooklm/chat.ts`
- [Citation extraction](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/notebooklm/citations.ts): DOM parsing · Extracts citations and selectors from NotebookLM pages. · `src/notebooklm/citations.ts`

### Sessions & Local State

- [Session manager](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/session/session-manager.ts): lifecycle manager · Creates, limits, resets, closes, and garbage-collects sessions. · `src/session/session-manager.ts`
- [Browser session](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/session/browser-session.ts): browser state · Owns page state and reusable chat context. · `src/session/browser-session.ts`
- [Shared context manager](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/session/shared-context-manager.ts): browser context · Coordinates shared browser context. · `src/session/shared-context-manager.ts`
- [Notebook library](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/library/notebook-library.ts): local metadata store · Persists share-URL metadata; never owns remote notebooks. · `src/library/notebook-library.ts`
- [Cleanup manager](https://github.com/pleaseprompto/notebooklm-mcp/blob/main/src/utils/cleanup-manager.ts): shutdown lifecycle · Centralizes process-lifetime cleanup. · `src/utils/cleanup-manager.ts`

### Other components

- **Google NotebookLM**: external service · Automated through Chrome DOM rather than an API.
- **MCP clients**: external clients

## Connections

- MCP clients → Server entrypoint: stdio
- MCP clients → HTTP transport: HTTP /mcp
- Server entrypoint → Configuration: loads
- Server entrypoint → Tool catalog: registers
- Server entrypoint → HTTP transport: selects
- Tool catalog → Tool contracts: uses schemas
- Tool catalog → Tool handlers: binds
- Tool handlers → Session manager: tool calls
- Tool handlers → Notebook library: notebook defaults
- Resource handlers → Notebook library: read-only queries
- Session manager → Browser session: manages
- Browser session → Shared context manager: uses
- Shared context manager → Chromium launcher: launches
- Chromium launcher → Account switcher: profile location
- Authentication manager → Account switcher: isolates accounts
- Authentication manager → Chromium launcher: visible auth bootstrap
- Browser watchdog → Chromium launcher: monitors
- Browser session → NotebookLM workflows: executes workflows
- NotebookLM workflows → Citation extraction: extracts provenance
- NotebookLM workflows → Google NotebookLM: automates UI
- Cleanup manager → Session manager: closes sessions
