Skip to main content
Glama

playwright_navigate

Navigate to a specified URL in a browser with configurable viewport settings, timeout, and wait conditions for web automation tasks.

Instructions

Navigate to a URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
widthNoViewport width in pixels (default: 1920)
heightNoViewport height in pixels (default: 1080)
timeoutNoNavigation timeout in milliseconds
waitUntilNoNavigation wait condition

Implementation Reference

  • Handler function for the playwright_navigate tool, performs page navigation using Playwright's goto method.
    case "playwright_navigate":
      try {
        await page!.goto(args.url, {
          timeout: args.timeout || 30000,
          waitUntil: args.waitUntil || "load"
        });
        return {
          content: [{
            type: "text",
            text: `Navigated to ${args.url}`,
          }],
          isError: false,
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Navigation failed: ${(error as Error).message}`,
          }],
          isError: true,
        };
      }
  • Input schema definition for the playwright_navigate tool, specifying parameters like url, viewport size, timeout, and waitUntil.
    {
      name: "playwright_navigate",
      description: "Navigate to a URL",
      inputSchema: {
        type: "object",
        properties: {
          url: { type: "string" },
          width: { type: "number", description: "Viewport width in pixels (default: 1920)" },
          height: { type: "number", description: "Viewport height in pixels (default: 1080)" },
          timeout: { type: "number", description: "Navigation timeout in milliseconds" },
          waitUntil: { type: "string", description: "Navigation wait condition" }
        },
        required: ["url"],
      },
    },
  • Registers the list tools request handler, which returns the array of tool definitions including playwright_navigate.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: tools,
    }));
  • Registers the call tool request handler, which dispatches to the specific tool handler based on name, including playwright_navigate.
    server.setRequestHandler(CallToolRequestSchema, async (request) =>
      handleToolCall(request.params.name, request.params.arguments ?? {}, server)
    );
  • Helper array listing browser-requiring tools, including playwright_navigate, used to conditionally launch the browser.
    export const BROWSER_TOOLS = [
      "playwright_navigate",
      "playwright_screenshot",
      "playwright_click",
      "playwright_fill",
      "playwright_select",
      "playwright_hover",
      "playwright_evaluate"
    ];

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/lars-hagen/mcp-playwright-cdp'

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