Skip to main content
Glama
pvinis
by pvinis

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",
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't mention critical behaviors like whether it returns only visible HTML (vs. full source), potential performance implications, error conditions, or output format details. This leaves significant gaps for an agent to understand how to use it effectively.

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, clear sentence that directly states the tool's purpose with no unnecessary words. It's perfectly front-loaded and wastes no space, making it easy for an agent to parse quickly.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'visible HTML' means (e.g., rendered vs. source), the return format, or error handling. For a tool that likely interacts with a browser context, more behavioral context is needed despite the simple parameterless design.

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 zero parameters, and schema description coverage is 100% (though trivial since there are no parameters). The description appropriately doesn't discuss parameters, which is correct for a parameterless tool. No additional parameter semantics are needed or expected.

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 ('HTML content of the current page'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'playwright_get_visible_text' or 'playwright_screenshot', which also retrieve page content but in different formats.

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?

No guidance is provided on when to use this tool versus alternatives like 'playwright_get_visible_text' for text-only content or 'playwright_screenshot' for visual capture. The description lacks context about prerequisites (e.g., requiring an active page session) or typical use cases.

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

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

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