Skip to main content
Glama

browser_navigate

Navigate to a specified URL and wait for the page to load using Playwright MCP Server, enabling automation of web tasks like navigation, HTML extraction, and screenshots.

Instructions

Navigate to a specified URL and wait for page load

Input Schema

NameRequiredDescriptionDefault
urlYes
waitUntilNodomcontentloaded

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "url": { "format": "uri", "type": "string" }, "waitUntil": { "default": "domcontentloaded", "enum": [ "networkidle", "domcontentloaded", "load" ], "type": "string" } }, "required": [ "url" ], "type": "object" }

Implementation Reference

  • Handler function that executes the browser_navigate tool: validates input, connects to browser if needed, navigates to URL using page.goto, returns success/error text response.
    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:23-32 (registration)
    Registers the 'browser_navigate' tool with the MCP server, providing name, metadata (title, description), and input schema.
    this.server.registerTool( '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') } },
  • Zod schema defining the input structure for the browser_navigate tool (url required, waitUntil optional).
    export const BrowserNavigateInputSchema = z.object({ url: z.string().url(), waitUntil: z.enum(['networkidle', 'domcontentloaded', 'load']).optional().default('domcontentloaded') });
  • Helper method ensureConnected() called by the handler to verify and establish Playwright browser connection if necessary.
    async ensureConnected(): Promise<void> { const connected = await this.isConnected(); if (!connected) { await this.cleanup(); await this.connect(); } }
  • Helper method getPage() called by the handler to retrieve the current Playwright Page instance.
    getPage(): Page { if (!this.page) { throw new Error('Playwright not connected. Call connect() first.'); } return this.page; }

Other Tools

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

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