Skip to main content
Glama
Winds-AI

autonomous-frontend-browser-tools

ui.interact

Automate browser interactions by clicking, typing, selecting, or scrolling elements using semantic selectors like data-testid, role, label, or text, with automatic visibility and enabled state handling.

Instructions

Interact with the active browser tab using semantic selectors (data-testid, role+name, label, placeholder, name, text, css, xpath). Supports actions: click, type, select, check/uncheck, keypress, hover, waitForSelector, scroll. Automatically scrolls into view and waits for visibility/enabled. Uses a CDP fallback in the extension when needed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
targetYesHow to locate the element
scopeTargetNoOptional container to scope the search (e.g., role=tablist)
valueNoText/value to type/select/keypress when applicable
optionsNo

Implementation Reference

  • Handler function that executes the ui.interact tool by sending POST request with parameters to the browser server's /dom-action endpoint and formats the response.
    async function handleUiInteract(params: any) {
      return await withServerConnection(async () => {
        try {
          const targetUrl = `http://${discoveredHost}:${discoveredPort}/dom-action`;
          const response = await fetch(targetUrl, {
            method: "POST",
            headers: {
              "Content-Type": "application/json",
            },
            body: JSON.stringify(params),
          });
          const result = await response.json();
          if (response.ok && result.success) {
            const texts: any[] = [
              {
                type: "text",
                text: `✅ Action '${params.action}' succeeded on target (${params.target.by}=${params.target.value}).`,
              },
            ];
            if (result.details) {
              texts.push({
                type: "text",
                text: JSON.stringify(result.details, null, 2),
              });
            }
            return { content: texts };
          } else {
            return {
              content: [
                {
                  type: "text",
                  text: `❌ Action '${params.action}' failed: ${
                    result.error || "Unknown error"
                  }`,
                },
              ],
              isError: true,
            } as any;
          }
        } catch (error: any) {
          const errorMessage =
            error instanceof Error ? error.message : String(error);
          return {
            content: [
              {
                type: "text",
                text: `Failed to perform interaction: ${errorMessage}`,
              },
            ],
            isError: true,
          } as any;
        }
      });
    }
  • Registration of the "ui.interact" tool on the MCP server, including detailed input schema using Zod for validation and description.
    server.tool(
      "ui.interact",
      "Interact with the active browser tab using semantic selectors (data-testid, role+name, label, placeholder, name, text, css, xpath). Supports actions: click, type, select, check/uncheck, keypress, hover, waitForSelector, scroll. Automatically scrolls into view and waits for visibility/enabled. Uses a CDP fallback in the extension when needed.",
      {
        action: z.enum([
          "click",
          "type",
          "select",
          "check",
          "uncheck",
          "keypress",
          "hover",
          "waitForSelector",
          "scroll",
        ]),
        target: z
          .object({
            by: z.enum([
              "testid",
              "role",
              "label",
              "text",
              "placeholder",
              "name",
              "css",
              "xpath",
            ]),
            value: z.string(),
            exact: z.boolean().optional(),
          })
          .describe("How to locate the element"),
        scopeTarget: z
          .object({
            by: z.enum([
              "testid",
              "role",
              "label",
              "text",
              "placeholder",
              "name",
              "css",
              "xpath",
            ]),
            value: z.string(),
            exact: z.boolean().optional(),
          })
          .optional()
          .describe("Optional container to scope the search (e.g., role=tablist)"),
        value: z
          .string()
          .optional()
          .describe("Text/value to type/select/keypress when applicable"),
        options: z
          .object({
            timeoutMs: z.number().optional(),
            waitForVisible: z.boolean().optional(),
            waitForEnabled: z.boolean().optional(),
            waitForNetworkIdleMs: z.number().optional(),
            postActionScreenshot: z.boolean().optional(),
            screenshotLabel: z.string().optional(),
            fallbackToCdp: z.boolean().optional(),
            frameSelector: z.string().optional(),
            // scroll-specific
            scrollX: z.number().optional(),
            scrollY: z.number().optional(),
            to: z.enum(["top", "bottom"]).optional(),
            smooth: z.boolean().optional(),
            // assertion helpers
            assertTarget: z
              .object({
                by: z.enum([
                  "testid",
                  "role",
                  "label",
                  "text",
                  "placeholder",
                  "name",
                  "css",
                  "xpath",
                ]),
                value: z.string(),
                exact: z.boolean().optional(),
              })
              .optional(),
            assertTimeoutMs: z.number().optional(),
            assertUrlContains: z.string().optional(),
            tabChangeWaitMs: z.number().optional(),
          })
          .optional(),
      },
      handleUiInteract
    );
  • Input schema definition for the ui.interact tool using Zod, specifying parameters like action, target selector, optional scope, value, and extensive options for timeouts, assertions, etc.
    {
      action: z.enum([
        "click",
        "type",
        "select",
        "check",
        "uncheck",
        "keypress",
        "hover",
        "waitForSelector",
        "scroll",
      ]),
      target: z
        .object({
          by: z.enum([
            "testid",
            "role",
            "label",
            "text",
            "placeholder",
            "name",
            "css",
            "xpath",
          ]),
          value: z.string(),
          exact: z.boolean().optional(),
        })
        .describe("How to locate the element"),
      scopeTarget: z
        .object({
          by: z.enum([
            "testid",
            "role",
            "label",
            "text",
            "placeholder",
            "name",
            "css",
            "xpath",
          ]),
          value: z.string(),
          exact: z.boolean().optional(),
        })
        .optional()
        .describe("Optional container to scope the search (e.g., role=tablist)"),
      value: z
        .string()
        .optional()
        .describe("Text/value to type/select/keypress when applicable"),
      options: z
        .object({
          timeoutMs: z.number().optional(),
          waitForVisible: z.boolean().optional(),
          waitForEnabled: z.boolean().optional(),
          waitForNetworkIdleMs: z.number().optional(),
          postActionScreenshot: z.boolean().optional(),
          screenshotLabel: z.string().optional(),
          fallbackToCdp: z.boolean().optional(),
          frameSelector: z.string().optional(),
          // scroll-specific
          scrollX: z.number().optional(),
          scrollY: z.number().optional(),
          to: z.enum(["top", "bottom"]).optional(),
          smooth: z.boolean().optional(),
          // assertion helpers
          assertTarget: z
            .object({
              by: z.enum([
                "testid",
                "role",
                "label",
                "text",
                "placeholder",
                "name",
                "css",
                "xpath",
              ]),
              value: z.string(),
              exact: z.boolean().optional(),
            })
            .optional(),
          assertTimeoutMs: z.number().optional(),
          assertUrlContains: z.string().optional(),
          tabChangeWaitMs: z.number().optional(),
        })
        .optional(),
    },
Behavior4/5

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

With no annotations, the description carries full burden and provides good behavioral context: it discloses automatic behaviors (scrolling into view, waiting for visibility/enabled), fallback mechanism (CDP fallback), and supported selector types. However, it doesn't mention error handling, performance implications, or what happens with invalid inputs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in two sentences: the first states purpose and capabilities, the second adds behavioral context. Every phrase adds value, though it could be slightly more front-loaded with the core purpose.

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

Completeness3/5

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

For a complex 5-parameter tool with nested objects and no output schema, the description provides adequate but incomplete context. It covers the main functionality and some behaviors, but lacks details on return values, error cases, and comprehensive usage scenarios that would help an agent fully understand tool invocation.

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 60%, and the description adds minimal parameter semantics beyond the schema. It mentions 'semantic selectors' mapping to the 'target.by' enum and lists actions matching the 'action' enum, but doesn't explain parameter interactions or provide examples. The baseline 3 is appropriate given moderate schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Interact with the active browser tab using semantic selectors' with a specific list of supported actions (click, type, select, etc.). It distinguishes from siblings like browser.navigate (navigation) or ui.inspectElement (inspection only) by emphasizing interaction capabilities.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context ('active browser tab', 'when needed' for CDP fallback) but doesn't explicitly state when to use this tool versus alternatives like ui.inspectElement or browser.console.read. No clear exclusions or prerequisites are provided.

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/Winds-AI/Frontend-development-MCP-tools-public'

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