Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

selectOption

Select specific options in dropdown or select elements during web automation. Use this tool to interact with forms and menus by specifying element selectors and desired values.

Instructions

Select option(s) in a dropdown or select element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYes
valuesYesArray of values to select

Implementation Reference

  • The core handler function in PlaywrightController that locates the select element by selector and calls selectOption(values) to select the specified options. Includes logging, error handling, and browser state checks.
    async selectOption(selector: string, values: string[]): Promise<void> {
      try {
        if (!this.isInitialized() || !this.state.page) {
          throw new Error('Browser not initialized');
        }
        this.log('Selecting options', { selector, values });
        const locator = this.state.page.locator(selector);
        await locator.selectOption(values);
        this.log('Select option complete');
      } catch (error: any) {
        console.error('Select option error:', error);
        throw new BrowserError('Failed to select option', 'Check if the selector exists and values are valid');
      }
    }
  • The Tool object definition including name, description, and inputSchema for validating selector (string) and values (array of strings).
    const SELECT_OPTION_TOOL: Tool = {
      name: "selectOption",
      description: "Select option(s) in a dropdown or select element",
      inputSchema: {
        type: "object",
        properties: {
          selector: { type: "string" },
          values: { 
            type: "array",
            items: { type: "string" },
            description: "Array of values to select"
          }
        },
        required: ["selector", "values"]
      }
    };
  • src/server.ts:514-553 (registration)
    The tools object where SELECT_OPTION_TOOL is registered under the 'selectOption' key, which is then passed to the MCP Server capabilities.
    const tools = {
      openBrowser: OPEN_BROWSER_TOOL,
      navigate: NAVIGATE_TOOL,
      type: TYPE_TOOL,
      click: CLICK_TOOL,
      moveMouse: MOVE_MOUSE_TOOL,
      scroll: SCROLL_TOOL,
      screenshot: SCREENSHOT_TOOL,
      getPageSource: GET_PAGE_SOURCE_TOOL,
      getPageText: GET_PAGE_TEXT_TOOL,
      getPageTitle: GET_PAGE_TITLE_TOOL,
      getPageUrl: GET_PAGE_URL_TOOL,
      getScripts: GET_SCRIPTS_TOOL,
      getStylesheets: GET_STYLESHEETS_TOOL,
      getMetaTags: GET_META_TAGS_TOOL,
      getLinks: GET_LINKS_TOOL,
      getImages: GET_IMAGES_TOOL,
      getForms: GET_FORMS_TOOL,
      getElementContent: GET_ELEMENT_CONTENT_TOOL,
      getElementHierarchy: GET_ELEMENT_HIERARCHY_TOOL,
      executeJavaScript: EXECUTE_JAVASCRIPT_TOOL,
      goForward: GO_FORWARD_TOOL,
      hover: HOVER_TOOL,
      dragAndDrop: DRAG_AND_DROP_TOOL,
      selectOption: SELECT_OPTION_TOOL,
      pressKey: PRESS_KEY_TOOL,
      waitForText: WAIT_FOR_TEXT_TOOL,
      waitForSelector: WAIT_FOR_SELECTOR_TOOL,
      resize: RESIZE_TOOL,
      handleDialog: HANDLE_DIALOG_TOOL,
      getConsoleMessages: GET_CONSOLE_MESSAGES_TOOL,
      getNetworkRequests: GET_NETWORK_REQUESTS_TOOL,
      uploadFiles: UPLOAD_FILES_TOOL,
      evaluateWithReturn: EVALUATE_WITH_RETURN_TOOL,
      takeScreenshot: TAKE_SCREENSHOT_TOOL,
      mouseMove: MOUSE_MOVE_TOOL,
      mouseClick: MOUSE_CLICK_TOOL,
      mouseDrag: MOUSE_DRAG_TOOL,
      closeBrowser: CLOSE_BROWSER_TOOL
    };
  • src/server.ts:821-832 (registration)
    The dispatch case in callTool handler that validates args and invokes the playwrightController.selectOption method.
    case 'selectOption': {
      if (!args.selector || !args.values) {
        return {
          content: [{ type: "text", text: "Selector and values are required" }],
          isError: true
        };
      }
      await playwrightController.selectOption(args.selector as string, args.values as string[]);
      return {
        content: [{ type: "text", text: "Option selected successfully" }]
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action but doesn't disclose behavioral traits like whether it requires the element to be visible/interactable, if it triggers events, error conditions, or what happens with invalid values. For a web automation tool with zero annotation coverage, this is a significant gap.

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 zero waste. It's appropriately sized for a simple tool and front-loads the core purpose immediately.

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?

Given the complexity of web automation, no annotations, no output schema, and incomplete parameter documentation, the description is inadequate. It doesn't explain what happens after selection, error handling, or prerequisites like page loading, leaving the agent with significant gaps.

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 50% (only 'values' has a description). The description mentions 'dropdown or select element' which hints at the 'selector' parameter's purpose, adding some meaning beyond the bare schema. However, it doesn't fully compensate for the lack of schema description on 'selector' or provide format/usage details.

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 option(s)') and target ('in a dropdown or select element'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'click' or 'type' that might also interact with form elements, missing full sibling differentiation.

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 tools for web interaction (e.g., 'click', 'type', 'handleDialog'), there's no indication of when this specific dropdown selection tool is appropriate versus other methods.

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/jomon003/PlayMCP'

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