Skip to main content
Glama

playwright_get_visible_html

Extract the visible HTML content of a web page using a real browser environment to enable tasks like scraping, testing, or web interaction through Playwright MCP Server.

Instructions

Get the HTML content of the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler implementation in VisibleHtmlTool.execute() method, which fetches the full HTML content of the current page using Playwright's page.content() and returns it wrapped in a success response.
    export class VisibleHtmlTool extends BrowserToolBase { /** * Execute the visible HTML page tool */ async execute(args: any, context: ToolContext): Promise<ToolResponse> { // Check if browser is available if (!context.browser || !context.browser.isConnected()) { // If browser is not connected, we need to reset the state to force recreation resetBrowserState(); return createErrorResponse( "Browser is not connected. The connection has been reset - please retry your navigation." ); } // Check if page is available and not closed if (!context.page || context.page.isClosed()) { return createErrorResponse( "Page is not available or has been closed. Please retry your navigation." ); } return this.safeExecute(context, async (page) => { try { const htmlContent = await page!.content(); return createSuccessResponse(`HTML content:\n${htmlContent}`); } catch (error) { return createErrorResponse(`Failed to get visible HTML content: ${(error as Error).message}`); } }); } }
  • Tool schema definition specifying the name, description, and empty input schema for playwright_get_visible_html.
    name: "playwright_get_visible_html", description: "Get the HTML content of the current page", inputSchema: { type: "object", properties: {}, required: [], }, },
  • Registration and dispatch in the main tool handler switch statement, routing calls to the VisibleHtmlTool instance.
    case "playwright_get_visible_html": return await visibleHtmlTool.execute(args, context);
  • Instantiation of the VisibleHtmlTool class instance used for handling the tool.
    if (!visibleHtmlTool) visibleHtmlTool = new VisibleHtmlTool(server);
  • src/tools.ts:419-419 (registration)
    Inclusion in BROWSER_TOOLS array, used for conditional browser launch checks.
    "playwright_get_visible_html",

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/pvinis/mcp-playwright-stealth'

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