Skip to main content
Glama

browser_get_element_attribute

Retrieve attribute values from web page elements using selectors for automated browser testing and data extraction.

Instructions

Get element attribute value

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instanceIdYesInstance ID
selectorYesElement selector
attributeYesAttribute name
timeoutNoTimeout in milliseconds

Implementation Reference

  • The main handler function for the 'browser_get_element_attribute' tool. It retrieves the browser instance, locates the element using the selector, fetches the specified attribute value using Playwright's page.getAttribute method, and returns the result or error.
    private async getElementAttribute(instanceId: string, selector: string, attribute: string, timeout: number): Promise<ToolResult> {
      const instance = this.browserManager.getInstance(instanceId);
      if (!instance) {
        return { success: false, error: `Instance ${instanceId} not found` };
      }
    
      try {
        const value = await instance.page.getAttribute(selector, attribute, { timeout });
        return {
          success: true,
          data: { selector, attribute, value },
          instanceId
        };
      } catch (error) {
        return {
          success: false,
          error: `Get element attribute failed: ${error instanceof Error ? error.message : error}`,
          instanceId
        };
      }
    }
  • src/tools.ts:330-356 (registration)
    The tool registration in getTools(), defining the name, description, and inputSchema for 'browser_get_element_attribute'.
    {
      name: 'browser_get_element_attribute',
      description: 'Get element attribute value',
      inputSchema: {
        type: 'object',
        properties: {
          instanceId: {
            type: 'string',
            description: 'Instance ID'
          },
          selector: {
            type: 'string',
            description: 'Element selector',
          },
          attribute: {
            type: 'string',
            description: 'Attribute name',
          },
          timeout: {
            type: 'number',
            description: 'Timeout in milliseconds',
            default: 30000
          }
        },
        required: ['instanceId', 'selector', 'attribute']
      }
    },
  • src/tools.ts:559-560 (registration)
    The dispatch case in executeTools() that routes calls to the getElementAttribute handler.
    case 'browser_get_element_attribute':
      return await this.getElementAttribute(args.instanceId, args.selector, args.attribute, args.timeout || 30000);
  • The input schema defining parameters for the tool: instanceId, selector, attribute (required), and optional timeout.
    inputSchema: {
      type: 'object',
      properties: {
        instanceId: {
          type: 'string',
          description: 'Instance ID'
        },
        selector: {
          type: 'string',
          description: 'Element selector',
        },
        attribute: {
          type: 'string',
          description: 'Attribute name',
        },
        timeout: {
          type: 'number',
          description: 'Timeout in milliseconds',
          default: 30000
        }
      },
      required: ['instanceId', 'selector', 'attribute']
    }
Behavior2/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 of behavioral disclosure. 'Get element attribute value' implies a read-only operation, but it doesn't disclose critical behaviors: that it requires a valid browser instance (instanceId), may fail if the element isn't found or times out, or returns a string/null value. For a tool with 4 parameters and no annotation coverage, this leaves significant gaps in understanding how it behaves in practice.

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 a single, efficient phrase ('Get element attribute value') that front-loads the core purpose with zero wasted words. Every term earns its place: 'Get' specifies the action, 'element attribute' identifies the target, and 'value' clarifies the output. It's appropriately sized for a straightforward tool.

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 tool's complexity (4 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the return value (e.g., string or null), error conditions (e.g., if element not found), or dependencies (requires an active browser instance). For a browser interaction tool with multiple parameters, this minimal description leaves too much unspecified for reliable agent use.

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%, with all parameters clearly documented in the schema (instanceId, selector, attribute, timeout). The description adds no additional meaning beyond what the schema provides—it doesn't explain what an 'element attribute' is, provide examples of selectors or attribute names, or clarify the timeout behavior. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get element attribute value' clearly states the verb ('Get') and resource ('element attribute value'), making the purpose immediately understandable. It distinguishes itself from siblings like browser_get_element_text (which gets text content) and browser_wait_for_element (which waits for existence). However, it doesn't specify that this operates on a browser instance, which is implied but not explicit.

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. It doesn't mention prerequisites (like needing an existing browser instance), when not to use it (e.g., for text content vs. attributes), or refer to sibling tools like browser_get_element_text for different element properties. The agent must infer usage from the tool name and context alone.

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/sailaoda/concurrent-browser-mcp'

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