Skip to main content
Glama
BrowserGenie

BrowserGenie MCP Server

by BrowserGenie

get_accessibility_tree

Retrieve the raw accessibility tree of a web page as structured JSON, optionally filtered by a CSS selector.

Instructions

Get the raw accessibility tree as structured JSON. Companion to browser_snapshot which returns formatted text. Optionally filter to a subtree with a selector.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorNoCSS selector to filter to a subtree
tabIdNoTarget tab ID (defaults to currently active tab)
apiKeyNoAPI key for authentication if enabled

Implementation Reference

  • Registration of the 'get_accessibility_tree' tool on the MCP server. It registers using server.tool() with name 'get_accessibility_tree', description, Zod schema (selector, tabId, apiKey), and an async handler that delegates to bridge.sendCommand.
    server.tool(
      'get_accessibility_tree',
      'Get the raw accessibility tree as structured JSON. Companion to browser_snapshot which returns formatted text. Optionally filter to a subtree with a selector.',
      {
        selector: z.string().optional().describe('CSS selector to filter to a subtree'),
        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, tabId, apiKey }) => {
        const result = await bridge.sendCommand({
          command: 'get_accessibility_tree',
          params: { selector },
          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) }] };
      }
    );
  • Handler function for 'get_accessibility_tree'. It sends a command with name 'get_accessibility_tree' and an optional 'selector' parameter via the WebSocket bridge, then returns the result as formatted JSON.
    async ({ selector, tabId, apiKey }) => {
      const result = await bridge.sendCommand({
        command: 'get_accessibility_tree',
        params: { selector },
        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 'get_accessibility_tree': optional 'selector' (CSS selector string), optional 'tabId' (number), and optional 'apiKey' (string).
    {
      selector: z.string().optional().describe('CSS selector to filter to a subtree'),
      tabId: z.number().optional().describe('Target tab ID (defaults to currently active tab)'),
      apiKey: z.string().optional().describe('API key for authentication if enabled'),
    },
  • WebSocketBridge.sendCommand() which forwards the command (including 'get_accessibility_tree') to the connected Chrome extension via WebSocket and resolves with the response.
    async sendCommand(cmd: BridgeCommand): Promise<BridgeResponse> {
      if (!this.isConnected()) {
        return {
          success: false,
          error: {
            code: 'NOT_CONNECTED',
            message: 'Chrome extension is not connected. Ensure the extension is installed, enabled, and the browser is running.',
          },
        };
      }
    
      const id = crypto.randomUUID();
      const timeout = cmd.timeout ?? DEFAULT_TIMEOUT;
    
      return new Promise<BridgeResponse>((resolve, reject) => {
        const timer = setTimeout(() => {
          this.pending.delete(id);
          resolve({
            success: false,
            error: {
              code: 'TIMEOUT',
              message: `Command '${cmd.command}' timed out after ${timeout}ms`,
            },
          });
        }, timeout);
    
        this.pending.set(id, { resolve, reject, timer });
    
        const message = {
          id,
          type: 'request',
          command: cmd.command,
          params: cmd.params,
          tabId: cmd.tabId,
          apiKey: cmd.apiKey,
          timestamp: Date.now(),
        };
    
        this.client!.send(JSON.stringify(message));
      });
    }
  • Import of registerAccessibilityTools from ./accessibility.js which registers 'get_accessibility_tree' among other tools.
    import { registerAccessibilityTools } from './accessibility.js';
Behavior2/5

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

With no annotations, the description only says the tool returns a JSON representation. It does not disclose whether it is read-only, what happens if the selector is invalid, or any side effects. Minimal behavioral context is provided beyond the output format.

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?

Two sentences with no unnecessary words. The purpose is front-loaded, and the companion mention is concise. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of an accessibility tree and the lack of an output schema, the description is too brief. It does not explain the structure of the returned JSON, performance implications, or behavior when no selector matches. More details are needed for full contextual completeness.

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 coverage is 100% with descriptions for all three parameters. The description adds that a selector can filter a subtree, but does not elaborate on default behavior or error cases. Since the schema already describes the parameters, the baseline of 3 is appropriate.

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 retrieves the raw accessibility tree as structured JSON, distinguishing it from the sibling tool 'browser_snapshot' which returns formatted text. It also mentions optional subtree filtering, providing a specific verb and resource.

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

Usage Guidelines3/5

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

The description provides context by naming the companion tool 'browser_snapshot' and hints at filtering, but it does not explicitly state when to use this tool versus other accessibility-related siblings like 'run_accessibility_audit' or 'get_shadow_dom_tree'. There are no exclusions or when-not-to-use guidance.

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