Skip to main content
Glama

wait

Pauses execution for a specified duration to allow web pages to finish loading or rendering dynamic content, ensuring complete page elements appear in screenshots.

Instructions

Use this tool when a page appears to be loading or not fully rendered. Common scenarios include: when elements are missing from a screenshot that should be there, when a page looks incomplete or broken, when dynamic content is still loading, or when a previous action (like clicking a button) hasn't fully processed yet. Waits for a specified number of seconds (up to 10) to allow the page to finish loading or rendering.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
secondsYesNumber of seconds to wait (max 10). Start with a smaller value (2-3 seconds) and increase if needed.

Implementation Reference

  • The handler function for the "wait" tool. Validates the seconds parameter (0-10), sleeps for the specified duration using the sleep utility, and returns a success message.
    async function handleWait(_page: Page, args: any): Promise<CallToolResult> {
      const { seconds } = args;
      if (typeof seconds !== "number" || seconds < 0 || seconds > 10) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: "Wait time must be a number between 0 and 10 seconds",
            },
          ],
        };
      }
    
      await sleep(seconds * 1000); // Reusing your sleep utility
      return {
        isError: false,
        content: [{ type: "text", text: `Waited ${seconds} second(s).` }],
      };
    }
  • The schema definition for the "wait" tool in the TOOLS array, defining the input schema with a required 'seconds' number parameter (0-10).
      name: "wait",
      description:
        "Use this tool when a page appears to be loading or not fully rendered. Common scenarios include: when elements are missing from a screenshot that should be there, when a page looks incomplete or broken, when dynamic content is still loading, or when a previous action (like clicking a button) hasn't fully processed yet. Waits for a specified number of seconds (up to 10) to allow the page to finish loading or rendering.",
      inputSchema: {
        type: "object",
        properties: {
          seconds: {
            type: "number",
            description:
              "Number of seconds to wait (max 10). Start with a smaller value (2-3 seconds) and increase if needed.",
            minimum: 0,
            maximum: 10,
          },
        },
        required: ["seconds"],
      },
    },
  • Helper utility function 'sleep' that pauses execution for a given number of milliseconds using setTimeout. Used by the wait handler.
    function sleep(ms: number): Promise<void> {
      return new Promise(resolve => setTimeout(resolve, ms));
    }
  • src/index.ts:937-939 (registration)
    Registration of the 'wait' tool handler in the main tool dispatcher switch statement within handleToolCall.
    case "wait":
      result = await handleWait(page, args);
      break;
  • src/index.ts:1068-1070 (registration)
    Server handler for ListToolsRequestSchema that returns the TOOLS array, which includes the 'wait' tool definition.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: TOOLS,
    }));

Tool Definition Quality

Score is being calculated. Check back soon.

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/steel-dev/steel-mcp-server'

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