Skip to main content
Glama

inspect_mode

Toggle inspect mode on annotated pages to click any element and copy its name for communicating design changes. Disable to restore normal page behavior.

Instructions

Toggle inspect mode on the annotated page. When ON, the user can click any element to copy its name. When OFF, the page behaves normally. Use this to help the user copy element names for communicating design changes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
enabledYestrue to enable inspect mode, false to disable

Implementation Reference

  • MCP tool handler for 'inspect_mode'. Receives an `enabled` boolean parameter and calls proxy.inspectOn() or proxy.inspectOff() to toggle inspect mode on the annotated page.
    // Tool 5: Toggle inspect mode
    mcp.tool(
      'inspect_mode',
      'Toggle inspect mode on the annotated page. When ON, the user can click any element to copy its name. When OFF, the page behaves normally. Use this to help the user copy element names for communicating design changes.',
      {
        enabled: z.boolean().describe('true to enable inspect mode, false to disable'),
      },
      async ({ enabled }) => {
        if (enabled) {
          proxy.inspectOn();
        } else {
          proxy.inspectOff();
        }
        return {
          content: [{
            type: 'text',
            text: enabled
              ? 'Inspect mode ON. The user can now click any element to copy its name. A toolbar indicator shows the mode is active.'
              : 'Inspect mode OFF. Page is back to normal interactive mode.',
          }],
        };
      }
    );
  • Proxy methods inspectOn() and inspectOff() push commands ('inspect_on' / 'inspect_off') into the pendingCommand queue, which the browser polls.
        inspectOn: () => { pendingCommands.push({ type: 'inspect_on' }); },
        inspectOff: () => { pendingCommands.push({ type: 'inspect_off' }); },
        listen: (port) => new Promise((resolve) => {
          server.listen(port, () => resolve(port));
        }),
      };
    }
  • Client-side polling handler that processes 'inspect_on' and 'inspect_off' commands received from the server, toggling the local inspect mode state.
            if (cmd.type === 'inspect_on') setInspectMode(true);
            if (cmd.type === 'inspect_off') setInspectMode(false);
          }
        })
        .catch(() => {})
        .finally(() => setTimeout(pollCommands, 1000));
    }
  • Client-side setInspectMode() function that updates the UI: changes the toolbar button styling, cursor, overlay border, and subtitle text to indicate inspect mode is active/inactive.
    function setInspectMode(on) {
      inspectMode = on;
      if (on) {
        inspectBtn.style.background = '#e11d48';
        inspectBtn.style.color = '#fff';
        inspectBtn.style.borderColor = '#e11d48';
        inspectBtn.innerHTML = '<span style="font-size:14px;vertical-align:middle">🔍</span> Inspect ON';
        document.body.style.cursor = 'crosshair';
        overlay.style.borderColor = '#e11d48';
        subtitle.textContent = 'Click any element to copy its name to clipboard';
        subtitle.style.color = '#059669';
      } else {
        inspectBtn.style.background = 'transparent';
        inspectBtn.style.color = '#94a3b8';
        inspectBtn.style.borderColor = 'rgba(255,255,255,.15)';
        inspectBtn.innerHTML = '<span style="font-size:14px;vertical-align:middle">🔍</span> Inspect';
        document.body.style.cursor = '';
        overlay.style.borderColor = '#e11d48';
        subtitle.textContent = 'Enable to click any element and copy its name';
        subtitle.style.color = '#c8cdd5';
      }
    }
  • Client-side click handler that, when inspectMode is true, intercepts clicks, prevents default, and copies the hovered element's name to the clipboard.
    document.addEventListener('click', (e) => {
      if (!inspectMode) return;
      if (e.target.closest('[data-ui-annotator]')) return;
    
      e.preventDefault();
      e.stopPropagation();
      e.stopImmediatePropagation();
    
      if (hoveredInfo) {
        navigator.clipboard.writeText(hoveredInfo.name).then(() => {
          showCopied(hoveredInfo.name);
        }).catch(() => {
          // Fallback for non-HTTPS
          const ta = document.createElement('textarea');
          ta.value = hoveredInfo.name;
          ta.style.cssText = 'position:fixed;opacity:0';
          document.body.appendChild(ta);
          ta.select();
          document.execCommand('copy');
          ta.remove();
          showCopied(hoveredInfo.name);
        });
      }
    }, true); // capture phase — intercept before page handlers
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It explains the tool's core behavior (enabling/disabling inspect mode and clicking to copy names) but does not disclose potential side effects, persistence, or permissions. For a simple toggle, this is adequate but not exceptional.

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 consists of three concise sentences that front-load the main action, explain the ON/OFF behaviors, and state the use case. Every sentence adds value with no redundancy.

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?

Given the simplicity of the tool (single boolean parameter, no output schema), the description covers the essential aspects: purpose, behavior, and usage scenario. It lacks details like whether the mode persists across page loads, but overall it is fairly complete for its complexity.

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 description coverage is 100%, so the baseline is 3. The description does not add additional meaning to the 'enabled' parameter beyond what the schema already provides (true/false). The purpose is conveyed but parameter semantics are not enriched.

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 tool toggles inspect mode and explains the behavior in both ON and OFF states. It is specific about the verb 'toggle' and the resource 'inspect mode', and the differentiation from sibling tools (annotate, get_elements, etc.) is implicit as they serve different functions.

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 advises to use this tool to help the user copy element names for design change communication. While it does not explicitly list exclusion criteria or alternatives, the context from sibling tools provides sufficient guidance on when to use this tool versus others.

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