Skip to main content
Glama
devskido

Playwright MCP Server

by devskido

playwright_navigate

Navigate to specified URLs in a browser for web automation tasks like content scraping, testing, or page interaction.

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

  • The `execute` method of `NavigationTool` class implements the `playwright_navigate` tool by performing `page.goto()` navigation with error handling for browser connection issues.
    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;
        }
      });
    }
  • The tool definition object including name, description, and inputSchema 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"],
      },
    },
  • Switch case in `handleToolCall` that registers and routes `playwright_navigate` calls to the NavigationTool handler.
    case "playwright_navigate":
      return await navigationTool.execute(args, context);
  • src/tools.ts:450-452 (registration)
    `playwright_navigate` is listed in the BROWSER_TOOLS array, used for conditional browser launch and tool categorization.
    export const BROWSER_TOOLS = [
      "playwright_navigate",
      "playwright_screenshot",
  • Code generation helper in PlaywrightGenerator that converts `playwright_navigate` actions into test code steps.
    case 'playwright_navigate':
      return this.generateNavigateStep(parameters);
    case 'playwright_fill':

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.7/5.0
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 action without behavioral details. It doesn't disclose whether this creates/destroys browser instances, requires authentication, has rate limits, or what happens on failure (e.g., timeout behavior). For a navigation tool with 7 parameters, this is inadequate transparency.

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 extremely concise at 3 words, front-loaded with the core action. There's zero wasted text, making it easy to parse. However, this conciseness comes at the cost of completeness, but as a standalone measure, it's efficient.

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?

Given 7 parameters, no annotations, no output schema, and multiple sibling tools, the description is incomplete. It doesn't explain what the tool returns (e.g., page object, success status), how it integrates with other Playwright tools, or behavioral expectations. For a complex navigation tool, this minimal description leaves critical gaps.

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 fully documents all 7 parameters. The description adds no parameter-specific information beyond implying a 'url' parameter. Baseline 3 is appropriate as the schema does the heavy lifting, but the description doesn't enhance understanding of parameter interactions or semantics.

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' states the basic action (verb+resource) but is vague about scope and differentiation. It doesn't specify whether this opens a new browser/page or navigates an existing one, nor how it differs from sibling tools like 'playwright_get' which might serve similar purposes. The purpose is understandable but lacks specificity.

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 is provided on when to use this tool versus alternatives like 'playwright_get' or other navigation-related siblings. The description doesn't mention prerequisites (e.g., requires an active browser session) or context for usage. It's a standalone statement with no usage context.

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