Skip to main content
Glama
BrowserGenie

BrowserGenie MCP Server

by BrowserGenie

get_element_layout

Get bounding rectangles, overflow, z-index, position, display, visibility, and opacity for a specific element or all visible elements on the page.

Instructions

Get layout information for a specific element or all visible elements on the page. Returns bounding rectangles, overflow, z-index, position, display, visibility, and opacity.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorNoCSS selector for a specific element
includeAllNoReturn layout for all visible elements (default: false)
tabIdNoTarget tab ID (defaults to currently active tab)
apiKeyNoAPI key for authentication if enabled

Implementation Reference

  • The MCP tool handler for 'get_element_layout'. It accepts a CSS selector, includeAll flag, tabId, and apiKey, sends a 'get_element_layout' command via the WebSocket bridge to a Chrome extension, and returns the result as formatted JSON.
    server.tool(
      'get_element_layout',
      'Get layout information for a specific element or all visible elements on the page. Returns bounding rectangles, overflow, z-index, position, display, visibility, and opacity.',
      {
        selector: z.string().optional().describe('CSS selector for a specific element'),
        includeAll: z.boolean().optional().describe('Return layout for all visible elements (default: false)'),
        tabId: z.number().optional().describe('Target tab ID (defaults to currently active tab)'),
        apiKey: z.string().optional().describe('API key for authentication if enabled'),
      },
      async ({ selector, includeAll, tabId, apiKey }) => {
        const result = await bridge.sendCommand({
          command: 'get_element_layout',
          params: { selector, includeAll },
          tabId,
          apiKey,
          timeout: LONG_TIMEOUT,
        });
        if (!result.success) {
          return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true };
        }
        return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
      }
    );
  • Input schema for the 'get_element_layout' tool: optional selector (string), includeAll (boolean), tabId (number), and apiKey (string).
    {
      selector: z.string().optional().describe('CSS selector for a specific element'),
      includeAll: z.boolean().optional().describe('Return layout for all visible elements (default: false)'),
      tabId: z.number().optional().describe('Target tab ID (defaults to currently active tab)'),
      apiKey: z.string().optional().describe('API key for authentication if enabled'),
    },
  • Tool registration via server.tool() with name 'get_element_layout' inside registerAccessibilityTools function, which is called from registerAllTools in src/tools/index.ts.
    server.tool(
      'get_element_layout',
      'Get layout information for a specific element or all visible elements on the page. Returns bounding rectangles, overflow, z-index, position, display, visibility, and opacity.',
      {
        selector: z.string().optional().describe('CSS selector for a specific element'),
        includeAll: z.boolean().optional().describe('Return layout for all visible elements (default: false)'),
        tabId: z.number().optional().describe('Target tab ID (defaults to currently active tab)'),
        apiKey: z.string().optional().describe('API key for authentication if enabled'),
      },
      async ({ selector, includeAll, tabId, apiKey }) => {
        const result = await bridge.sendCommand({
          command: 'get_element_layout',
          params: { selector, includeAll },
          tabId,
          apiKey,
          timeout: LONG_TIMEOUT,
        });
        if (!result.success) {
          return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true };
        }
        return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
      }
    );
Behavior3/5

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

With no annotations, the description partially covers behavior by listing returned properties, but it does not disclose potential side effects, performance implications, whether it works on dynamic content, or if it requires page to be fully loaded. The default return behavior when no parameters are provided (likely returns for all visible) is implied but not explicit.

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 primary purpose, and contains no redundant information. Every word contributes to understanding.

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 basic purpose and return values, but given no output schema, it lacks details on the structure of the return (e.g., an array of objects or single object) and whether results are live or static. It also does not address edge cases like invisible elements or missing elements.

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?

All 4 parameters have descriptions in the schema (100% coverage). The description adds context by explaining the purpose of selector and includeAll in relation to 'specific element or all visible', and lists the returned properties, which helps the agent understand parameter usage beyond 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?

The description clearly states the action (get), resource (layout information), and scope (specific element or all visible elements). It specifies the returned values (bounding rectangles, etc.), which distinguishes it from sibling tools like get_computed_styles or get_element_state.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like get_computed_styles or get_element_state. No when-not or prerequisite conditions are mentioned, leaving the agent to infer usage context.

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/BrowserGenie/mcp'

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