interactive_login
Manually log in to the N Lobby school portal via a browser without credentials to access announcements, schedules, and learning resources securely.
Instructions
Open browser for manual login to N Lobby (no credentials required)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/browser-auth.ts:513-572 (handler)Core implementation of the interactive_login tool: launches a headless=false Puppeteer browser, navigates to N Lobby, waits for manual user login via waitForLoginCompletionWithRetry, extracts authentication cookies, handles errors with screenshots.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"}`, ); } }
- src/server.ts:996-1031 (handler)MCP tool handler dispatch in server.ts: handles the CallToolRequest for 'interactive_login', instantiates BrowserAuth if needed, calls interactiveLogin, sets extracted cookies to API client, 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.`, }, ], }; }
- src/server.ts:409-417 (registration)Tool registration entry in the server's listTools handler: defines the tool name, description, and empty input schema (no parameters required).{ name: "interactive_login", description: "Open browser for manual login to N Lobby (no credentials required)", inputSchema: { type: "object", properties: {}, }, },
- src/browser-auth.ts:5-10 (schema)Type definition for the output of interactiveLogin: structure containing extracted session tokens, CSRF, callback URL, and all cookies as string.export interface ExtractedCookies { sessionToken?: string; csrfToken?: string; callbackUrl?: string; allCookies: string; }