Skip to main content
Glama

browser_get_visible_text

Extract visible text from web pages using an automation tool designed to bypass anti-bot detection, enabling reliable scraping and testing on protected sites.

Instructions

Get the visible text of the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for 'browser_get_visible_text' tool. It is registered via @mcp.tool() decorator. Executes JavaScript to collect and join visible text content from all elements on the page that are not hidden.
    @mcp.tool() async def browser_get_visible_text(): """Get the visible text of the current page""" async def get_visible_text_handler(driver: uc.Chrome): # 使用JavaScript获取页面中所有可见文本内容 script = """ return Array.from(document.body.querySelectorAll('*')) .filter(el => { const style = window.getComputedStyle(el); return !!(el.textContent.trim()) && style.display !== 'none' && style.visibility !== 'hidden' && style.opacity !== '0'; }) .map(el => el.textContent.trim()) .filter(text => text) .join('\\n'); """ visible_text = driver.execute_script(script) return await create_success_response(visible_text) return await tool.safe_execute( ToolContext(webdriver=await ensure_browser()), get_visible_text_handler )
  • Registration of the 'browser_get_visible_text' tool using FastMCP's @mcp.tool() decorator.
    @mcp.tool()

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/dragons96/mcp-undetected-chromedriver'

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