Skip to main content
Glama
Browser Session MCP

Browser Session MCP

wait_for

Read-only

Waits until a CSS selector matches, specified text appears, or a JavaScript expression is truthy; use after navigate, click, or scroll when content loads asynchronously.

Instructions

Wait until a CSS selector matches an element, a text string appears in the page's visible text, or a JavaScript expression is truthy, in the session's active tab, polling every 100ms; or, with only ms, just pause. Use it after navigate, click or scroll when content loads asynchronously. Pass one of selector, text or expression; selector wins if several are given. ms alone is a plain pause for hosts with no timer of their own. text is a case-sensitive substring of document.body.innerText, so text hidden with CSS doesn't count; it is looked for in frames from other sites too. It reads the page without changing it. Returns which selector or text matched. Fails with a timeout error if nothing matches within timeout, or if neither argument is given.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sessionId": "<sessionId>"
    },
    "name": "wait_for"
  }
}

Input Schema

NameRequiredDescriptionDefault
msNoWith no selector, text or expression: just wait this many milliseconds (at most 25000), for hosts without timers.
textNoText to wait for in document.body.innerText; case-sensitive substring match.
frameNoWith `expression`: run it in the frame whose URL contains this (as evaluate's `frame`).
timeoutNoMilliseconds to wait before failing. Default 10000.
selectorNoCSS selector to wait for.
sessionIdYesThe id returned by open_browser_session. Errors if no open session has it.
expressionNoJavaScript to poll until its value is truthy, run like evaluate (e.g. `window.dataLayer.length > 3`).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.1.23
    • addedInput schema / properties / expression
      Added value: +{
      +  "description": "JavaScript to poll until its value is truthy, run like evaluate (e.g. `window.dataLayer.length > 3`).",
      +  "type": "string"
      +}
    • addedInput schema / properties / frame
      Added value: +{
      +  "description": "With `expression`: run it in the frame whose URL contains this (as evaluate's `frame`).",
      +  "type": "string"
      +}
    • addedInput schema / properties / ms
      Added value: +{
      +  "description": "With no selector, text or expression: just wait this many milliseconds (at most 25000), for hosts without timers.",
      +  "minimum": 1,
      +  "type": "integer"
      +}
  2. Changed4 schema fields changed
    • addedInput schema / properties / selector / description
      Added value: +"CSS selector to wait for."
    • addedInput schema / properties / sessionId / description
      Added value: +"The id returned by open_browser_session. Errors if no open session has it."
    • addedInput schema / properties / text / description
      Added value: +"Text to wait for in document.body.innerText; case-sensitive substring match."
    • addedInput schema / properties / timeout / description
      Added value: +"Milliseconds to wait before failing. Default 10000."
  3. First observedv0.1.2

TDQS

A4/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, and the description reinforces this ('It reads the page without changing it'), so no contradiction. It adds real behavioral detail beyond annotations: 100ms polling cadence, case-sensitive innerText matching that ignores CSS-hidden text, inclusion of cross-site frames, the returned match info, and the timeout failure mode.

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?

Front-loaded with the core purpose, then constraints, then failure modes — logically ordered. It is dense and semicolon-heavy, verging on run-on, but nearly every clause carries actionable information.

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

Completeness5/5

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

Covers the full calling contract for a 7-parameter polling tool: match conditions, precedence, timing limits, return value, and error cases. With no output schema and 100% schema coverage elsewhere, nothing an agent needs in order to call it correctly is missing.

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 coverage is 100%, so the baseline is 3. The description does add genuine precedence semantics not in the schema ('selector wins if several are given', error when neither is supplied) and clarifies `ms` behavior, but it leaves the `frame` interplay and the 25000ms cap mostly to the schema.

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?

Description opens with a precise verb and three concrete match conditions (CSS `selector`, visible `text`, truthy `expression`) plus the pure-pause mode, scoped to 'the session's active tab'. An agent can immediately distinguish this from siblings like `evaluate`, `click`, or `navigate`.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states when to use: 'after navigate, click or scroll when content loads asynchronously', and calls out the `ms`-only case for hosts without timers. It does not spell out when to prefer `evaluate` polling instead, so it stops short of full alternative routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.