Skip to main content
Glama

playwright_navigate

Navigate to web pages using browser automation. Specify URL, browser type, viewport dimensions, and navigation settings to load websites for testing or data extraction.

Instructions

Navigate to a URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to navigate to the website specified
browserTypeNoBrowser type to use (chromium, firefox, webkit). Defaults to chromium
widthNoViewport width in pixels (default: 1280)
heightNoViewport height in pixels (default: 720)
timeoutNoNavigation timeout in milliseconds
waitUntilNoNavigation wait condition
headlessNoRun browser in headless mode (default: false)

Implementation Reference

  • NavigationTool class implements the core logic for the 'playwright_navigate' tool by executing Playwright's page.goto with error handling for browser disconnections.
    export class NavigationTool extends BrowserToolBase {
      /**
       * Execute the navigation tool
       */
      async execute(args: any, context: ToolContext): Promise<ToolResponse> {
        // Check if browser is available
        if (!context.browser || !context.browser.isConnected()) {
          // If browser is not connected, we need to reset the state to force recreation
          resetBrowserState();
          return createErrorResponse(
            "Browser is not connected. The connection has been reset - please retry your navigation.",
          );
        }
    
        // Check if page is available and not closed
        if (!context.page || context.page.isClosed()) {
          return createErrorResponse("Page is not available or has been closed. Please retry your navigation.");
        }
    
        return this.safeExecute(context, async (page) => {
          try {
            await page.goto(args.url, {
              timeout: args.timeout || 30000,
              waitUntil: args.waitUntil || "load",
            });
    
            return createSuccessResponse(`Navigated to ${args.url}`);
          } catch (error) {
            const errorMessage = (error as Error).message;
    
            // Check for common disconnection errors
            if (
              errorMessage.includes("Target page, context or browser has been closed") ||
              errorMessage.includes("Target closed") ||
              errorMessage.includes("Browser has been disconnected")
            ) {
              // Reset browser state to force recreation on next attempt
              resetBrowserState();
              return createErrorResponse(
                `Browser connection issue: ${errorMessage}. Connection has been reset - please retry your navigation.`,
              );
            }
    
            // For other errors, return the standard error
            throw error;
          }
        });
      }
    }
  • Defines the tool name, description, and input schema (parameters like url, browserType, viewport dimensions, etc.) for 'playwright_navigate'.
    name: "playwright_navigate",
    description: "Navigate to a URL",
    inputSchema: {
      type: "object",
      properties: {
        url: { type: "string", description: "URL to navigate to the website specified" },
        browserType: {
          type: "string",
          description: "Browser type to use (chromium, firefox, webkit). Defaults to chromium",
          enum: ["chromium", "firefox", "webkit"],
        },
        width: { type: "number", description: "Viewport width in pixels (default: 1280)" },
        height: { type: "number", description: "Viewport height in pixels (default: 720)" },
        timeout: { type: "number", description: "Navigation timeout in milliseconds" },
        waitUntil: { type: "string", description: "Navigation wait condition" },
        headless: { type: "boolean", description: "Run browser in headless mode (default: false)" },
      },
      required: ["url"],
    },
  • Instantiates the NavigationTool instance during tool initialization.
    if (!navigationTool) navigationTool = new NavigationTool(server);
    if (!closeBrowserTool) closeBrowserTool = new CloseBrowserTool(server);
  • Dispatches tool calls to the NavigationTool's execute method in the main handleToolCall switch statement.
    case "playwright_navigate":
      return await navigationTool.execute(args, context);
  • Imports NavigationTool from browser tools index.
    NavigationTool,
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits like whether this opens/closes browsers, handles authentication, manages sessions, has side effects, or what happens on failure (e.g., timeout). For a browser automation tool with 7 parameters, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's appropriately sized and front-loaded, though it could benefit from more detail given the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a browser navigation tool with 7 parameters, no annotations, and no output schema, the description is incomplete. It lacks context on return values, error handling, dependencies on other tools (e.g., session management), and behavioral nuances, leaving significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so parameters are well-documented in the schema. The description adds no meaning beyond the schemaโ€”it doesn't explain parameter interactions, default behaviors, or usage examples. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Navigate to a URL' clearly states the action (navigate) and target (URL), but it's vague about scope and doesn't distinguish from siblings like 'playwright_get' or 'playwright_go_forward'. It doesn't specify if this opens a new browser/page or navigates an existing one.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'playwright_get' (which might be similar) or other navigation-related siblings. The description provides no context about prerequisites, sequencing, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/aakashH242/mcp-playwright'

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