Skip to main content
Glama

wait_for

Pause execution until specified text or CSS selector becomes visible in the browser, with configurable timeout to synchronize page state changes.

Instructions

Wait for visible text or a CSS selector to appear on the page.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textNo
selectorNo
timeoutMsNo

Implementation Reference

  • The handler function for the 'wait_for' tool. It calls requirePage() to get the active page, then waits for either visible text (using getByText) or a CSS selector (using locator) to appear within a configurable timeout (default 10s). Returns {ok: true, url: currentUrl} on success.
    async function waitFor(args: { text?: string; selector?: string; timeoutMs?: number }) {
      const p = requirePage();
      const timeout = args.timeoutMs ?? 10000;
      if (args.text) {
        await p.getByText(args.text).first().waitFor({ timeout });
      } else if (args.selector) {
        await p.locator(args.selector).first().waitFor({ timeout });
      } else {
        throw new Error('Provide {text} or {selector}.');
      }
      return { ok: true, url: p.url() };
    }
  • The tool registration entry including input schema for wait_for. Defines properties: text (string), selector (string), timeoutMs (number). No required fields — the handler enforces that at least one of text/selector must be provided.
      name: 'wait_for',
      description: 'Wait for visible text or a CSS selector to appear on the page.',
      inputSchema: {
        type: 'object',
        properties: {
          text: { type: 'string' },
          selector: { type: 'string' },
          timeoutMs: { type: 'number' },
        },
      },
    },
  • src/index.ts:469-469 (registration)
    The dispatch case in the CallToolRequestSchema handler that routes 'wait_for' requests to the waitFor function.
    case 'wait_for':     result = await waitFor(args as { text?: string; selector?: string; timeoutMs?: number }); break;
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 lacks details on timeout behavior, error handling, and whether it waits for visibility or existence. The term 'visible text' is ambiguous.

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?

Single sentence with no fluff, but front-loaded. Could benefit from a brief structure outlining condition and timeout.

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 no output schema and three parameters, the description is too brief. It fails to mention return values, timeout behavior, or page scope.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description should explain parameters. It only loosely ties 'text' and 'selector' to the description but omits timeoutMs entirely.

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 waits for visible text or a CSS selector to appear, which is a specific verb+resource. It distinguishes from siblings like click, navigate, and type.

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?

No guidance on when to use this tool vs alternatives like waitForSelector or waitForNavigation. No context on prerequisites or conditions.

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/flying-pisces/mcp-helm'

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