Skip to main content
Glama
cloudflare

Cloudflare Playwright MCP

Official
by cloudflare

browser_wait_for

Read-only

Wait for text to appear or disappear, or delay for a set time, to synchronize browser actions.

Instructions

Wait for text to appear or disappear or a specified time to pass

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeNoThe time to wait in seconds
textNoThe text to wait for
textGoneNoThe text to wait for to disappear

Implementation Reference

  • Handler function for browser_wait_for. Waits for a specified time, for text to appear, or for text to disappear.
    handle: async (context, params) => {
      if (!params.text && !params.textGone && !params.time)
        throw new Error('Either time, text or textGone must be provided');
    
      const code: string[] = [];
    
      if (params.time) {
        code.push(`await new Promise(f => setTimeout(f, ${params.time!} * 1000));`);
        await new Promise(f => setTimeout(f, Math.min(10000, params.time! * 1000)));
      }
    
      const tab = context.currentTabOrDie();
      const locator = params.text ? tab.page.getByText(params.text).first() : undefined;
      const goneLocator = params.textGone ? tab.page.getByText(params.textGone).first() : undefined;
    
      if (goneLocator) {
        code.push(`await page.getByText(${JSON.stringify(params.textGone)}).first().waitFor({ state: 'hidden' });`);
        await goneLocator.waitFor({ state: 'hidden' });
      }
    
      if (locator) {
        code.push(`await page.getByText(${JSON.stringify(params.text)}).first().waitFor({ state: 'visible' });`);
        await locator.waitFor({ state: 'visible' });
      }
    
      return {
        code,
        captureSnapshot,
        waitForNetwork: false,
      };
    },
  • Input schema for browser_wait_for defining optional time (seconds), text, and textGone parameters.
    schema: {
      name: 'browser_wait_for',
      title: 'Wait for',
      description: 'Wait for text to appear or disappear or a specified time to pass',
      inputSchema: z.object({
        time: z.coerce.number().optional().describe('The time to wait in seconds'),
        text: z.string().optional().describe('The text to wait for'),
        textGone: z.string().optional().describe('The text to wait for to disappear'),
      }),
      type: 'readOnly',
    },
  • src/tools.ts:35-49 (registration)
    Registration of wait tool (including browser_wait_for) in snapshotTools array via wait(true).
    export const snapshotTools: Tool<any>[] = [
      ...common(true),
      ...console,
      ...dialogs(true),
      ...files(true),
      ...install,
      ...keyboard(true),
      ...navigate(true),
      ...network,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs(true),
      ...testing,
      ...wait(true),
  • src/tools.ts:52-65 (registration)
    Registration of wait tool (including browser_wait_for) in visionTools array via wait(false).
    export const visionTools: Tool<any>[] = [
      ...common(false),
      ...console,
      ...dialogs(false),
      ...files(false),
      ...install,
      ...keyboard(false),
      ...navigate(false),
      ...network,
      ...pdf,
      ...tabs(false),
      ...testing,
      ...vision,
      ...wait(false),
  • ToolSchema type definition used by browser_wait_for schema.
    export type ToolSchema<Input extends InputType> = {
      name: string;
      title: string;
      description: string;
      inputSchema: Input;
      type: 'readOnly' | 'destructive';
    };
    
    type InputType = z.Schema;
    
    export type FileUploadModalState = {
      type: 'fileChooser';
      description: string;
      fileChooser: playwright.FileChooser;
    };
    
    export type DialogModalState = {
      type: 'dialog';
      description: string;
      dialog: playwright.Dialog;
    };
    
    export type ModalState = FileUploadModalState | DialogModalState;
    
    export type ToolActionResult = { content?: (ImageContent | TextContent)[] } | undefined | void;
    
    export type ToolResult = {
      code: string[];
      action?: () => Promise<ToolActionResult>;
      captureSnapshot: boolean;
      waitForNetwork: boolean;
      resultOverride?: ToolActionResult;
    };
    
    export type Tool<Input extends InputType = InputType> = {
      capability: ToolCapability;
      schema: ToolSchema<Input>;
      clearsModalState?: ModalState['type'];
      handle: (context: Context, params: z.output<Input>) => Promise<ToolResult>;
    };
    
    export type ToolFactory = (snapshot: boolean) => Tool<any>;
    
    export function defineTool<Input extends InputType>(tool: Tool<Input>): Tool<Input> {
      return tool;
    }
Behavior3/5

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

Annotations already indicate read-only behavior (readOnlyHint=true, destructiveHint=false). The description adds minimal context (waiting for conditions) but does not specify polling behavior or timeout details. No contradiction with annotations.

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?

A single sentence that is clear and efficient, with no redundancy or unnecessary words.

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

Completeness4/5

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

For a simple read-only tool with three optional parameters and no output schema, the description covers the main use cases. However, it could clarify mutual exclusivity or default behavior, but overall it is adequate.

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?

Input schema has 100% description coverage for all three parameters. The description mentions text appearance/disappearance and time, matching the parameters, but adds no additional meaning beyond what the schema already provides.

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 verb 'wait' and the resource (text appearance/disappearance or a time duration). It is specific and distinguishes from sibling tools like browser_click or browser_navigate.

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 contexts (waiting for text or time) but does not explicitly state when to use this tool versus alternatives like browser_click or browser_fill_form. No exclusions or comparisons 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/cloudflare/playwright-mcp'

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