Skip to main content
Glama
blackwhite084

Playwright Server MCP

playwright_get_html_content

Extract HTML content from web pages using CSS selectors for web automation and data retrieval tasks.

Instructions

Get the HTML content of the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for the element

Implementation Reference

  • The handler class that implements the core logic for the 'playwright_get_html_content' tool. It retrieves the inner HTML content of the specified CSS selector from the current Playwright page session.
    class GetHtmlContentToolHandler(ToolHandler):
        async def handle(self, name: str, arguments: dict | None) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
            if not self._sessions:
                return [types.TextContent(type="text", text="No active session. Please create a new session first.")]
            session_id = list(self._sessions.keys())[-1]
            page = self._sessions[session_id]["page"]
            selector = arguments.get("selector")
            html_content = await page.locator(selector).inner_html()
            return [types.TextContent(type="text", text=f"HTML content of element with selector {selector}: {html_content}")]
  • JSON Schema definition for the tool's input parameters, specifying a required 'selector' field.
    types.Tool(
        name="playwright_get_html_content",
        description="Get the HTML content of the page",
         inputSchema={
            "type": "object",
            "properties": {
                "selector": {"type": "string", "description": "CSS selector for the element"}
            },
            "required": ["selector"]
        }
    )
  • Registration of all tool handlers in a dictionary used by the @server.call_tool() handler to dispatch tool calls.
    tool_handlers = {
        "playwright_navigate": NavigateToolHandler(),
        "playwright_screenshot": ScreenshotToolHandler(),
        "playwright_click": ClickToolHandler(),
        "playwright_fill": FillToolHandler(),
        "playwright_evaluate": EvaluateToolHandler(),
        "playwright_click_text": ClickTextToolHandler(),
        "playwright_get_text_content": GetTextContentToolHandler(),
        "playwright_get_html_content": GetHtmlContentToolHandler(),
        "playwright_new_session":NewSessionToolHandler(),
    }
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 but offers minimal insight. It doesn't mention whether this tool requires a loaded page, how it handles missing selectors, if it returns raw HTML or a parsed structure, or any performance considerations like timeouts. The description merely restates the basic function without operational context.

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, direct sentence with zero wasted words, making it highly concise and front-loaded. It efficiently communicates the core action without unnecessary elaboration, though this brevity contributes to gaps in other dimensions.

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 for a tool that interacts with a dynamic environment like a web page. It fails to address key contextual aspects such as error handling, return format (e.g., string vs. structured HTML), dependencies on page state, or how it differs from sibling tools, leaving significant gaps for an AI agent to infer.

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

Parameters3/5

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

The input schema has 100% description coverage, clearly documenting the single 'selector' parameter as a CSS selector for the element. The description adds no additional meaning beyond this, as it doesn't elaborate on selector syntax, examples, or constraints. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 page'), making the purpose immediately understandable. However, it doesn't distinguish this tool from its sibling 'playwright_get_text_content', which suggests a similar retrieval function but for text rather than HTML content.

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 'playwright_get_text_content' for text content or 'playwright_evaluate' for more complex DOM interactions. It lacks context about prerequisites (e.g., requiring a page to be loaded) or exclusions, leaving usage decisions ambiguous.

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/blackwhite084/playwright-plus-python-mcp'

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