How pleaseprompto/notebooklm-mcp works
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 Server entrypoint · chromium-fallback.ts Chromium launcher · tools/index.ts Tool catalog · handlers.ts Tool handlers
Components 20
MCP Interface
- Server entrypoint · Builds capabilities and selects the process transport.
src/index.ts - Configuration · Centralized limits, profiles, and transport settings.
src/config.ts - Tool catalog · Composes tools after profile and disabled-tool filtering.
src/tools/index.ts - Tool contracts · Separates MCP-facing definitions from execution.
src/tools/definitions.ts - Tool handlers · Dispatches tool calls into session-backed workflows.
src/tools/handlers.ts - HTTP transport · Hosts /mcp sessions and health probes.
src/transport/http.ts - Resource handlers · Serves read-only library and compatibility resources.
src/resources/resource-handlers.ts
Browser Runtime
- Authentication manager · Bootstraps and maintains persistent-cookie authentication.
src/auth/auth-manager.ts - Account switcher · Derives account-specific data and profile locations.
src/auth/account-switcher.ts - Chromium launcher · Uses system Chrome or bundled Chromium fallback.
src/browser/chromium-fallback.ts - Browser watchdog
src/browser/watchdog.ts
NotebookLM Automation
- NotebookLM workflows · Chat, source, and audio workflows against the live NotebookLM UI.
src/notebooklm/chat.ts - Citation extraction · Extracts citations and selectors from NotebookLM pages.
src/notebooklm/citations.ts
Sessions & Local State
- Session manager · Creates, limits, resets, closes, and garbage-collects sessions.
src/session/session-manager.ts - Browser session · Owns page state and reusable chat context.
src/session/browser-session.ts - Shared context manager · Coordinates shared browser context.
src/session/shared-context-manager.ts - Notebook library · Persists share-URL metadata; never owns remote notebooks.
src/library/notebook-library.ts - Cleanup manager · Centralizes process-lifetime cleanup.
src/utils/cleanup-manager.ts
Other components
- Google NotebookLM · Automated through Chrome DOM rather than an API.
- MCP clients
Connections 21
- 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