Skip to main content
Glama

Get Attributes

get_attributes
Read-onlyIdempotent

Retrieve a specific HTML attribute or all attributes from a matching element using a CSS or XPath selector. Get values like href, src, or class to inspect page elements.

Instructions

Get a specific HTML attribute (or all attributes) from the selected element. Examples of possible attributes include href, src, value, class, id, name, type, aria-label, etc.

Args: selector: CSS selector or SeleniumBase-supported XPath selector. If multiple elements match, then only the first one is used.

attribute: Specific HTML attribute to retrieve. When omitted, returns
    all HTML attributes of the matching element as a dictionary.

timeout: Maximum seconds to wait for the target element. Default: 5.

Tool selection: - Need one or more HTML attribute values from a specific element -> use this tool. - Need to discover multiple matching elements or inspect their text -> use 'find_elements'. - Need visible text or HTML content -> use 'get_content'. - Need to check element presence/visibility -> use 'check_if_condition'.

If there's no matching element found within the timeout, then @handle_sb_errors returns details from the exception raised.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeoutNo
selectorYes
attributeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.3.2
    • addedInput schema / properties / timeout
      Added value: +{
      +  "default": 5,
      +  "title": "Timeout",
      +  "type": "number"
      +}
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "result": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "additionalProperties": true,
      +          "type": "object"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "title": "Result"
      +    }
      +  },
      +  "required": [
      +    "result"
      +  ],
      +  "title": "get_attributesOutput",
      +  "type": "object"
      +}
  2. Addedv1.2.0

TDQS

A5/5.0
Behavior5/5

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

Beyond the readOnly/idempotent/destructive annotations, the description discloses important behavior: only the first matching element is used, the attribute parameter is optional and returns all attributes as a dictionary when omitted, and timeout/no-match behavior routes to @handle_sb_errors. This adds real operational context.

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 front-loaded with the core purpose, followed by compact parameter explanations and a clear tool-selection list. Every sentence earns its place, and the structure makes it easy for an agent to scan.

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

Completeness5/5

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

For a 3-parameter read tool with an output schema, the description covers the selector type, first-match behavior, attribute semantics, timeout default, and error handling. Nothing essential to invoking the tool correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description fully compensates. It explains selector as CSS or SeleniumBase-supported XPath, attribute as retrievable value or all attributes as a dictionary, and timeout with a default of 5 seconds. Every parameter receives meaningful semantic detail.

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 uses a specific verb and resource: 'get a specific HTML attribute (or all attributes) from the selected element.' It names concrete example attributes and is clearly differentiated from sibling tools like find_elements and get_content in the tool-selection section.

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 ('Need one or more HTML attribute values from a specific element -> use this tool') and when to use alternatives like find_elements, get_content, and check_if_condition. It also clarifies the first-match behavior for multiple elements, leaving little ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.