login
Authenticate with Perplexity.ai to enable web searches through browser automation. Opens a browser window for login if not already authenticated.
Instructions
Check if you are authenticated on Perplexity.ai. If not, opens a browser window so you can log in.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:60-75 (handler)The 'login' tool is registered in src/index.ts. The execute handler uses `ensureAuthenticated` to manage the authentication flow.
mcp.addTool({ name: "login", description: "Check if you are authenticated on Perplexity.ai. If not, opens a browser window so you can log in.", parameters: z.object({}), execute: async () => { await ensureBrowser(); const page = await getFirstPage(); const authenticated = await checkSession(page); if (authenticated) { return "Already authenticated on Perplexity.ai."; } await ensureAuthenticated(); return "Login successful. You are now authenticated on Perplexity.ai."; }, }); - src/auth.ts:29-43 (helper)The 'ensureAuthenticated' function orchestrates the login process, opening the browser and waiting for the session to become active.
export async function ensureAuthenticated(): Promise<void> { await ensureBrowser(); const page = await getFirstPage(); await page.goto(PERPLEXITY_HOME, { waitUntil: "domcontentloaded" }); const authenticated = await checkSession(page); if (authenticated) { log("Session active."); return; } log("No active session. Please log in to Perplexity in the browser window..."); await waitForLogin(page); log("Login detected."); }