Skip to main content
Glama

playwright_navigate

Direct a browser to a specified URL using Playwright automation, enabling web page interaction, content retrieval, and testing within an automated environment.

Instructions

Navigate to a URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes

Implementation Reference

  • The core handler logic for the 'playwright_navigate' tool. It navigates the Playwright page to the specified URL with optional timeout and waitUntil options, returning success or error message.
    case "playwright_navigate": try { await page!.goto(args.url, { timeout: args.timeout || 30000, waitUntil: args.waitUntil || "load" }); return { toolResult: { content: [{ type: "text", text: `Navigated to ${args.url} with ${args.waitUntil || "load"} wait`, }], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `Navigation failed: ${(error as Error).message}`, }], isError: true, }, }; }
  • The tool schema definition for 'playwright_navigate', including name, description, and input schema requiring a 'url' string.
    { name: "playwright_navigate", description: "Navigate to a URL", inputSchema: { type: "object", properties: { url: { type: "string" }, }, required: ["url"], }, },
  • Registration of the MCP CallTool request handler, which routes tool calls (including 'playwright_navigate') to the handleToolCall function in toolsHandler.ts.
    // Call tool handler server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}, server) );
  • Registration of the MCP ListTools request handler, which provides the list of available tools including 'playwright_navigate'.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools, }));
  • Helper function to ensure the Playwright browser and page are launched, used by browser-requiring tools like 'playwright_navigate'.
    async function ensureBrowser() { if (!browser) { browser = await chromium.launch({ headless: false }); const context = await browser.newContext({ viewport: { width: 1920, height: 1080 }, deviceScaleFactor: 1, }); page = await context.newPage(); page.on("console", (msg) => { const logEntry = `[${msg.type()}] ${msg.text()}`; consoleLogs.push(logEntry); // Note: server.notification is assumed to be passed in from the main server }); } return 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/lebrodus/mcp-playwright'

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