Skip to main content
Glama
livoras

Better Playwright MCP

by livoras

browserSelectOption

Selects specified options in a dropdown menu on a webpage, using the element's xpath reference and providing a delay for snapshot capture, optimizing web interactions within the 'Better Playwright MCP' framework.

Instructions

在下拉框中选择选项

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageIdYes页面ID
refYes元素的xp引用值
valuesYes要选择的选项值数组
waitForTimeoutNo操作后等待获取快照的延迟时间(毫秒,默认2000)

Implementation Reference

  • The handler function for the 'browser_select_option' tool. It generates a locator from the element reference, adds code to select the specified options for code generation purposes, and executes the selection in the actual browser tab.
    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);
        });
    },
  • Defines the Zod schema for the tool inputs: element/ref from shared elementSchema, plus 'values' array of strings to select. Includes the tool schema with 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 = defineTabTool({
        capability: 'core',
        schema: {
            name: 'browser_select_option',
            title: 'Select option',
            description: 'Select an option in a dropdown',
            inputSchema: selectOptionSchema,
            type: 'destructive',
        },
  • Registers the selectOption tool by including it in the default export array of snapshot-related tools, likely imported and registered in the MCP server.
    export default [
        snapshot,
        click,
        drag,
        hover,
        selectOption,
    ];
  • Shared base schema for element selection tools, extended by browser_select_option for element/ref identification.
    export const elementSchema = z.object({
        element: z.string().describe('Human-readable element description used to obtain permission to interact with the element'),
        ref: z.string().describe('Exact target element reference from the page snapshot'),
    });
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While '选择选项' implies a UI interaction, the description doesn't mention what happens after selection (e.g., page changes, validation), error conditions, or performance characteristics like timeouts beyond what's in the schema. This leaves significant gaps for a mutation tool.

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 extremely concise - a single phrase that directly states the tool's purpose with zero wasted words. It's appropriately sized for what it communicates, though it could benefit from additional context.

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

Completeness2/5

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

For a UI interaction tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what happens after selection, what the tool returns, error conditions, or how it differs from similar sibling tools. The 100% schema coverage helps with parameters but doesn't compensate for missing behavioral context.

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 already documents all parameters thoroughly. The description adds no additional meaning about parameters beyond what the schema provides - it doesn't explain how 'values' should match dropdown options or provide examples of 'ref' XPath patterns.

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 options) and the target ('下拉框' - dropdown), which is a specific verb+resource combination. However, it doesn't distinguish this tool from sibling tools like 'browserClick' or 'browserPressKey' that might also interact with UI elements, so it doesn't reach the highest clarity level.

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 sibling tools like 'browserClick' and 'browserType' available, there's no indication of when dropdown selection is appropriate versus other interaction methods, nor any mention of prerequisites or exclusions.

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

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