browser_select
Automate dropdown selections on web pages by specifying a CSS selector and the desired value or label, integrating with browser automation for efficient web interactions.
Instructions
Select an option from a dropdown menu
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for select element | |
| value | Yes | Value or label to select |
Implementation Reference
- src/executor.ts:404-428 (handler)The handler function that executes the browser_select tool using Playwright's page.selectOption method to select a dropdown option.async function handleBrowserSelect(page: Page, args: any): Promise<{ toolResult: CallToolResult }> { try { await page.waitForSelector(args.selector); await page.selectOption(args.selector, args.value); return { toolResult: { content: [{ type: "text", text: `Selected option ${args.value} in ${args.selector}`, }], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `Selection failed on ${args.selector}: ${(error as Error).message}`, }], isError: true, }, }; } }
- src/tools.ts:96-107 (schema)Input schema and metadata definition for the browser_select tool.{ name: "browser_select", description: "Select an option from a dropdown menu", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for select element" }, value: { type: "string", description: "Value or label to select" } }, required: ["selector", "value"] } },
- src/tools.ts:3-12 (registration)Registers browser_select as part of the browser tools list used for tool dispatching.export const BROWSER_TOOLS = [ "browser_navigate", "browser_screenshot", "browser_click", "browser_fill", "browser_select", "browser_hover", "browser_evaluate", "browser_set_viewport" ];
- src/executor.ts:200-201 (registration)Switch case in executeToolCall that routes browser_select calls to its handler.case "browser_select": return await handleBrowserSelect(activePage!, args);
- src/handlers.ts:61-63 (registration)MCP server handler for listing available tools, which includes browser_select.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools, }));