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,

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