Skip to main content
Glama
Lokii0911
by Lokii0911

get_attribute

Retrieve the value of a specified DOM attribute from a web element using Selenium. Provide the element strategy, value, and attribute name; optionally set a timeout.

Instructions

Return one DOM attribute for an element.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
strategyYes
valueYes
attributeYes
timeout_secondsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool is registered as an MCP tool via the @mcp.tool() decorator on the get_attribute function. It delegates to browser.get_attribute via the _run helper.
    @mcp.tool()
    def get_attribute(
        strategy: LocatorStrategy,
        value: str,
        attribute: str,
        timeout_seconds: float | None = None,
    ) -> dict[str, str | None]:
        """Return one DOM attribute for an element."""
        return _run("get_attribute", browser.get_attribute, strategy, value, attribute, timeout_seconds)
  • Core handler implementation: finds the element using _wait_for_element, then calls Selenium's element.get_attribute(attribute) and returns the result.
    def get_attribute(
        self,
        strategy: LocatorStrategy,
        value: str,
        attribute: str,
        timeout_seconds: float | None = None,
    ) -> dict[str, str | None]:
        with self._lock:
            element = self._wait_for_element(strategy, value, timeout_seconds)
            return {"attribute": attribute, "value": element.get_attribute(attribute)}
  • Input schema: requires strategy (LocatorStrategy), value (str), attribute (str), and optional timeout_seconds. Returns dict with str or None values.
    def get_attribute(
        strategy: LocatorStrategy,
        value: str,
        attribute: str,
        timeout_seconds: float | None = None,
    ) -> dict[str, str | None]:
  • The _run helper wraps handler calls with error handling for BrowserError and other exceptions.
    def _run(action: str, func: Any, *args: Any, **kwargs: Any) -> Any:
        try:
            return _as_dict(func(*args, **kwargs))
        except BrowserError:
            logger.exception("Browser action failed: %s", action)
            raise
        except Exception as exc:
            logger.exception("Unexpected Selenium MCP error during %s", action)
            raise BrowserError(f"{action} failed: {exc}") from exc
Behavior2/5

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

No annotations are provided, so the description must carry the full burden. It only states the basic function, omitting behavioral traits such as what happens if the element is not found, timeout behavior, or whether the attribute is case-sensitive. This is insufficient for a tool with no annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence, efficiently conveying the core purpose without unnecessary words. However, it could be slightly expanded to include parameter hints without losing conciseness.

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 has 4 parameters and no annotations, the description is too brief. It does not mention the return value type (which is documented in the output schema, but not described), nor does it cover edge cases or error behavior. The simple nature of the tool partially excuses the lack of detail, but it still feels incomplete.

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

Parameters2/5

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

Schema description coverage is 0%, meaning the description adds no meaning beyond the schema. While the schema itself defines strategy, value, attribute, and timeout_seconds clearly, the description does not explain how these parameters interact (e.g., strategy and value locate the element; attribute specifies which attribute to return). The description should compensate for the lack of schema documentation.

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 'Return one DOM attribute for an element' clearly states the action (return) and resource (DOM attribute), distinguishing it from siblings like get_text which returns text content, or find_element which returns the element itself.

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 implies usage when wanting a single DOM attribute, but provides no explicit guidance on when to use this tool versus alternatives (e.g., get_text for text, page_source for full HTML). No exclusions or prerequisites are mentioned.

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/Lokii0911/SeleniumMCP'

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