browser_navigate
Directs a browser to a specified URL using Playwright sessions, enabling automated web navigation within isolated browser instances managed by the server.
Instructions
Navigate to URL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes |
Implementation Reference
- index.js:301-315 (registration)Registration of the 'browser_navigate' tool using server.tool, which proxies the call to a browser client.
server.tool('browser_navigate', 'Navigate to URL', { url: z.string() }, async (args, extra) => { log(`[browser_navigate] called with args: ${JSON.stringify(args)}`); try { const result = await proxyToolCall('browser_navigate', args); log(`[browser_navigate] result: ${JSON.stringify(result).slice(0, 500)}`); if (!result.isError) { hasActivePage = true; // Mark page as active after successful navigation } return result; } catch (err) { log(`[browser_navigate] ERROR: ${err.message}\n${err.stack}`); throw err; } }); - index.js:209-240 (helper)The proxyToolCall function serves as the actual implementation handler that forwards tool execution requests (including 'browser_navigate') to the underlying MCP client.
async function proxyToolCall(toolName, args) { log(`[proxyToolCall] ${toolName} with args: ${JSON.stringify(args)}`); const { client } = await getOrCreateInstance(); log(`[proxyToolCall] got client for port ${assignedPort}`); // Update last used if (assignedPort && instances.has(assignedPort)) { instances.get(assignedPort).lastUsed = Date.now(); } try { log(`[proxyToolCall] Calling client.callTool...`); const result = await client.callTool({ name: toolName, arguments: args || {} }); log(`[proxyToolCall] Result type: ${typeof result}`); log(`[proxyToolCall] Result: ${JSON.stringify(result).slice(0, 500)}`); // The SDK returns { content: [...], isError?: boolean } // We need to return this same format if (result && result.content) { return result; } // Fallback: wrap in content array if needed return { content: [{ type: 'text', text: JSON.stringify(result) }] }; } catch (error) { log(`[proxyToolCall] ERROR: ${error.message}\n${error.stack}`); return { content: [{ type: 'text', text: `Error: ${error.message}` }], isError: true };