Skip to main content
Glama

get_text

Extract text content from web elements using CSS selectors for automated testing and content verification.

Instructions

Get the text content of an element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector of the element

Implementation Reference

  • Core implementation of get_text tool: waits for the selector and extracts the textContent of the element using Puppeteer.
    async getText(selector: string) {
        const page = await this.init();
        try {
            await page.waitForSelector(selector, { timeout: 5000 });
            const text = await page.$eval(selector, el => el.textContent);
            return text?.trim() || '';
        } catch (e: any) {
            throw new Error(`Failed to get text from ${selector}: ${e.message}`);
        }
    }
  • src/index.ts:60-70 (registration)
    Tool registration in the TOOLS array: defines name, description, and input schema for listTools response.
    {
        name: "get_text",
        description: "Get the text content of an element",
        inputSchema: {
            type: "object",
            properties: {
                selector: { type: "string", description: "CSS selector of the element" },
            },
            required: ["selector"],
        },
    },
  • Handler dispatcher in CallToolRequestSchema: routes get_text calls to browserManager.getText.
    case "get_text":
        result = await browserManager.getText(String(args?.selector));
        break;
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral context. It states what the tool does but doesn't disclose error handling, performance characteristics, whether it returns formatted/raw text, or if it requires specific page states. This is inadequate for a tool with potential side effects.

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, clear sentence with zero wasted words. It's front-loaded with the core action and resource, making it immediately understandable without unnecessary elaboration.

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 no annotations, no output schema, and a tool that likely interacts with a browser/page context, the description is incomplete. It doesn't explain return values, error conditions, or dependencies on other tools (e.g., 'navigate' first), leaving significant gaps for an AI agent.

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%, so the schema already documents the 'selector' parameter fully. The description adds no additional meaning about parameter usage beyond implying it extracts text from elements matching the selector, which aligns with but doesn't enhance the schema.

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 verb 'Get' and the resource 'text content of an element', making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_console_logs' or explain what type of element it works on (DOM element vs. other).

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 (e.g., needing a page to be loaded), when not to use it, or how it relates to siblings like 'click' or 'navigate'.

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/samusilv/qa-agent-mcp'

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