Skip to main content
Glama

playwright_navigate

Launch a browser instance, navigate to a specified URL, and control viewport size, browser type, navigation timeout, and headless mode for web automation tasks.

Instructions

Navigate to a URL

Input Schema

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

Implementation Reference

  • NavigationTool class with execute method implementing the playwright_navigate tool logic using Playwright's page.goto
    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;
          }
        });
      }
  • Input schema definition for the playwright_navigate tool, including parameters like url, browserType, dimensions, etc.
    {
      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"],
      },
  • Registration and dispatch of playwright_navigate in the main tool handler switch statement
    case "playwright_navigate":
      return await navigationTool.execute(args, context);
  • Instantiation of the NavigationTool instance used for handling playwright_navigate calls
    if (!navigationTool) navigationTool = new NavigationTool(server);
  • src/tools.ts:451-451 (registration)
    Inclusion of playwright_navigate in the BROWSER_TOOLS array for conditional browser launching
    "playwright_navigate",
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Navigate to a URL' implies opening a browser and loading a page, but doesn't describe what happens (creates new browser instance? uses existing? what's returned?), authentication needs, rate limits, or error conditions. For a tool with 7 parameters and no annotations, 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 maximally concise at just 4 words, front-loading the essential information with zero wasted words. It's appropriately sized for a simple navigation function.

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 tool with 7 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns, what happens on success/failure, or how it relates to other playwright tools. The agent would need to guess about the behavioral context and output format.

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 the schema already fully documents all 7 parameters. The description adds no additional parameter information beyond what's in the schema. According to guidelines, when schema coverage is high (>80%), the baseline is 3 even with no param info in description.

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

Purpose4/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), making the purpose immediately understandable. However, it doesn't distinguish this tool from other navigation-related siblings like 'playwright_get' or 'playwright_go_back/forward', which would require more specific differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives. With multiple playwright navigation tools available (get, go_back, go_forward), there's no indication of when this specific navigate function is preferred or what distinguishes it from other navigation methods.

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

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

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