NotebookLM MCP Server

repository·main·Indexed 25 days ago

https://github.com/pleaseprompto/notebooklm-mcp

A Model Context Protocol (MCP) server for Google NotebookLM (v2.0.0) that enables AI agents to chat, manage sources, generate audio overviews, and extract citations via a stealthy Chrome instance. It supports stdio and Streamable-HTTP transports and integrates with clients like Claude Code and Cursor.

Tokens
13.2K
Snippets
34
Records
81
Agent score
84%

What's inside notebooklm-mcp

  1. Manage multi-turn sessions with ask_question

    main

    To maintain conversational context in NotebookLM, reuse the session_id returned by the ask_question tool in subsequent calls.

    • To continue a conversation: Include the session_id in the arguments of ask_question.
    • To reset a conversation: Call reset_session with the current session_id.
    • To end a conversation: Call close_session with the current session_id.

    Sessions automatically expire after 900 seconds (15 minutes) of inactivity.

    // 1. Open broad — captures session_id
    { "name": "ask_question", "arguments": { "question": "Give me an overview of the n8n error handling architecture." }}
    // → response.session_id = "ses_abc123"
    
    // 2. Drill in using the session_id
    { "name": "ask_question", "arguments": { "question": "What's the recommended retry/backoff pattern for HTTP nodes?", "session_id": "ses_abc123" }}
    
    // 3. Reset the session
    { "name": "reset_session", "arguments": { "session_id": "ses_abc123" } }
    
    // 4. Close the session
    { "name": "close_session", "arguments": { "session_id": "ses_abc123" } }
  2. Connect to Claude Code

    main

    You can add the NotebookLM MCP server to Claude Code using the CLI or by manually editing your configuration file.

    Via CLI

    Use the claude mcp add command. You can use the published package or a local clone.

    Via Manual Configuration

    Add the server definition to your ~/.claude.json file.

    {
      "mcpServers": {
        "notebooklm": {
          "command": "npx",
          "args": ["notebooklm-mcp@latest"]
        }
      }
    }
  3. Use HTTP transport for n8n, Zapier, or Make

    main

    To use the server with HTTP-only clients, start the server in HTTP mode.

    Start Command: npx notebooklm-mcp@latest --transport http --port 3000 --host 0.0.0.0

    Endpoints:

    • POST /mcp: Main MCP endpoint for tool calls.
    • GET /healthz: Liveness probe.

    Workflow for HTTP clients:

    1. Initialize: Send a JSON-RPC initialize request to /mcp. Capture the Mcp-Session-Id from the response header.
    2. Call Tools: Include the Mcp-Session-Id header in all subsequent requests to /mcp to maintain the connection.
    3. Tool Output: The actual tool result is found in the standard MCP envelope under result.content[0].text as a JSON string.
    # Start server
    npx notebooklm-mcp@latest --transport http --port 3000 --host 0.0.0.0
    
    # 1. Initialize session
    curl -i -X POST http://localhost:3000/mcp \
      -H 'Content-Type: application/json' \
      -d '{
        "jsonrpc": "2.0",
        "id": 1,
        "method": "initialize",
        "params": {
          "protocolVersion": "2025-03-26",
          "capabilities": {},
          "clientInfo": { "name": "curl", "version": "0.0.1" }
        }
      }'
    
    # 2. Ask a question (using captured session ID)
    curl -X POST http://localhost:3000/mcp \
      -H 'Content-Type: application/json' \
      -H 'Mcp-Session-Id: <session-id-from-step-1>' \
      -d '{
        "jsonrpc": "2.0",
        "id": 2,
        "method": "tools/call",
        "params": {
          "name": "ask_question",
          "arguments": {
            "question": "What is the n8n Code node best for?",
            "source_format": "footnotes"
          }
        }
      }'
    
    # 3. Liveness probe
    curl http://localhost:3000/healthz
  4. Run multiple accounts in parallel

    main

    To use different Google accounts (e.g., work vs. personal) simultaneously, start multiple server instances using the --account flag or the NOTEBOOKLM_ACCOUNT environment variable. Each account maintains its own isolated Chrome profile and library.json file under <dataDir>/accounts/<name>/.

    # Terminal A: work account
    npx notebooklm-mcp@latest --account work
    
    # Terminal B: personal account
    npx notebooklm-mcp@latest --account personal
  5. Install the NotebookLM MCP Server

    main

    You can install the NotebookLM MCP server using npx (recommended) or by building from source.

    This method keeps the binary cached and ensures you are always using the latest version.

    npx notebooklm-mcp@latest

    Building from Source

    1. Clone the repository.
    2. Install dependencies.
    3. Build the project.
    4. Run the compiled entry point.
  6. Perform data cleanup with `cleanup_data`

    main

    Use cleanup_data to wipe NotebookLM MCP files from the system. This is a two-step process to prevent accidental deletion:

    1. Preview: Call cleanup_data with confirm: false. Use preserve_library: true if you want to keep your library.json.
    2. Execute: After reviewing the preview and closing Chrome instances, call cleanup_data with confirm: true.
  7. First-time setup for NotebookLM MCP

    main

    To set up the NotebookLM MCP server for the first time, follow these steps:

    1. Install and start: Run the server using npx.
    2. Authenticate: Call the setup_auth tool. This will open a Chrome window where you must log in to the Google account that owns your NotebookLM notebooks. Close the browser once finished.
    3. Verify Authentication: Call get_health and ensure the response contains "authenticated": true.
    4. Add a notebook: Use the add_notebook tool with a NotebookLM share-URL to add notebooks to your local library.
    5. Ask a question: Use ask_question to query your notebooks. Capture the session_id from the response to enable multi-turn conversations.
    # 1. Install and start
    npx notebooklm-mcp@latest
    // 2. Authenticate
    { "name": "setup_auth", "arguments": {} }
    
    // 3. Verify
    { "name": "get_health", "arguments": {} }
    
    // 4. Add a notebook
    {
      "name": "add_notebook",
      "arguments": {
        "url": "https://notebooklm.google.com/notebook/abcd-efgh",
        "name": "n8n Documentation",
        "description": "n8n core docs + builtin nodes",
        "topics": ["workflow automation", "n8n", "node configuration"],
        "use_cases": ["building n8n workflows", "debugging n8n executions"],
        "tags": ["docs", "n8n"]
      }
    }
    
    // 5. Ask a question
    {
      "name": "ask_question",
      "arguments": {
        "question": "What is the recommended retry pattern for the HTTP Request node?"
      }
    }
  8. Run NotebookLM MCP on a headless Linux server

    main

    On servers without a display, setup_auth will fail because the login window cannot open. To fix this, perform a one-time setup using xvfb-run. Once the login is complete, the persistent Chrome profile allows all subsequent runs to operate fully headless.

    1. Run: xvfb-run -a npx notebooklm-mcp@latest.
    2. Call setup_auth from your client and complete the login.
    3. Exit the process.
    4. Run normally thereafter: npx notebooklm-mcp@latest.
    xvfb-run -a npx notebooklm-mcp@latest
    # call setup_auth from your client, complete login, then exit
    
    # from then on, run normally:
    npx notebooklm-mcp@latest
  9. Generate and download Audio Overviews

    main

    You can generate and download NotebookLM Audio Overviews using a two-step workflow:

    1. Generate: Call generate_audio. You can provide a custom_prompt to guide the audio content and a timeout_ms to prevent premature timeouts. The default timeout is 600,000 ms (10 min).
    2. Download: Call download_audio specifying a destination_dir. This returns the absolute file_path and the file size.

    Note: You must call generate_audio before download_audio within the same notebook context.

    // 1. Generate
    {
      "name": "generate_audio",
      "arguments": {
        "custom_prompt": "Focus on the migration steps and breaking changes",
        "timeout_ms": 900000
      }
    }
    
    // 2. Download
    {
      "name": "download_audio",
      "arguments": {
        "destination_dir": "/Users/me/Downloads/notebooklm"
      }
    }
  10. Configure NotebookLM MCP Server settings

    main

    The server does not use a configuration file. Settings are applied via environment variables, CLI flags, or per-call tool parameters. The resolution order is:

    1. Per-call tool parameters (e.g., browser_options, show_browser)
    2. Environment variables
    3. Built-in defaults

    Persistent state (active profile and disabled tools) is stored in <configDir>/settings.json, which can be managed using the npx notebooklm-mcp config ... command.

  11. Authenticate with Google NotebookLM

    main

    The server uses a persistent Chrome profile to store authentication cookies. You must perform a one-time login using the setup_auth tool.

    Authentication Tools

    • setup_auth: Opens a visible Chrome window for the first-time login. You have up to 10 minutes to complete the process.
    • re_auth: Wipes stored auth and starts the login process over. Use this when switching accounts or if auth breaks.
    • cleanup_data: Wipes all stored data. Use preserve_library=true to keep your library.json metadata.

    Profile Locations

    • Linux: ~/.local/share/notebooklm-mcp/chrome_profile/
    • macOS: ~/Library/Application Support/notebooklm-mcp/chrome_profile/
    • Windows: %APPDATA%\notebooklm-mcp\chrome_profile\

    Note for Headless Linux Servers: Run the initial setup using xvfb-run to provide a display for the login window: xvfb-run -a npx notebooklm-mcp.