Skip to main content
Glama
nzjami

Playwright MCP

by nzjami

browser_select_option

Destructive

Select values 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 core handler function for the 'browser_select_option' tool. It resolves the element locator from the provided ref, adds corresponding Playwright code to the response, executes the selectOption action on the locator with the given values, and waits for completion.
    handle: async (tab, params, response) => {
      response.setIncludeSnapshot();
    
      const locator = await tab.refLocator(params);
      response.addCode(`// Select options [${params.values.join(', ')}] in ${params.element}`);
      response.addCode(`await page.${await generateLocator(locator)}.selectOption(${javascript.formatObject(params.values)});`);
    
      await tab.waitForCompletion(async () => {
        await locator.selectOption(params.values);
      });
    },
  • Defines the input schema (extending elementSchema with 'values' array) and the tool schema including name 'browser_select_option', title, description, inputSchema reference, and type.
    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 = defineTabTool({
      capability: 'core',
      schema: {
        name: 'browser_select_option',
        title: 'Select option',
        description: 'Select an option in a dropdown',
        inputSchema: selectOptionSchema,
        type: 'destructive',
      },
  • src/tools.ts:36-52 (registration)
    Registers the 'browser_select_option' tool by including the snapshot tools module (which exports it) in the central allTools array used by the backend.
    export const allTools: Tool<any>[] = [
      ...common,
      ...console,
      ...dialogs,
      ...evaluate,
      ...files,
      ...install,
      ...keyboard,
      ...navigate,
      ...network,
      ...mouse,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs,
      ...wait,
    ];
  • The BrowserServerBackend provides the tools list to MCP server and dispatches calls to the specific tool handler by name, enabling 'browser_select_option'.
    tools(): mcpServer.ToolSchema<any>[] {
      return this._tools.map(tool => tool.schema);
    }
    
    async callTool(schema: mcpServer.ToolSchema<any>, parsedArguments: any) {
      const response = new Response(this._context, schema.name, parsedArguments);
      const tool = this._tools.find(tool => tool.schema.name === schema.name)!;
      await tool.handle(this._context, parsedArguments, response);
      if (this._sessionLog)
        await this._sessionLog.log(response);
      return await response.serialize();
    }
  • Initializes the backend's _tools array using filteredTools, which includes the 'browser_select_option' tool.
    constructor(config: FullConfig, browserContextFactory: BrowserContextFactory) {
      this._tools = filteredTools(config);
      this._context = new Context(this._tools, config, browserContextFactory);
    }
Behavior4/5

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

Annotations indicate destructiveHint=true and readOnlyHint=false, which the description doesn't contradict. The description adds value by specifying the action is for dropdowns, but it doesn't elaborate on behavioral traits like whether it triggers page changes, requires specific permissions, or handles errors. With annotations covering safety, it provides some context but could be more detailed.

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 no wasted words. It's front-loaded and appropriately sized for the tool's purpose, making it easy to scan and understand 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 has annotations (destructive, openWorld) but no output schema, the description is minimal. It covers the basic action but lacks details on return values, error handling, or integration with other browser tools. For a destructive operation in browser automation, more context would be helpful, but it's adequate as a starting point.

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 parameters are fully documented in the schema. The description doesn't add any meaning beyond what the schema provides, such as explaining how 'values' interact with dropdowns or the relationship between 'element' and 'ref'. Baseline 3 is appropriate as the schema handles the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/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), but it's vague about the context (browser automation) and doesn't distinguish from siblings like browser_fill_form or browser_click. It restates the title 'Select option' without adding specificity.

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 is provided on when to use this tool versus alternatives. For example, it doesn't clarify if this is for dropdowns only, how it differs from browser_fill_form for form inputs, or prerequisites like needing a page snapshot. The description lacks any usage context.

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/nzjami/mcpPlaywright'

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