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
| Name | Required | Description | Default |
|---|---|---|---|
| selector | No | CSS selector for a specific element | |
| includeAll | No | Return layout for all visible elements (default: false) | |
| tabId | No | Target tab ID (defaults to currently active tab) | |
| apiKey | No | API key for authentication if enabled |
Implementation Reference
- src/tools/accessibility.ts:29-51 (handler)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) }] }; } ); - src/tools/accessibility.ts:32-37 (schema)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'), }, - src/tools/accessibility.ts:29-51 (registration)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) }] }; } );