Skip to main content
Glama
VikashLoomba

MCP-Server-Playwright

browser_select_text

Select dropdown elements in web pages by matching text content to values for automated browser interactions.

Instructions

Select an element on the page with Select tag by its text content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText content of the element to select
valueYesValue to select

Implementation Reference

  • The main handler logic for the 'browser_select_text' tool. It attempts to select an option in a <select> element by matching the text content using Playwright's page.getByText().selectOption(). Includes error handling for strict mode violations by retrying on the first matching element.
    case ToolName.BrowserSelectText:
      try {
        await page.getByText(args.text).selectOption(args.value);
        return {
          content: [{
            type: "text",
            text: `Selected element with text ${args.text} with value: ${args.value}`,
          }],
          isError: false,
        };
      } catch (error) {
        if((error as Error).message.includes("strict mode violation")) {
            console.log("Strict mode violation, retrying on first element...");
            try {
                await page.getByText(args.text).first().selectOption(args.value);
                return {
                    content: [{
                        type: "text",
                        text: `Selected element with text ${args.text} with value: ${args.value}`,
                    }],
                    isError: false,
                };
            } catch (error) {
                return {
                    content: [{
                        type: "text",
                        text: `Failed (twice) to select element with text ${args.text}: ${(error as Error).message}`,
                    }],
                    isError: true,
                };
            }
        }
        return {
          content: [{
            type: "text",
            text: `Failed to select element with text ${args.text}: ${(error as Error).message}`,
          }],
          isError: true,
        };
      }
  • Tool schema definition including name, description, and inputSchema for 'browser_select_text'. Defines required parameters 'text' and 'value'.
    {
      name: ToolName.BrowserSelectText,
      description: "Select an element on the page with Select tag by its text content",
      inputSchema: {
        type: "object",
        properties: {
          text: { type: "string", description: "Text content of the element to select" },
          value: { type: "string", description: "Value to select" },
        },
        required: ["text", "value"],
      },
    },
  • index.ts:640-642 (registration)
    Registration of all tools, including 'browser_select_text', via the ListToolsRequestSchema handler which returns the TOOLS array.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: TOOLS,
    }));
  • index.ts:644-646 (registration)
    Registration of the CallToolRequestSchema handler, which dispatches to handleToolCall based on the tool name, including 'browser_select_text'.
    server.setRequestHandler(CallToolRequestSchema, async (request) =>
      handleToolCall(request.params.name as ToolName, request.params.arguments ?? {})
    );
  • Enum definition mapping ToolName.BrowserSelectText to the string 'browser_select_text'.
    BrowserSelectText = "browser_select_text",
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but lacks details on effects (e.g., whether it triggers events, changes page state, or requires specific permissions), error handling, or performance implications, leaving 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 a single, efficient sentence with zero waste, clearly front-loading the core action. It avoids redundancy and is appropriately sized for the tool's complexity, earning full marks for conciseness.

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 tool's mutation nature (selecting elements), no annotations, and no output schema, the description is incomplete. It lacks information on return values, error cases, or behavioral nuances, making it inadequate for safe and effective use by an agent.

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 both parameters ('text' and 'value'). The description implies these parameters are used for selection but doesn't add syntax, format, or interaction details beyond what the schema provides, meeting the baseline for high coverage.

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 an element') and target ('on the page with Select tag by its text content'), providing a specific verb and resource. However, it doesn't explicitly differentiate from sibling tools like 'browser_select' (which likely selects by other criteria) or 'browser_click_text' (which clicks rather than selects), missing full sibling distinction.

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 offers no guidance on when to use this tool versus alternatives. It doesn't mention scenarios like selecting dropdown options, prerequisites such as needing a page loaded, or exclusions for non-Select elements, leaving the agent to infer usage from context alone.

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/VikashLoomba/MCP-Server-Playwright'

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