get_page_content
Extract the HTML content of a webpage using Playwright MCP. Submit the page ID to retrieve the full HTML structure for automation or analysis tasks.
Instructions
Get the current page HTML content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page_id | No |
Implementation Reference
- src/playwright_mcp/server.py:265-268 (handler)Handler logic for 'get_page_content' tool: retrieves the active page and returns its HTML content using page.content().elif name == "get_page_content": page = get_active_page(arguments.get("page_id")) content = await page.content() return [types.TextContent(type="text", text=content)]
- src/playwright_mcp/server.py:134-144 (registration)Registration of the 'get_page_content' tool in the list_tools handler, including its description and input schema.types.Tool( name="get_page_content", description="Get the current page HTML content", inputSchema={ "type": "object", "properties": { "page_id": {"type": "string"}, }, }, ), types.Tool(
- src/playwright_mcp/server.py:200-211 (helper)Helper function used by get_page_content to retrieve the active browser page based on page_id or current default.def get_active_page(page_id: Optional[str] = None) -> Page: """Get the active page based on page_id or current default.""" global current_page_id if page_id is None: page_id = current_page_id if page_id not in pages: raise ValueError(f"Page not found: {page_id}") return pages[page_id]