Skip to main content
Glama

wait_for

Read-only

Pauses automation until specified text appears on a webpage, using Chrome DevTools to synchronize actions with page content loading.

Instructions

Wait for the specified text to appear on the selected page.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to appear on the page
timeoutNoMaximum wait time in milliseconds. If set to 0, the default timeout will be used.

Implementation Reference

  • The handler function for the 'wait_for' tool. It waits for an element containing the specified text to appear on the page by creating locators in all frames using text and ARIA selectors, then calls wait() on the locator.
    handler: async (request, response, context) => {
      const page = context.getSelectedPage();
      const frames = page.frames();
    
      const locator = Locator.race(
        frames.flatMap(frame => [
          frame.locator(`aria/${request.params.text}`),
          frame.locator(`text/${request.params.text}`),
        ]),
      );
    
      if (request.params.timeout) {
        locator.setTimeout(request.params.timeout);
      }
    
      await locator.wait();
    
      response.appendResponseLine(
        `Element with text "${request.params.text}" found.`,
      );
    
      response.setIncludeSnapshot(true);
    },
  • The input schema for the 'wait_for' tool, defining the 'text' parameter and optional 'timeout'.
    schema: {
      text: z.string().describe('Text to appear on the page'),
      ...timeoutSchema,
    },
  • src/main.ts:307-320 (registration)
    The tools from snapshotTools (including wait_for) are collected into an array and registered via registerTool, which sets up the MCP server tool handler.
    const tools = [
      ...Object.values(consoleTools),
      ...Object.values(emulationTools),
      ...Object.values(inputTools),
      ...Object.values(networkTools),
      ...Object.values(pagesTools),
      ...Object.values(performanceTools),
      ...Object.values(screenshotTools),
      ...Object.values(scriptTools),
      ...Object.values(snapshotTools),
    ];
    for (const tool of tools) {
      registerTool(tool as unknown as ToolDefinition);
    }
  • src/main.ts:38-38 (registration)
    Import of snapshot tools module, which exports the wait_for tool.
    import * as snapshotTools from './tools/snapshot.js';
Behavior3/5

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

Annotations indicate readOnlyHint=true, which the description aligns with by implying a passive monitoring action ('wait for'). The description adds behavioral context about waiting for text appearance, but doesn't detail failure modes, polling behavior, or interaction with page state. With annotations covering safety, this provides moderate additional value.

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, direct sentence with zero wasted words. It front-loads the core action and target efficiently, making it easy to parse and understand quickly without unnecessary elaboration.

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 tool with 2 parameters, 100% schema coverage, and readOnlyHint annotation, the description is minimally adequate. It lacks output details (no schema provided) and doesn't address error handling or dependencies on other tools like 'select_page', but covers the basic operation sufficiently given the structured data.

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%, fully documenting both parameters. The description mentions 'specified text' and 'selected page', hinting at the 'text' parameter and implicit page context, but adds no extra meaning beyond the schema's details on text and timeout behavior. Baseline 3 is appropriate given high schema 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 ('wait for') and the target ('specified text to appear on the selected page'), making the purpose understandable. It doesn't explicitly differentiate from siblings like 'evaluate_script' or 'list_console_messages', which might also involve text detection, but the core function is well-defined.

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. It doesn't mention prerequisites (e.g., needing a selected page first), exclusions, or compare it to siblings like 'evaluate_script' for text checking, leaving the agent to infer usage context.

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/SHAY5555-gif/chrome-devtools-mcp'

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