Skip to main content
Glama
AdsPower

AdsPower LocalAPI MCP Server

Official

get-page-visible-text

Extract visible text content from web pages to analyze displayed information for browser automation tasks.

Instructions

Get the visible text content of the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for 'get-page-visible-text' tool. It evaluates JavaScript on the current page using Puppeteer's evaluate method to traverse the DOM with TreeWalker, collecting text from visible nodes (display != none, visibility != hidden), trims and joins them with newlines.
    async getPageVisibleText() { browser.checkConnected(); try { const visibleText = await browser.pageInstance!.evaluate(() => { const walker = document.createTreeWalker( document.body, NodeFilter.SHOW_TEXT, { acceptNode: (node) => { const style = window.getComputedStyle( node.parentElement! ); return style.display !== 'none' && style.visibility !== 'hidden' ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT; }, } ); let text = ''; let node; while ((node = walker.nextNode())) { const trimmedText = node.textContent?.trim(); if (trimmedText) { text += trimmedText + '\n'; } } return text.trim(); }); return `Visible text content:\n${visibleText}`; } catch (error) { return `Failed to get visible text content: ${(error as Error).message}`; } },
  • Registers the 'get-page-visible-text' tool on the MCP server, using empty input schema and the wrapped automationHandlers.getPageVisibleText handler.
    server.tool('get-page-visible-text', 'Get the visible text content of the page', schemas.emptySchema.shape, wrapHandler(automationHandlers.getPageVisibleText));
  • The emptySchema used as input schema for 'get-page-visible-text' tool (no parameters required), defined using Zod.
    // Empty Schema emptySchema: z.object({}).strict(),

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/AdsPower/local-api-mcp-typescript'

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