Skip to main content
Glama

launch_browser

Launch a new browser instance using Chromium, Firefox, or WebKit, with configurable headless mode and viewport dimensions for automated web tasks.

Instructions

Launch a new browser instance (chromium, firefox, or webkit)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
browserNoBrowser engine to usechromium
headlessNoRun browser in headless mode
viewportNo

Implementation Reference

  • Zod schema for launch_browser tool: validates 'browser' (enum chromium/firefox/webkit, default chromium), 'headless' (boolean, default true), and optional 'viewport' (width/height).
    const LaunchBrowserSchema = z.object({
      browser: z.enum(['chromium', 'firefox', 'webkit']).default('chromium'),
      headless: z.boolean().default(true),
      viewport: z.object({
        width: z.number().default(1280),
        height: z.number().default(1024)
      }).optional()
    });
  • src/index.ts:130-157 (registration)
    Registration of launch_browser tool in ListToolsRequestSchema handler, defining its name, description, and inputSchema (JSON Schema format).
    tools: [
      {
        name: 'launch_browser',
        description: 'Launch a new browser instance (chromium, firefox, or webkit)',
        inputSchema: {
          type: 'object',
          properties: {
            browser: {
              type: 'string',
              enum: ['chromium', 'firefox', 'webkit'],
              default: 'chromium',
              description: 'Browser engine to use'
            },
            headless: {
              type: 'boolean',
              default: true,
              description: 'Run browser in headless mode'
            },
            viewport: {
              type: 'object',
              properties: {
                width: { type: 'number', default: 1280 },
                height: { type: 'number', default: 720 }
              }
            }
          }
        }
      },
  • Handler for the 'launch_browser' case in CallToolRequestSchema: parses args with LaunchBrowserSchema, closes existing browser if open, clears console logs, launches the selected browser (chromium/firefox/webkit) via Playwright, creates a new context and page, sets up console event listener, and returns a success message.
    switch (name) {
      case 'launch_browser': {
        const params = LaunchBrowserSchema.parse(args);
        
        // Close existing browser if any
        if (currentBrowser) {
          await currentBrowser.close();
        }
    
        // Clear console logs
        consoleLogs = [];
    
        // Launch new browser
        const browserType = params.browser === 'firefox' ? firefox : 
                          params.browser === 'webkit' ? webkit : chromium;
        
        currentBrowser = await browserType.launch({ 
          headless: params.headless 
        });
        
        currentContext = await currentBrowser.newContext({
          viewport: params.viewport ? {
            width: params.viewport.width,
            height: params.viewport.height
          } : undefined
        });
        
        currentPage = await currentContext.newPage();
    
        // Set up console event listener
        currentPage.on('console', (msg) => {
          consoleLogs.push({
            level: msg.type(),
            message: msg.text(),
            timestamp: new Date()
          });
        });
    
        return {
          content: [
            {
              type: 'text',
              text: `Browser ${params.browser} launched successfully ${params.headless ? '(headless)' : '(headed)'}`
            }
          ]
        };
      }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.1/5.0
Behavior2/5

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

No annotations provided, and the description only states 'launch' without disclosing side effects like resource consumption, persistence, or the need to later close the instance. The agent is left uninformed about lifecycle management.

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?

Single sentence, 10 words, front-loaded with core purpose. No superfluous information.

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 no output schema, the description should explain return values (e.g., browser instance ID) or effects, but it does not. Nested viewport object lacks any explanatory context. The tool's role in the sequence of operations is unclear.

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

Parameters2/5

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

The description redundantly lists the enum values already in the schema but adds no extra meaning for parameters like headless or viewport. With 67% schema coverage, baseline is 3, but the description fails to add value, reducing the score.

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 tool's purpose: launching a new browser instance with specific browser options (chromium, firefox, webkit). It distinguishes itself from sibling tools (e.g., close_browser, navigate) by being the initialization step.

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 vs alternatives. It is implied as the first step, but no mention of prerequisites, consequences of not closing, or when not to use it (e.g., if a browser already exists).

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