get-rendered-html
Fetch fully rendered HTML from a URL, including JavaScript-generated content, for web pages requiring client-side rendering. Ideal for SPAs and dynamic web applications.
Instructions
Fetches fully rendered HTML content using a headless browser, including JavaScript-generated content. Essential for modern web applications, single-page applications (SPAs), or any content that requires client-side rendering to be complete.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL of the target web page (ordinary HTML including JavaScript, etc.). |
Implementation Reference
- Core handler function that executes the tool logic: launches a headless Chromium browser using Playwright, navigates to the provided URL, retrieves the fully rendered HTML content, and returns it as a string.async def get_parsed_html_string_by_playwright(url:str)->str: async with async_playwright() as p: browser = await p.chromium.launch() page = await browser.new_page() await page.goto(url) parsed_html = await page.content() await browser.close() return parsed_html
- Dispatch logic in the main @server.call_tool() handler that invokes the specific implementation for 'get-rendered-html'.elif name == "get-rendered-html": parsed_html = await get_parsed_html_string_by_playwright(url) result_string = str(parsed_html)
- src/mcp_server_fetch_python/server.py:32-42 (registration)Registers the 'get-rendered-html' tool in the MCP server's list_tools(), including name, description, and input schema.types.Tool( name="get-rendered-html", description="Fetches fully rendered HTML content using a headless browser, including JavaScript-generated content. Essential for modern web applications, single-page applications (SPAs), or any content that requires client-side rendering to be complete.", # noqa: E501 inputSchema={ "type": "object", "properties": { "url": {"type": "string", "description":"URL of the target web page (ordinary HTML including JavaScript, etc.)."} # noqa: E501 }, "required": ["url"], }, ),
- JSON schema defining the tool's input: an object with a required 'url' string property.inputSchema={ "type": "object", "properties": { "url": {"type": "string", "description":"URL of the target web page (ordinary HTML including JavaScript, etc.)."} # noqa: E501 }, "required": ["url"], },