Skip to main content
Glama

interactive_login

Open browser for manual login to access N Lobby school portal data including announcements, schedules, and learning resources through browser-based authentication.

Instructions

Open browser for manual login to N Lobby (no credentials required)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'interactive_login': initializes browser, performs interactive login via browserAuth, sets cookies, and returns success/error response
    case "interactive_login":
      try {
        // Initialize browser
        await this.browserAuth.initializeBrowser();
    
        // Start interactive login
        const extractedCookies =
          await this.browserAuth.interactiveLogin();
    
        // Set cookies in API client
        this.api.setCookies(extractedCookies.allCookies);
    
        // Close browser
        await this.browserAuth.close();
    
        return {
          content: [
            {
              type: "text",
              text: `[SUCCESS] Successfully logged in to N Lobby!\n\nExtracted cookies:\n- Session Token: ${extractedCookies.sessionToken ? "present" : "missing"}\n- CSRF Token: ${extractedCookies.csrfToken ? "present" : "missing"}\n- Callback URL: ${extractedCookies.callbackUrl || "not set"}\n\nYou can now access real N Lobby data using other tools.`,
            },
          ],
        };
      } catch (error) {
        // Ensure browser is closed on error
        await this.browserAuth.close();
    
        return {
          content: [
            {
              type: "text",
              text: `[ERROR] Interactive login failed: ${error instanceof Error ? error.message : "Unknown error"}\n\nPlease try again or contact support if the issue persists.`,
            },
          ],
        };
      }
  • Input schema for interactive_login tool (empty object, no parameters required)
    inputSchema: {
      type: "object",
      properties: {},
    },
  • src/server.ts:409-417 (registration)
    Registration of the 'interactive_login' tool in the MCP tools list
    {
      name: "interactive_login",
      description:
        "Open browser for manual login to N Lobby (no credentials required)",
      inputSchema: {
        type: "object",
        properties: {},
      },
    },
  • Core helper function implementing interactive browser-based login, navigating to N Lobby, waiting for user login, and extracting cookies
    async interactiveLogin(): Promise<ExtractedCookies> {
      // Check browser health before starting
      const isHealthy = await this.checkBrowserHealth();
      if (!isHealthy) {
        logger.warn("Browser unhealthy, reinitializing...");
        await this.initializeBrowser();
      }
    
      if (!this.browser || !this.page) {
        throw new Error(
          "Browser not initialized. Call initializeBrowser() first.",
        );
      }
    
      try {
        logger.info("Starting interactive login process...");
    
        // Navigate to N Lobby
        await this.page.goto(CONFIG.nlobby.baseUrl, {
          waitUntil: "networkidle2",
          timeout: 30000,
        });
    
        logger.info(
          "N Lobby page loaded. Please complete the login process in the browser window.",
        );
        logger.info("The browser will remain open for you to login manually.");
    
        // Wait for user to complete login (detect when we're on the authenticated page)
        await this.waitForLoginCompletionWithRetry(300000);
    
        logger.info("Login detected! Extracting cookies...");
    
        // Extract cookies after successful login
        const cookies = await this.extractCookies();
    
        return cookies;
      } catch (error) {
        logger.error("Interactive login failed:", error);
    
        // Enhanced error logging for interactive login
        if (this.page) {
          try {
            const currentUrl = await this.page.url();
            const title = await this.page.title();
            logger.error(`Current URL: ${currentUrl}`);
            logger.error(`Page title: ${title}`);
    
            // Take screenshot for debugging
            await this.takeScreenshot("interactive-login-failure-debug.png");
          } catch (debugError) {
            logger.error("Failed to capture debug information:", debugError);
          }
        }
    
        throw new Error(
          `Interactive login failed: ${error instanceof Error ? error.message : "Unknown error"}`,
        );
      }
    }

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/minagishl/nlobby-mcp'

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