Skip to main content
Glama

browser_navigate

Directs a web browser to load a specific URL and waits for the page to complete loading, enabling automated web navigation for testing or data collection.

Instructions

Navigate to a specified URL and wait for page load

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
waitUntilNodomcontentloaded

Implementation Reference

  • The anonymous async handler function for the browser_navigate tool. It validates the input parameters, ensures the Playwright browser is connected, navigates the page to the specified URL, and returns a success or error message.
    async (params: any) => { try { const input = z.object({ url: z.string().url(), waitUntil: z.enum(['networkidle', 'domcontentloaded', 'load']).optional().default('domcontentloaded') }).parse(params); await this.playwright.ensureConnected(); const page = this.playwright.getPage(); await page.goto(input.url, { waitUntil: input.waitUntil }); return { content: [{ type: 'text', text: `Successfully navigated to ${page.url()}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Navigation failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; }
  • src/server.ts:24-60 (registration)
    The MCP server registration of the 'browser_navigate' tool, including its metadata, inline input schema, and inline handler function.
    'browser_navigate', { title: 'Navigate to URL', description: 'Navigate to a specified URL and wait for page load', inputSchema: { url: z.string().url(), waitUntil: z.enum(['networkidle', 'domcontentloaded', 'load']).optional().default('domcontentloaded') } }, async (params: any) => { try { const input = z.object({ url: z.string().url(), waitUntil: z.enum(['networkidle', 'domcontentloaded', 'load']).optional().default('domcontentloaded') }).parse(params); await this.playwright.ensureConnected(); const page = this.playwright.getPage(); await page.goto(input.url, { waitUntil: input.waitUntil }); return { content: [{ type: 'text', text: `Successfully navigated to ${page.url()}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Navigation failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
  • Zod input schema definition for the browser_navigate tool parameters.
    export const BrowserNavigateInputSchema = z.object({ url: z.string().url(), waitUntil: z.enum(['networkidle', 'domcontentloaded', 'load']).optional().default('domcontentloaded') });
  • Key helper methods from PlaywrightManager used by the handler: ensureConnected() to maintain browser connection and getPage() to retrieve the current page instance.
    async ensureConnected(): Promise<void> { const connected = await this.isConnected(); if (!connected) { await this.cleanup(); await this.connect(); } }

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/b3nw/playwright-mcp-server'

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