Skip to main content
Glama

get_elements

Retrieve UI element details from annotated web pages to identify components users describe, providing names, selectors, positions, and sizes.

Instructions

Get all UI elements detected on the currently annotated page. Returns element names, CSS selectors, positions, and sizes. Use this to understand what the user is referring to when they describe a UI element.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.js:60-97 (registration)
    The MCP tool 'get_elements' is registered in src/index.js. It calls proxy.getElements() to retrieve elements and formats the output for the user.
    mcp.tool(
      'get_elements',
      'Get all UI elements detected on the currently annotated page. Returns element names, CSS selectors, positions, and sizes. Use this to understand what the user is referring to when they describe a UI element.',
      {},
      async () => {
        const els = proxy.getElements();
        if (els.length === 0) {
          return {
            content: [{
              type: 'text',
              text: 'No elements detected. Make sure the user has opened the annotated proxy URL in their browser. Use the annotate tool first to get the proxy URL.',
            }],
          };
        }
    
        // Group elements by source type for readability
        const grouped = {};
        for (const el of els) {
          const key = el.source || 'other';
          if (!grouped[key]) grouped[key] = [];
          grouped[key].push(el);
        }
    
        let output = `Found ${els.length} UI elements on the page:\n\n`;
    
        for (const [source, items] of Object.entries(grouped)) {
          output += `## ${source.toUpperCase()} (${items.length})\n`;
          for (const el of items) {
            output += `- **${el.name}** — \`${el.selector}\` (${el.rect.w}×${el.rect.h}px at ${el.rect.x},${el.rect.y})`;
            if (el.text && el.text !== el.name) output += ` "${el.text.slice(0, 50)}"`;
            output += '\n';
          }
          output += '\n';
        }
    
        return { content: [{ type: 'text', text: output }] };
      }
    );
  • The underlying implementation of proxy.getElements(), which simply returns the currentElements array in src/proxy.js.
    getElements: () => currentElements,
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 describes the return data (names, selectors, positions, sizes) and implies it's a read-only operation, but lacks details on permissions, rate limits, or error handling. The description adds some behavioral context but is incomplete for a tool with no annotations.

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, front-loaded with the tool's purpose and followed by usage guidance. Every sentence earns its place by providing essential information without redundancy, making it highly efficient and well-structured.

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 tool's complexity (0 parameters, no output schema, no annotations), the description is mostly complete. It explains what the tool does and when to use it, but lacks details on behavioral traits like error handling or performance, which would be beneficial for full completeness.

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 0 parameters with 100% coverage, so no parameter documentation is needed. The description does not discuss parameters, which is appropriate, and adds value by explaining the tool's purpose and usage, justifying a score above the baseline of 3.

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 specific action ('Get all UI elements detected'), resource ('on the currently annotated page'), and output details ('element names, CSS selectors, positions, and sizes'). It effectively distinguishes from sibling tools like 'annotate', 'highlight_element', 'inspect_mode', and 'rescan_elements' by focusing on retrieval rather than modification or scanning.

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool: 'to understand what the user is referring to when they describe a UI element.' This provides clear context for its application, distinguishing it from siblings that might modify or scan elements, though it does not name specific 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