Skip to main content
Glama

setup_auth

Authenticate with Google to enable AI agents to query NotebookLM for document-based answers with source citations.

Instructions

Google authentication for NotebookLM access - opens a browser window for manual login to your Google account. Returns immediately after opening the browser. You have up to 10 minutes to complete the login. Use 'get_health' tool afterwards to verify authentication was saved successfully. Use this for first-time authentication or when auto-login credentials are not available. For switching accounts or rate-limit workarounds, use 're_auth' tool instead.

TROUBLESHOOTING for persistent auth issues: If setup_auth fails or you encounter browser/session issues:

  1. Ask user to close ALL Chrome/Chromium instances

  2. Run cleanup_data(confirm=true, preserve_library=true) to clean old data

  3. Run setup_auth again for fresh start This helps resolve conflicts from old browser sessions and installation data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
show_browserNoShow browser window (simple version). Default: true for setup. For advanced control, use browser_options instead.
browser_optionsNoOptional browser settings. Control visibility, timeouts, and stealth behavior.

Implementation Reference

  • Main handler for setup_auth tool. Handles arguments, progress reporting, configuration overrides, calls AuthManager.performSetup, and returns structured result.
    async handleSetupAuth(
      args: {
        show_browser?: boolean;
        browser_options?: BrowserOptions;
      },
      sendProgress?: ProgressCallback
    ): Promise<
      ToolResult<{
        status: string;
        message: string;
        authenticated: boolean;
        duration_seconds?: number;
      }> 
    > {
      const { show_browser, browser_options } = args;
    
      // CRITICAL: Send immediate progress to reset timeout from the very start
      await sendProgress?.("Initializing authentication setup...", 0, 10);
    
      log.info(`🔧 [TOOL] setup_auth called`);
      if (show_browser !== undefined) {
        log.info(`  Show browser: ${show_browser}`);
      }
    
      const startTime = Date.now();
    
      // Apply browser options temporarily
      const originalConfig = { ...CONFIG };
      const effectiveConfig = applyBrowserOptions(browser_options, show_browser);
      Object.assign(CONFIG, effectiveConfig);
    
      try {
        // Progress: Starting
        await sendProgress?.("Preparing authentication browser...", 1, 10);
    
        log.info(`  🌐 Opening browser for interactive login...`);
    
        // Progress: Opening browser
        await sendProgress?.("Opening browser window...", 2, 10);
    
        // Perform setup with progress updates (uses CONFIG internally)
        const success = await this.authManager.performSetup(sendProgress);
    
        const durationSeconds = (Date.now() - startTime) / 1000;
    
        if (success) {
          // Progress: Complete
          await sendProgress?.("Authentication saved successfully!", 10, 10);
    
          log.success(`✅ [TOOL] setup_auth completed (${durationSeconds.toFixed(1)}s)`);
          return {
            success: true,
            data: {
              status: "authenticated",
              message: "Successfully authenticated and saved browser state",
              authenticated: true,
              duration_seconds: durationSeconds,
            },
          };
        } else {
          log.error(`❌ [TOOL] setup_auth failed (${durationSeconds.toFixed(1)}s)`);
          return {
            success: false,
            error: "Authentication failed or was cancelled",
          };
        }
      } catch (error) {
        const errorMessage =
          error instanceof Error ? error.message : String(error);
        const durationSeconds = (Date.now() - startTime) / 1000;
        log.error(`❌ [TOOL] setup_auth failed: ${errorMessage} (${durationSeconds.toFixed(1)}s)`);
        return {
          success: false,
          error: errorMessage,
        };
      } finally {
        // Restore original CONFIG
        Object.assign(CONFIG, originalConfig);
      }
    }
  • Tool definition and input schema for setup_auth, including detailed description and optional browser configuration parameters.
    name: "setup_auth",
    description:
      "Google authentication for NotebookLM access - opens a browser window for manual login to your Google account. " +
      "Returns immediately after opening the browser. You have up to 10 minutes to complete the login. " +
      "Use 'get_health' tool afterwards to verify authentication was saved successfully. " +
      "Use this for first-time authentication or when auto-login credentials are not available. " +
      "For switching accounts or rate-limit workarounds, use 're_auth' tool instead.\n\n" +
      "TROUBLESHOOTING for persistent auth issues:\n" +
      "If setup_auth fails or you encounter browser/session issues:\n" +
      "1. Ask user to close ALL Chrome/Chromium instances\n" +
      "2. Run cleanup_data(confirm=true, preserve_library=true) to clean old data\n" +
      "3. Run setup_auth again for fresh start\n" +
      "This helps resolve conflicts from old browser sessions and installation data.",
    inputSchema: {
      type: "object",
      properties: {
        show_browser: {
          type: "boolean",
          description:
            "Show browser window (simple version). Default: true for setup. " +
            "For advanced control, use browser_options instead.",
        },
        browser_options: {
          type: "object",
          description:
            "Optional browser settings. Control visibility, timeouts, and stealth behavior.",
          properties: {
            show: {
              type: "boolean",
              description: "Show browser window (default: true for setup)",
            },
            headless: {
              type: "boolean",
              description: "Run browser in headless mode (default: false for setup)",
            },
            timeout_ms: {
              type: "number",
              description: "Browser operation timeout in milliseconds (default: 30000)",
            },
          },
        },
      },
    },
  • src/index.ts:252-257 (registration)
    Dispatches setup_auth tool calls to the appropriate handler method in the MCP server request handler.
    case "setup_auth":
      result = await this.toolHandlers.handleSetupAuth(
        args as { show_browser?: boolean },
        sendProgress
      );
      break;
  • Key helper method performSetup in AuthManager, launched by the tool handler. Manages persistent browser context for interactive authentication, data clearing, login, and state persistence.
    async performSetup(sendProgress?: ProgressCallback, overrideHeadless?: boolean): Promise<boolean> {
      const { chromium } = await import("patchright");
    
      // Determine headless mode: override or default to true (visible for setup)
      // overrideHeadless contains show_browser value (true = show, false = hide)
      const shouldShowBrowser = overrideHeadless !== undefined ? overrideHeadless : true;
    
      try {
        // CRITICAL: Clear ALL old auth data FIRST (for account switching)
        log.info("🔄 Preparing for new account authentication...");
        await sendProgress?.("Clearing old authentication data...", 1, 10);
        await this.clearAllAuthData();
    
        log.info("🚀 Launching persistent browser for interactive setup...");
        log.info(`  📍 Profile: ${CONFIG.chromeProfileDir}`);
        await sendProgress?.("Launching persistent browser...", 2, 10);
    
        // ✅ CRITICAL FIX: Use launchPersistentContext (same as runtime!)
        // This ensures session cookies persist correctly
        const context = await chromium.launchPersistentContext(
          CONFIG.chromeProfileDir,
          {
            headless: !shouldShowBrowser, // Use override or default to visible for setup
            channel: "chrome" as const,
            viewport: CONFIG.viewport,
            locale: "en-US",
            timezoneId: "Europe/Berlin",
            args: [
              "--disable-blink-features=AutomationControlled",
              "--disable-dev-shm-usage",
              "--no-first-run",
              "--no-default-browser-check",
            ],
          }
        );
    
        // Get or create a page
        const pages = context.pages();
        const page = pages.length > 0 ? pages[0] : await context.newPage();
    
        // Perform login with progress updates
        const loginSuccess = await this.performLogin(page, sendProgress);
    
        if (loginSuccess) {
          // ✅ Save browser state to state.json (for validation & backup)
          // Chrome ALSO saves everything to the persistent profile automatically!
          await sendProgress?.("Saving authentication state...", 9, 10);
          await this.saveBrowserState(context, page);
          log.success("✅ Setup complete - authentication saved to:");
          log.success(`  📄 State file: ${this.stateFilePath}`);
          log.success(`  📁 Chrome profile: ${CONFIG.chromeProfileDir}`);
          log.info("💡 Session cookies will now persist across restarts!");
        }
    
        // Close persistent context
        await context.close();
    
        return loginSuccess;
      } catch (error) {
        log.error(`❌ Setup failed: ${error}`);
        return false;
      }
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden and adds valuable behavioral context: 'Returns immediately after opening the browser. You have up to 10 minutes to complete the login.' It also includes troubleshooting steps that imply potential issues like browser conflicts. However, it doesn't detail error handling or return values, keeping it from a perfect score.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with core functionality, but the troubleshooting section adds length that may not be essential for every use. Sentences earn their place by providing practical advice, but it could be more streamlined, e.g., by integrating troubleshooting into a separate note.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description compensates well by explaining the tool's behavior, usage context, and troubleshooting. It covers authentication flow and sibling differentiation. However, it lacks details on return values or error responses, which would be helpful for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no specific parameter information beyond what's in the schema, such as explaining 'show_browser' or 'browser_options' usage. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific purpose: 'Google authentication for NotebookLM access - opens a browser window for manual login to your Google account.' It distinguishes from sibling 're_auth' by specifying 'first-time authentication or when auto-login credentials are not available' versus 'switching accounts or rate-limit workarounds.' The verb 'opens' and resource 'browser window' are concrete.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit guidance is provided: 'Use this for first-time authentication or when auto-login credentials are not available. For switching accounts or rate-limit workarounds, use 're_auth' tool instead.' It also advises to 'Use 'get_health' tool afterwards to verify authentication.' This covers when to use, when not to use, and alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/inventra/notebooklm-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server