Skip to main content
Glama

get_text

Extract text content from web elements using CSS selectors for browser automation and web scraping tasks.

Instructions

Get text content from an element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for the element

Implementation Reference

  • Registration of the 'get_text' tool in the Playwright tools array, including name, description, input schema, and handler function that delegates to browser.getText()
    {
      name: 'get_text',
      description: 'Get text content from an element',
      inputSchema: {
        type: 'object',
        properties: {
          selector: { type: 'string', description: 'CSS selector for the element' }
        },
        required: ['selector']
      },
      handler: async ({ selector }) => {
        const text = await browser.getText(selector);
        return { success: true, data: { text }, message: `Got text from ${selector}` };
      }
    },
  • Core implementation of getText method in SimpleBrowser class using Playwright's page.textContent to extract text from the specified selector
    async getText(selector) {
      await this.ensureLaunched();
      return await this.page.textContent(selector);
    }
  • index.js:74-76 (registration)
    Main registration point where createTools is called to include 'get_text' (via playwrightTools) in the MCP server's tools list used for listTools and callTool requests
    // Register all available automation tools
    const tools = createTools(browser);
  • Input schema definition for the 'get_text' tool requiring a CSS selector
    inputSchema: {
      type: 'object',
      properties: {
        selector: { type: 'string', description: 'CSS selector for the element' }
      },
      required: ['selector']
    },
  • tools.js:17-21 (registration)
    Combines playwrightTools (including get_text) with other tools into the main tools array for MCP server registration
    export function createTools(browser) {
      const playwrightTools = createPlaywrightTools(browser);
    
      return [
        ...playwrightTools,
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. While 'Get text content' implies a read-only operation, it doesn't specify what happens if the selector doesn't match (e.g., error, null return), whether it waits for the element to exist, or the format of returned text. For a tool with no annotation coverage, this leaves significant behavioral gaps.

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 wasted words. It's front-loaded with the core purpose ('Get text content from an element'), making it immediately scannable. Every word earns its place, and there's no redundant or verbose phrasing.

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 moderate complexity (interacting with web elements) and lack of annotations and output schema, the description is insufficient. It doesn't explain return values (e.g., string format, error cases), behavioral expectations, or integration with sibling tools like wait_for. For a tool that likely operates in a browser automation context, more context is needed for effective 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 the single parameter 'selector' clearly documented as 'CSS selector for the element' in the schema. The description adds no additional parameter information beyond what the schema provides, such as examples of valid selectors or constraints. With high schema coverage, the baseline score of 3 is appropriate.

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 text content from an element' clearly states the verb ('Get') and resource ('text content from an element'), making the tool's function immediately understandable. It distinguishes from siblings like get_title (gets page title) and get_url (gets page URL) by specifying element text extraction. However, it doesn't explicitly mention it's for web page elements, which could be inferred from sibling tools but isn't stated.

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. There's no mention of prerequisites (e.g., needing a page to be loaded), comparison with similar tools like get_title or snapshot, or when not to use it (e.g., for non-text elements). The agent must infer usage from the tool name and sibling 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/zypin-testing/zypin-mcp'

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