browser_navigate
Navigate web browsers to specified URLs for automated testing and interaction using Playwright MCP Server's browser automation capabilities.
Instructions
Navigate to a URL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL to navigate to |
Implementation Reference
- src/server.ts:202-214 (handler)The main handler function for the 'browser_navigate' tool. It ensures a browser and page are available, navigates to the specified URL using Playwright's page.goto(), and returns a confirmation message.private async handleNavigate(url: string) { await this.ensureBrowser(); await this.browserState.page!.goto(url); return { content: [ { type: 'text', text: `Navigated to ${url}`, }, ], }; }
- src/server.ts:63-72 (schema)Input schema definition for the 'browser_navigate' tool, specifying that it requires a 'url' string parameter.inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'The URL to navigate to', }, }, required: ['url'], },
- src/server.ts:60-73 (registration)Registration of the 'browser_navigate' tool in the list of available tools returned by ListToolsRequestHandler, including name, description, and input schema.{ name: 'browser_navigate', description: 'Navigate to a URL', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'The URL to navigate to', }, }, required: ['url'], }, },
- src/server.ts:157-158 (handler)Dispatch case in the CallToolRequestHandler switch statement that routes 'browser_navigate' calls to the handleNavigate method.case 'browser_navigate': return await this.handleNavigate(args?.url as string);
- src/server.ts:191-200 (helper)Helper method used by browser_navigate handler to launch Chromium browser and create a new page if not already available.private async ensureBrowser() { if (!this.browserState.browser) { this.browserState.browser = await chromium.launch({ headless: false, }); } if (!this.browserState.page) { this.browserState.page = await this.browserState.browser.newPage(); } }