Skip to main content
Glama

pilot_page_attrs

Extract all element attributes as structured JSON data using element references or CSS selectors for browser automation tasks.

Instructions

Get all attributes of an element as JSON.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refYesElement ref or CSS selector

Implementation Reference

  • The handler implementation for the 'pilot_page_attrs' tool, which uses a Playwright locator to evaluate and retrieve all attributes of the targeted DOM element and returns them as a JSON string.
    server.tool(
      'pilot_page_attrs',
      'Get all attributes of an element as JSON.',
      { ref: z.string().describe('Element ref or CSS selector') },
      async ({ ref }) => {
        await bm.ensureBrowser();
        try {
          const page = bm.getPage();
          const resolved = await bm.resolveRef(ref);
          const locator = 'locator' in resolved ? resolved.locator : page.locator(resolved.selector);
          const attrs = await locator.evaluate((el) => {
            const result: Record<string, string> = {};
            for (const attr of el.attributes) {
              result[attr.name] = attr.value;
            }
            return result;
          });
          return { content: [{ type: 'text' as const, text: JSON.stringify(attrs, null, 2) }] };
        } catch (err) {
          return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
        }
      }
    );
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but only specifies the output format (JSON). It omits error handling (what happens if the ref doesn't match?), whether this returns all HTML attributes or data-* properties only, and whether the operation is atomic or has side effects. The 'Get' verb implies read-only, but safety characteristics are not explicit.

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 sentence with zero filler. It front-loads the action ('Get') and packs both the operation scope ('all attributes of an element') and return format ('as JSON') into nine words. For a single-parameter tool, this length is appropriate.

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

Completeness3/5

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

Given the tool's low complexity (one required parameter, 100% schema coverage), the description is minimally viable. However, lacking an output schema, the description should ideally elaborate on the JSON structure returned (e.g., key-value pairs of attribute names/values) and mention error cases. It meets basics but leaves gaps an agent needs for robust usage.

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?

With 100% schema description coverage on the single 'ref' parameter ('Element ref or CSS selector'), the description meets the baseline. However, it adds no additional semantic value beyond the schema—no examples of valid CSS selectors, no explanation of what constitutes an 'Element ref' versus a selector, and no clarification on multi-element matching behavior.

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 clearly states the tool retrieves ("Get") element attributes and specifies the output format ("as JSON"). It effectively distinguishes from siblings like pilot_page_html (full markup) and pilot_page_text (content extraction), though it could be more explicit about targeting HTML attributes specifically to differentiate from pilot_element_state or pilot_page_css.

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. For example, it doesn't clarify when to prefer this over pilot_page_html (full element outerHTML), pilot_element_state (visibility/enabled status), or pilot_page_css (computed styles), which is critical given the dense sibling namespace of browser automation tools.

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/TacosyHorchata/Pilot'

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