get_page_content
Extract HTML content from web pages for automation tasks using Playwright browser control.
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 for the 'get_page_content' tool: retrieves the active page and returns its HTML content using Playwright's page.content() method.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-143 (registration)Registers the 'get_page_content' tool in the list_tools() function, including its name, 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"}, }, }, ),
- src/playwright_mcp/server.py:134-143 (schema)Defines the input schema for 'get_page_content' tool: optional page_id string.types.Tool( name="get_page_content", description="Get the current page HTML content", inputSchema={ "type": "object", "properties": { "page_id": {"type": "string"}, }, }, ),
- src/playwright_mcp/server.py:200-211 (helper)Helper function used by the handler to retrieve the page instance 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]