Skip to main content
Glama

wait_for

Pauses script execution until a specified web element becomes available on the page, using CSS selectors to identify elements and optional timeout settings.

Instructions

Wait for an element to appear on the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for the element to wait for
timeoutNoTimeout in milliseconds (default: 5000)

Implementation Reference

  • Handler function for the 'wait_for' MCP tool. Delegates to browser.waitFor method.
    handler: async ({ selector, timeout = 5000 }) => {
      await browser.waitFor(selector, timeout);
      return { success: true, message: `Element ${selector} appeared within ${timeout}ms` };
    }
  • Input schema definition for the 'wait_for' tool.
    inputSchema: {
      type: 'object',
      properties: {
        selector: { type: 'string', description: 'CSS selector for the element to wait for' },
        timeout: { type: 'number', description: 'Timeout in milliseconds (default: 5000)' }
      },
      required: ['selector']
    },
  • Full registration of the 'wait_for' tool in createPlaywrightTools array.
    {
      name: 'wait_for',
      description: 'Wait for an element to appear on the page',
      inputSchema: {
        type: 'object',
        properties: {
          selector: { type: 'string', description: 'CSS selector for the element to wait for' },
          timeout: { type: 'number', description: 'Timeout in milliseconds (default: 5000)' }
        },
        required: ['selector']
      },
      handler: async ({ selector, timeout = 5000 }) => {
        await browser.waitFor(selector, timeout);
        return { success: true, message: `Element ${selector} appeared within ${timeout}ms` };
      }
    },
  • Core waitFor helper method in SimpleBrowser class that uses Playwright's waitForSelector.
    async waitFor(selector, timeout = 5000) {
      await this.ensureLaunched();
      await this.page.waitForSelector(selector, { timeout });
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action but lacks details on what happens on success (e.g., returns element, continues execution) or failure (e.g., timeout error, retry behavior), and doesn't mention side effects like blocking execution or resource usage.

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 that directly states the tool's purpose without unnecessary words. It's front-loaded and appropriately sized, with every word contributing to understanding.

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 annotations and no output schema, the description is incomplete for a tool that likely involves waiting behavior and potential errors. It doesn't explain return values, error conditions, or operational context, leaving gaps for an AI agent to infer usage.

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 ('selector' and 'timeout') with clear descriptions. The description adds no additional meaning beyond implying the tool uses these parameters, meeting the baseline for 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 tool's purpose with a specific verb ('wait for') and resource ('an element to appear on the page'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_text' or 'select', which might also involve waiting for elements, though the core action is distinct.

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 scenarios like waiting for dynamic content, handling timeouts, or how it relates to siblings like 'get_text' (which might implicitly wait) or 'navigate' (which could involve waiting for page loads).

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/zypin-testing/zypin-mcp'

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