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(),
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 only states what the tool does, not how it behaves. It doesn't disclose whether this is a read-only operation, if it requires specific page states, potential latency, or error conditions. For a tool with zero 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 that front-loads the core purpose with zero wasted words. It's appropriately sized for a simple tool and earns its place by clearly conveying the action and target.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no output schema), the description is minimally adequate but lacks depth. It doesn't explain what 'visible text' entails (e.g., excludes hidden elements) or the return format, leaving the agent to infer behavior. With no annotations, it should provide more context for completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the lack of inputs. The description doesn't need to add parameter details, and it appropriately avoids mentioning any. Baseline for 0 parameters is 4, as it doesn't mislead about inputs.

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 resource ('visible text content of the page'), making the purpose immediately understandable. It distinguishes from siblings like 'get-page-html' by specifying 'visible text' rather than HTML markup. However, it doesn't explicitly contrast with all siblings, keeping it at a 4 rather than a 5.

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 like 'get-page-html' or 'evaluate-script'. It lacks context about prerequisites (e.g., needing an open browser page) or exclusions, offering minimal usage direction beyond the basic purpose.

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

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