Skip to main content
Glama
lewisvoncken

Playwright MCP

by lewisvoncken

browser_select_option

Destructive

Select options in dropdown menus during browser automation. Specify element references and values to interact with web page controls programmatically.

Instructions

Select an option in a dropdown

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementYesHuman-readable element description used to obtain permission to interact with the element
refYesExact target element reference from the page snapshot
valuesYesArray of values to select in the dropdown. This can be a single value or multiple values.

Implementation Reference

  • The core handler function that executes the 'browser_select_option' tool logic. It locates the target element using the page snapshot reference, generates Playwright code for selecting options, and defines an action to perform the selection.
    handle: async (context, params) => {
      const snapshot = context.currentTabOrDie().snapshotOrDie();
      const locator = snapshot.refLocator(params);
    
      const code = [
        `// Select options [${params.values.join(', ')}] in ${params.element}`,
        `await page.${await generateLocator(locator)}.selectOption(${javascript.formatObject(params.values)});`
      ];
    
      return {
        code,
        action: () => locator.selectOption(params.values).then(() => {}),
        captureSnapshot: true,
        waitForNetwork: true,
      };
    },
  • The schema definition for the 'browser_select_option' tool, specifying name, title, description, input schema, and type.
    schema: {
      name: 'browser_select_option',
      title: 'Select option',
      description: 'Select an option in a dropdown',
      inputSchema: selectOptionSchema,
      type: 'destructive',
    },
  • Zod input schema extension defining the 'values' parameter as an array of strings for the options to select.
    const selectOptionSchema = elementSchema.extend({
      values: z.array(z.string()).describe('Array of values to select in the dropdown. This can be a single value or multiple values.'),
    });
  • The defineTool call that creates the 'browser_select_option' tool object, combining schema and handler. Exported for further registration.
    const selectOption = defineTool({
      capability: 'core',
      schema: {
        name: 'browser_select_option',
        title: 'Select option',
        description: 'Select an option in a dropdown',
        inputSchema: selectOptionSchema,
        type: 'destructive',
      },
    
      handle: async (context, params) => {
        const snapshot = context.currentTabOrDie().snapshotOrDie();
        const locator = snapshot.refLocator(params);
    
        const code = [
          `// Select options [${params.values.join(', ')}] in ${params.element}`,
          `await page.${await generateLocator(locator)}.selectOption(${javascript.formatObject(params.values)});`
        ];
    
        return {
          code,
          action: () => locator.selectOption(params.values).then(() => {}),
          captureSnapshot: true,
          waitForNetwork: true,
        };
      },
    });
  • src/tools.ts:47-47 (registration)
    Inclusion of tools from snapshot.ts (including browser_select_option) into the main snapshotTools array for global registration.
    ...snapshot,
Behavior3/5

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

Annotations provide key behavioral hints: readOnlyHint=false (implies mutation), openWorldHint=true (suggests dynamic interaction), and destructiveHint=true (indicates potential changes). The description adds minimal context by specifying 'dropdown' as the target, but does not elaborate on behavioral traits like permission requirements, error handling, or the impact of selection (e.g., triggering page changes). No contradiction with annotations exists.

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, direct sentence with zero wasted words, making it highly concise and front-loaded. It immediately communicates the core function without unnecessary elaboration, which is efficient for an AI agent parsing tool definitions.

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

Completeness3/5

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

Given the tool's complexity (interactive, destructive action with 3 required parameters) and lack of output schema, the description is minimally complete. It identifies the target (dropdown) but omits details like return values, error conditions, or dependencies on other tools (e.g., browser_snapshot for 'ref'). Annotations help, but more context would improve usability for the 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%, with clear descriptions for all parameters (element, ref, values). The description adds no additional semantic meaning beyond the schema, such as explaining how 'values' correspond to dropdown options or the interaction between 'element' and 'ref'. The baseline score of 3 reflects adequate schema documentation without extra value from the 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 'Select an option in a dropdown' clearly states the action (select) and target resource (dropdown), making the purpose immediately understandable. However, it does not explicitly differentiate from sibling tools like browser_fill_form or browser_click, which might also interact with form elements, leaving room for ambiguity in distinguishing use cases.

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. It lacks context such as prerequisites (e.g., requiring a page snapshot from browser_snapshot), exclusions (e.g., not for non-dropdown elements), or comparisons to siblings like browser_fill_form for general form input, leaving the agent to infer usage from the tool name alone.

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

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