Skip to main content
Glama
Angeluis001

Playwright MCP

by Angeluis001

browser_select_option

Destructive

Select options in dropdown menus during browser automation. Specify element references and values to interact with web page select elements 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 handler function that implements the browser_select_option tool. It resolves the element locator from the page snapshot, generates the corresponding code snippet, and executes the selectOption action using Playwright's locator API.
    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,
      };
    },
  • Defines the input schema using Zod, extending the base elementSchema with 'values' array, and the tool's metadata schema including the name 'browser_select_option'.
    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.'),
    });
    
    const selectOption = defineTool({
      capability: 'core',
      schema: {
        name: 'browser_select_option',
        title: 'Select option',
        description: 'Select an option in a dropdown',
        inputSchema: selectOptionSchema,
        type: 'destructive',
      },
  • Registers and exports the selectOption tool (browser_select_option) within the snapshot module's default export array.
    export default [
      snapshot,
      click,
      drag,
      hover,
      type,
      selectOption,
    ];
  • src/tools.ts:35-50 (registration)
    Includes the snapshot module (containing browser_select_option) in the main snapshotTools array for global tool registration.
    export const snapshotTools: Tool<any>[] = [
      ...common(true),
      ...console,
      ...dialogs(true),
      ...files(true),
      ...install,
      ...keyboard(true),
      ...navigate(true),
      ...network,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs(true),
      ...testing,
      ...wait(true),
    ];
Behavior3/5

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

Annotations provide readOnlyHint=false, openWorldHint=true, and destructiveHint=true, indicating this is a mutable, open-ended, and potentially destructive action. The description adds minimal behavioral context beyond this, as 'Select an option' implies mutation but doesn't detail effects like page changes or side effects. It doesn't contradict annotations, so a baseline 3 is appropriate given the annotations cover key traits.

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, front-loaded sentence with zero waste: 'Select an option in a dropdown' directly conveys the core purpose without fluff. Every word earns its place, making it highly efficient and easy to parse.

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 UI action with 3 required parameters), annotations cover safety and openness, but there's no output schema. The description is minimal and doesn't address return values or error conditions, leaving gaps. It's adequate for basic understanding but incomplete for robust agent use, scoring a minimum viable 3.

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 three parameters (element, ref, values). The description adds no additional parameter semantics beyond what the schema provides, such as examples or edge cases for values. Since the schema does the heavy lifting, the baseline score of 3 is justified.

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 clearly states the action ('Select an option') and target ('in a dropdown'), which is specific and distinguishes it from siblings like browser_click or browser_fill_form. However, it doesn't explicitly differentiate from browser_handle_dialog or browser_type, which could also involve selection interactions, making it slightly less precise than a perfect 5.

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 doesn't mention prerequisites (e.g., needing a snapshot first), exclusions (e.g., not for non-dropdown elements), or comparisons to siblings like browser_click for general interactions, leaving the agent to infer usage from context 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/Angeluis001/playwright-mcp'

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