Skip to main content
Glama
jae-jae
by jae-jae

browser_install

Install Chromium browser binary for Playwright web automation when encountering browser not installed errors.

Instructions

Install Playwright Chromium browser binary. Call this if you get an error about the browser not being installed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
withDepsNoInstall system dependencies required by Chromium browser. Default is false
forceNoForce installation even if Chromium is already installed. Default is false

Implementation Reference

  • Implementation of the browser_install tool handler. Parses args for withDeps and force flags, builds Playwright install command, executes it via helper, and returns success/error response in MCP format.
    export async function browserInstall(args: any) {
      const withDeps = args?.withDeps === true;
      const force = args?.force === true;
    
      logger.info("[BrowserInstall] Starting installation of Chromium browser...");
    
      try {
        // Build the command arguments
        const installArgs = ["playwright", "install"];
    
        if (withDeps) {
          installArgs.push("--with-deps");
        }
    
        if (force) {
          installArgs.push("--force");
        }
    
        installArgs.push("chromium");
    
        logger.debug(`[BrowserInstall] Executing: npx ${installArgs.join(" ")}`);
    
        // Execute the installation command
        const result = await executePlaywrightInstall(installArgs);
    
        if (result.success) {
          const successMessage = `Successfully installed Chromium browser${withDeps ? " with system dependencies" : ""}`;
          logger.info(`[BrowserInstall] ${successMessage}`);
    
          return {
            content: [
              {
                type: "text",
                text: `✅ ${successMessage}\n\n${result.output}`
              }
            ]
          };
        } else {
          const errorMessage = `Failed to install Chromium browser: ${result.error}`;
          logger.error(`[BrowserInstall] ${errorMessage}`);
    
          return {
            content: [
              {
                type: "text",
                text: `❌ ${errorMessage}\n\nOutput:\n${result.output}\n\nError:\n${result.error}`
              }
            ]
          };
        }
      } catch (error: any) {
        const errorMessage = `Chromium installation failed: ${error.message}`;
        logger.error(`[BrowserInstall] ${errorMessage}`);
    
        return {
          content: [
            {
              type: "text",
              text: `❌ ${errorMessage}\n\nPlease check your internet connection and try again. You may also need to run with elevated privileges.`
            }
          ]
        };
      }
    }
  • Tool schema definition for browser_install, including name, description, and inputSchema with optional boolean parameters 'withDeps' and 'force'.
    export const browserInstallTool = {
      name: "browser_install",
      description: "Install Playwright Chromium browser binary. Call this if you get an error about the browser not being installed.",
      inputSchema: {
        type: "object",
        properties: {
          withDeps: {
            type: "boolean",
            description: "Install system dependencies required by Chromium browser. Default is false",
            default: false
          },
          force: {
            type: "boolean",
            description: "Force installation even if Chromium is already installed. Default is false",
            default: false
          }
        },
        required: []
      }
    };
  • Registration of browser_install tool handler in the central toolHandlers map using browserInstallTool.name as key mapping to browserInstall function.
    export const toolHandlers = {
      [fetchUrlTool.name]: fetchUrl,
      [fetchUrlsTool.name]: fetchUrls,
      [browserInstallTool.name]: browserInstall
    };
  • Supporting helper utility that executes the Playwright install command. Prefers local Playwright CLI for consistency, falls back to npx, captures stdout/stderr, and returns success status with output.
    function executePlaywrightInstall(args: string[]): Promise<{success: boolean, output: string, error: string}> {
      return new Promise((resolve) => {
        let command: string;
        let commandArgs: string[];
        let strategyUsed: string;
    
        // Strategy 1: Try to use local playwright CLI
        try {
          const playwrightPackagePath = require.resolve("playwright/package.json");
          const playwrightDir = playwrightPackagePath.replace("/package.json", "");
          const playwrightCliPath = `${playwrightDir}/cli.js`;
    
          // Verify CLI file exists
          if (existsSync(playwrightCliPath)) {
            // Remove 'playwright' from args as we're directly calling the CLI
            const filteredArgs = args.filter(arg => arg !== "playwright");
            
            command = "node";
            commandArgs = [playwrightCliPath, ...filteredArgs];
            strategyUsed = "local CLI";
            
            logger.info(`[BrowserInstall] Using local Playwright CLI: ${playwrightCliPath}`);
            logger.debug(`[BrowserInstall] Command: node ${commandArgs.join(" ")}`);
          } else {
            throw new Error("CLI file not found");
          }
        } catch (error: any) {
          // Strategy 2: Fallback to npx
          command = "npx";
          commandArgs = args;
          strategyUsed = "npx fallback";
          
          logger.warn(`[BrowserInstall] Local CLI not found, falling back to npx: ${error.message}`);
          logger.debug(`[BrowserInstall] Command: npx ${commandArgs.join(" ")}`);
        }
    
        const child = spawn(command, commandArgs, {
          stdio: "pipe",
          shell: process.platform === "win32"
        });
    
        let stdout = "";
        let stderr = "";
    
        child.stdout?.on("data", (data) => {
          const output = data.toString();
          stdout += output;
          logger.debug(`[BrowserInstall] [${strategyUsed}] stdout: ${output.trim()}`);
        });
    
        child.stderr?.on("data", (data) => {
          const output = data.toString();
          stderr += output;
          logger.debug(`[BrowserInstall] [${strategyUsed}] stderr: ${output.trim()}`);
        });
    
        child.on("close", (code) => {
          const success = code === 0;
          logger.info(`[BrowserInstall] [${strategyUsed}] Process exited with code: ${code}`);
    
          resolve({
            success,
            output: stdout,
            error: stderr
          });
        });
    
        child.on("error", (error) => {
          logger.error(`[BrowserInstall] [${strategyUsed}] Process error: ${error.message}`);
          resolve({
            success: false,
            output: stdout,
            error: error.message
          });
        });
      });
    }
  • browserInstallTool is included in the exported tools array for discovery/registration.
    export const tools = [
      fetchUrlTool,
      fetchUrlsTool,
      browserInstallTool
    ];
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains the tool's purpose and trigger condition but doesn't describe what happens during installation (e.g., download size, time, network requirements), potential side effects, or what constitutes successful completion. It provides basic context but lacks richer behavioral details needed for a mutation tool.

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 perfectly concise with two sentences that each serve a distinct purpose: the first states what the tool does, and the second provides usage guidance. There's zero wasted language, and the information is front-loaded with the core functionality stated immediately.

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

Completeness4/5

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

Given this is a mutation tool (installation) with no annotations and no output schema, the description provides good context about when to use it and what it does. However, it doesn't explain what happens after installation completes or what the agent should expect, leaving some gaps in completeness for a tool that modifies system state.

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%, with both parameters (withDeps, force) well-documented in the schema. The description doesn't add any parameter-specific information beyond what's already in the schema, so it meets the baseline of 3 where the schema does the heavy lifting without additional value from the description.

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

Purpose5/5

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

The description clearly states the specific action ('Install Playwright Chromium browser binary') and resource ('Chromium browser binary'), distinguishing it from sibling tools like fetch_url and fetch_urls which perform different operations. It provides a concrete use case ('if you get an error about the browser not being installed') that makes the purpose unambiguous.

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool ('if you get an error about the browser not being installed'), providing clear contextual guidance. While it doesn't mention alternatives or exclusions, the specific error-based trigger makes usage guidelines comprehensive and actionable for the stated purpose.

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/jae-jae/fetcher-mcp'

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