Skip to main content
Glama

playwright_select

Select options in dropdown elements on web pages using CSS selectors and values for browser automation tasks.

Instructions

Select an element on the page with Select tag

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for element to select
valueYesValue to select

Implementation Reference

  • The handler function for the 'playwright_select' tool. It waits for the selector, selects the option using Playwright's selectOption method, and returns success or error message.
    case "playwright_select": try { await page!.waitForSelector(args.selector); await page!.selectOption(args.selector, args.value); return { content: [{ type: "text", text: `Selected ${args.selector} with: ${args.value}`, }], isError: false, }; } catch (error) { return { content: [{ type: "text", text: `Failed to select ${args.selector}: ${(error as Error).message}`, }], isError: true, }; }
  • The input schema and metadata definition for the 'playwright_select' tool, including name, description, and required parameters.
    { name: "playwright_select", description: "Select an element on the page with Select tag", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to select" }, value: { type: "string", description: "Value to select" }, }, required: ["selector", "value"], }, },
  • src/index.ts:22-26 (registration)
    Registration of all tools, including 'playwright_select', by creating the tool definitions array and setting up the request handlers that expose them via MCP.
    // Create tool definitions const TOOLS = createToolDefinitions(); // Setup request handlers setupRequestHandlers(server, TOOLS);
  • Helper constant listing browser-requiring tools, including 'playwright_select', used in handleToolCall to conditionally launch the browser.
    export const BROWSER_TOOLS = [ "playwright_navigate", "playwright_screenshot", "playwright_click", "playwright_fill", "playwright_select", "playwright_hover", "playwright_evaluate" ];
  • Registers the generic tool call handler which dispatches to the specific handler (like playwright_select) based on the tool name.
    // Call tool handler server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}, server) );

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/lars-hagen/mcp-playwright-cdp'

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