Skip to main content
Glama

rescan_elements

Rescan UI elements on a page after content changes caused by navigation, DOM updates, or user interaction. Keeps annotations up to date.

Instructions

Force the annotated page to rescan all UI elements. Use this after the page content has changed (e.g. after navigation, DOM updates, or user interaction).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool handler function for 'rescan_elements'. It calls proxy.rescan() to queue a 'scan' command to the browser, waits 500ms, then returns the count of elements found.
    async () => {
      proxy.rescan();
      // Wait a moment for the scan to complete
      await new Promise(r => setTimeout(r, 500));
      const count = proxy.getElements().length;
      return {
        content: [{
          type: 'text',
          text: `Rescanned page. Found ${count} elements.`,
        }],
      };
    }
  • src/index.js:117-134 (registration)
    Registration of the 'rescan_elements' tool using mcp.tool(). Defines the tool name, description, empty schema (no params), and the handler function.
    // Tool 4: Rescan page elements
    mcp.tool(
      'rescan_elements',
      'Force the annotated page to rescan all UI elements. Use this after the page content has changed (e.g. after navigation, DOM updates, or user interaction).',
      {},
      async () => {
        proxy.rescan();
        // Wait a moment for the scan to complete
        await new Promise(r => setTimeout(r, 500));
        const count = proxy.getElements().length;
        return {
          content: [{
            type: 'text',
            text: `Rescanned page. Found ${count} elements.`,
          }],
        };
      }
    );
  • The proxy.rescan() method which pushes a { type: 'scan' } command to the pendingCommands queue. This command is polled by the browser-side annotator script.
    rescan: () => { pendingCommands.push({ type: 'scan' }); },
  • The client-side handler for the 'scan' command in the browser. When the browser polls commands and receives a scan type, it calls scanElements() and sendElements() to re-scan the DOM and send results back.
    if (cmd.type === 'highlight') highlightByName(cmd.name);
    if (cmd.type === 'scan') { scanElements(); sendElements(); }
  • The scanElements() function on the client side that actually traverses the DOM finding roles, aria-labels, ids, classes, buttons, links, inputs, etc. and building the elements array.
    function scanElements() {
      elements = [];
      const seen = new Set();
    
      // Semantic elements
      document.querySelectorAll('[role], [aria-label], nav, header, footer, main, aside, section, article, form').forEach(el => {
        if (el.closest('[data-ui-annotator]')) return;
        const name = el.getAttribute('aria-label') || el.getAttribute('role') || el.tagName.toLowerCase();
        addElement(el, name, 'semantic', seen);
      });
    
      // Elements with id or class
      document.querySelectorAll('[id], [class]').forEach(el => {
        if (el.closest('[data-ui-annotator]')) return;
        const rect = el.getBoundingClientRect();
        if (rect.width < 20 || rect.height < 10) return;
    
        const id = el.id;
        const cls = el.className && typeof el.className === 'string'
          ? el.className.split(/\\s+/).filter(c => c && !c.startsWith('__')).slice(0, 3).join('.')
          : '';
        const name = id || cls || null;
        if (name) addElement(el, name, id ? 'id' : 'class', seen);
      });
    
      // Interactive elements
      document.querySelectorAll('button, a[href], input, select, textarea').forEach(el => {
        if (el.closest('[data-ui-annotator]')) return;
        const text = (el.textContent || el.getAttribute('placeholder') || el.getAttribute('aria-label') || '').trim().slice(0, 40);
        if (text) addElement(el, text, el.tagName.toLowerCase(), seen);
      });
    }
Behavior2/5

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

No annotations are provided, so the description must carry full burden. It only states the action and usage, but does not disclose behavioral traits such as whether the operation is destructive, requires authentication, or any rate limits. 'Force' hints at mutability but is vague.

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 two sentences long, with the first sentence stating the action and the second providing usage guidance. Every word is purposeful, and the structure is front-loaded.

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?

Given zero parameters and no output schema, the description covers purpose and usage adequately. However, it lacks behavioral transparency (e.g., side effects, idempotency) which reduces completeness for a tool with no annotations.

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?

The input schema has zero parameters, so schema coverage is 100%. The description does not need to add parameter meaning, and the baseline score of 4 is appropriate.

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 action 'force rescan all UI elements' and the resource 'annotated page'. It distinguishes itself from siblings like 'get_elements' (retrieval) and 'annotate' (adding metadata), but does not explicitly name alternatives.

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 description explicitly tells when to use the tool: 'after page content has changed (e.g. after navigation, DOM updates, or user interaction)'. This provides clear context, though it lacks explicit statements on when not to use or named alternatives.

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/mcpware/ui-annotator-mcp'

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