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;

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