Skip to main content
Glama
cloudflare

Cloudflare Playwright MCP

Official
by cloudflare

browser_select_option

Destructive

Automatically select dropdown options in web browsers using Playwright for efficient testing. Specify target elements and values to streamline interaction and validation workflows.

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 implementation of the 'browser_select_option' tool. It defines the tool schema and the handler function that generates Playwright code to select options in a dropdown and executes the action on the locator derived from the page snapshot.
    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,
        };
      },
    });
  • Zod schema definition for the input parameters of the browser_select_option tool, extending the shared elementSchema with 'values' array.
    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:35-50 (registration)
    Registration of the snapshot tools array, which includes the browser_select_option tool from the snapshot module via array spread.
    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),
    ];
  • src/tools.ts:26-26 (registration)
    Import of the snapshot module containing the browser_select_option tool definition.
    import snapshot from './tools/snapshot.js';
Behavior3/5

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

The description doesn't add meaningful behavioral context beyond what annotations already provide. Annotations clearly indicate this is a destructive (destructiveHint: true), non-read-only operation with open-world characteristics. The description doesn't elaborate on what 'destructive' means in this context (e.g., changes UI state), nor does it mention rate limits, permissions needed, or error conditions.

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 at just 5 words, front-loading the core functionality with zero wasted words. Every word earns its place, making it immediately scannable and understandable without unnecessary elaboration.

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 this is a destructive operation (per annotations) with no output schema, the description should ideally mention what happens after selection (e.g., page changes, validation triggers) or error scenarios. While the schema covers parameters well, the behavioral context for a destructive UI interaction tool is incomplete without output information or success/failure indicators.

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?

With 100% schema description coverage, the input schema already fully documents all three parameters. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain the relationship between 'element' and 'ref', clarify what format 'values' should be in, or provide examples of valid dropdown selections.

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 (dropdown option), making the purpose immediately understandable. However, it doesn't distinguish this from similar sibling tools like browser_click or browser_type, which could also interact with dropdowns in different ways.

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. With many sibling browser interaction tools available, there's no indication whether this is for single/multi-select dropdowns, when to use browser_click instead, or any prerequisites like needing a page snapshot first.

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

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

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