Skip to main content
Glama
quequiere

perplexity-web-mcp

by quequiere

login

Check your authentication status on Perplexity.ai and open a browser to log in if not 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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:60-75 (registration)
    Registration of the 'login' tool via mcp.addTool(), including its schema (no parameters), description, and execute handler.
    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.";
      },
    });
  • The execute handler for the 'login' tool: checks session, and if not authenticated, calls ensureAuthenticated() to open browser for login.
    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.";
    },
  • checkSession(): Helper that calls Perplexity's auth API endpoint to check if the user is logged in.
    export async function checkSession(page: Page): Promise<boolean> {
      try {
        const response = await page.evaluate(async (url: string) => {
          const res = await fetch(url, { credentials: "include" });
          return res.json();
        }, AUTH_CHECK_URL);
    
        const session = response as Session;
        return !!session?.user?.id;
      } catch {
        return false;
      }
    }
  • ensureAuthenticated(): Navigates to Perplexity home, checks session, and waits for user to log in via the browser window.
    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.");
    }
  • waitForLogin(): Polls every 2 seconds for up to 5 minutes until a valid session is detected.
    async function waitForLogin(page: Page): Promise<void> {
      const deadline = Date.now() + POLL_TIMEOUT_MS;
      while (Date.now() < deadline) {
        await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
        const ok = await checkSession(page);
        if (ok) return;
      }
      throw new Error("Login timeout after 5 minutes.");
    }
Behavior4/5

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

Discloses key behaviors (authentication check, browser opening) without annotations, but could detail post-login behavior.

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

Conciseness5/5

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

Single, front-loaded sentence with no wasted words, efficiently conveying purpose and action.

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?

Covers core functionality well; lacks detail on return value or post-login state, but adequate for a simple tool.

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

Parameters4/5

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

No parameters, so baseline 4 applies; description adds no parameter info but doesn't need to.

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?

Clearly states the tool checks authentication and optionally opens a browser for login, distinguishing it from sibling search tools.

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

Usage Guidelines4/5

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

Describes when to use (to check/login) and what happens next, though no explicit when-not or alternatives are given.

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/quequiere/perplexity-web-mcp'

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