Skip to main content
Glama

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
NameRequiredDescriptionDefault
page_idNo

Implementation Reference

  • 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)]
  • 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"}, }, }, ),
  • 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"}, }, }, ),
  • 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]

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/misanthropic-ai/playwrite-mcp'

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