Skip to main content
Glama

browser_select_option

Destructive

Select options in dropdown menus during web automation by specifying element references and desired values to interact with web page controls.

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 for the 'browser_select_option' tool. It captures a page snapshot, locates the target dropdown element using a reference from a prior snapshot, generates equivalent Playwright code for the action, and executes the selection of one or more options.
    handle: async (tab, params, response) => {
      response.setIncludeSnapshot();
    
      const locator = await tab.refLocator(params);
      response.addCode(`await page.${await generateLocator(locator)}.selectOption(${javascript.formatObject(params.values)});`);
    
      await tab.waitForCompletion(async () => {
        await locator.selectOption(params.values);
      });
    },
  • The tool schema defining the name, title, description, input schema (element ref + values array), and type as destructive.
    schema: {
      name: 'browser_select_option',
      title: 'Select option',
      description: 'Select an option in a dropdown',
      inputSchema: selectOptionSchema,
      type: 'destructive',
    },
  • Zod schema for inputs: extends elementSchema (element description + ref) with 'values' array of strings.
    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.'),
    });
  • src/tools.ts:36-52 (registration)
    The 'snapshot' module (containing browser_select_option) is imported and registered by inclusion in the 'allTools' array, which provides tools to the MCP backend.
    export const allTools: Tool<any>[] = [
      ...common,
      ...console,
      ...dialogs,
      ...evaluate,
      ...files,
      ...install,
      ...keyboard,
      ...navigate,
      ...network,
      ...mouse,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs,
      ...wait,
    ];
  • The defineTabTool helper wraps the raw tab handler, adding context.currentTabOrDie(), modal state checks, and delegates to the tab-specific handle.
    export function defineTabTool<Input extends z.Schema>(tool: TabTool<Input>): Tool<Input> {
      return {
        ...tool,
        handle: async (context, params, response) => {
          const tab = context.currentTabOrDie();
          const modalStates = tab.modalStates().map(state => state.type);
          if (tool.clearsModalState && !modalStates.includes(tool.clearsModalState))
            response.addError(`Error: The tool "${tool.schema.name}" can only be used when there is related modal state present.\n` + tab.modalStatesMarkdown().join('\n'));
          else if (!tool.clearsModalState && modalStates.length)
            response.addError(`Error: Tool "${tool.schema.name}" does not handle the modal state.\n` + tab.modalStatesMarkdown().join('\n'));
          else
            return tool.handle(tab, params, response);
        },
      };
    }
Behavior3/5

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

Annotations already indicate this is a destructive (destructiveHint: true), non-read-only (readOnlyHint: false) operation with open-world implications (openWorldHint: true). The description adds minimal behavioral context beyond this—it doesn't explain what 'destructive' means in practice (e.g., modifies page state), rate limits, or authentication needs. However, it doesn't contradict annotations, so it meets the lower bar with annotations present.

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, efficient sentence with zero waste—it directly states the tool's purpose without fluff. It's appropriately sized and front-loaded, making it easy to parse quickly.

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), rich annotations, and 100% schema coverage, the description is minimally adequate. However, it lacks details on output (no schema), error handling, or practical examples, leaving gaps for an agent to understand full usage. With annotations covering safety, a 3 reflects basic completeness.

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 three parameters (element, ref, values). The description adds no additional meaning about parameters beyond what's in the schema, such as examples of 'values' or how 'ref' relates to snapshots. Baseline 3 is appropriate when the schema does the heavy lifting.

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'), providing a specific verb+resource combination. It distinguishes this from siblings like browser_click or browser_type by focusing on dropdown interaction, though it doesn't explicitly contrast with all possible alternatives.

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 like browser_click for general clicking or browser_type for text input. There's no mention of prerequisites (e.g., needing a page snapshot), context for dropdowns, or exclusions for other element types.

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

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