Skip to main content
Glama

observe

Watch an element for text or attribute changes and wait until a specified condition to trigger a click, replacing manual MutationObserver or polling code.

Instructions

Watch an element for changes instead of polling with MutationObserver/setInterval code in evaluate. collect: record text/attribute changes for 'duration' ms. until: wait for a condition, then optionally click at once (then_click). click_first fires the triggering action after the observer is armed, so nothing is missed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
untilNoJS expression checked on each change, 'el' is the element, e.g. el.textContent === '8'
collectNotext (textContent) | attributes | alltext
timeoutNoMax observation time in ms (max 25000)
durationNoCollect window in ms (default 5000); exclusive with until
intervalNoPolling fallback interval in ms
selectorYesCSS selector or ref of the element to observe
then_clickNoSelector or ref to click immediately when until holds
click_firstNoSelector or ref to click once the observer is armed

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed10 schema fields changedv2.10.5
    • removedInput schema / $schema
      Removed value: -"http://json-schema.org/draft-07/schema#"
    • removedInput schema / additionalProperties
      Removed value: -false
    • changedInput schema / properties / click_first / description
      Previous value: -"CSS selector or element ref (e.g. 'e5') to click AFTER the observer is set up but BEFORE collection starts. Use to trigger the changes you want to observe (e.g. 'Start Mutations' button)."New value: +"Selector or ref to click once the observer is armed"
    • changedInput schema / properties / collect / description
      Previous value: -"What to collect: 'text' for textContent changes, 'attributes' for attribute changes, 'all' for both (default: 'text')"New value: +"text (textContent) | attributes | all"
    • changedInput schema / properties / duration / description
      Previous value: -"Collect all changes for this many ms, then return them. Mutually exclusive with 'until'. Default: 5000"New value: +"Collect window in ms (default 5000); exclusive with until"
    • changedInput schema / properties / interval / description
      Previous value: -"Polling interval in ms for change detection fallback (default: 100)"New value: +"Polling fallback interval in ms"
    • changedInput schema / properties / selector / description
      Previous value: -"CSS selector or element ref (e.g. 'e5') of the element to observe"New value: +"CSS selector or ref of the element to observe"
    • changedInput schema / properties / then_click / description
      Previous value: -"CSS selector or element ref (e.g. 'e5') to click immediately when 'until' condition is met (for timing-critical actions). Only used with 'until'."New value: +"Selector or ref to click immediately when until holds"
    • changedInput schema / properties / timeout / description
      Previous value: -"Maximum observation time in ms (default: 10000, max: 25000)"New value: +"Max observation time in ms (max 25000)"
    • changedInput schema / properties / until / description
      Previous value: -"JS expression evaluated on each change — stops when it returns true. Variable 'el' is the observed element. Example: el.textContent === '8'"New value: +"JS expression checked on each change, 'el' is the element, e.g. el.textContent === '8'"
  2. First observedv2.7.0

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations provided, the description carries the full disclosure burden, and it delivers meaningfully: it reveals two distinct operational modes (collect and until), the click-ordering guarantee ('click_first fires the triggering action after the observer is armed, so nothing is missed'), and the optional then_click behavior. It stops short of noting the internal polling fallback behind the interval parameter, though the schema documents that parameter.

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?

Three sentences with the main purpose front-loaded in sentence one, followed by compact mode explanations. Every sentence earns its place; the 'so nothing is missed' clause captures an important ordering guarantee in four words without padding.

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?

The description covers the two execution modes and the click behaviors well, but the tool has no output schema and the description never states what the tool returns after a collect window or when an until condition fires. Constraint details like duration/until exclusivity and the polling-fallback behavior are left entirely to the schema. For an 8-parametter tool with zero annotations, this is adequate but not complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, giving a baseline of 3, and the description adds genuine value on top of the schema: it connects collect to duration, until to then_click, and clarifies the intent of click_first ('fires the triggering action after the observer is armed'). This conceptual grouping makes the parameter model understandable in a way the flat per-parameter schema descriptions alone do not.

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?

States a specific action (watch an element for changes) on a specific resource (a DOM element via selector), and immediately distinguishes itself from the sibling evaluate tool ('instead of polling with MutationObserver/setInterval code in evaluate'). A new agent can tell what this tool does and how it differs from evaluate without opening the schema.

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?

The opening line gives a clear when-to-use signal: prefer this tool over hand-written MutationObserver/setInterval polling inside evaluate, which is a concrete alternative. However, the 'until' mode functionally overlaps with the sibling wait_for tool, and the description never mentions that alternative or states when not to use observe, so the routing guidance is incomplete.

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