Skip to main content
Glama

browser.get_html

Extract HTML source or plain text from web pages. Configure to capture full pages or visible viewport content for automation tasks.

Instructions

Get the HTML source of the current page. Set text_only=true to strip tags and return plain text. Set full_page=false (default) for visible viewport only.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes
full_pageNo
text_onlyNo

Implementation Reference

  • The _get_html method in McpToolGateway is the implementation handler for the browser.get_html tool.
    async def _get_html(self, payload: GetPageHtmlInput) -> dict[str, Any]:
        session = await self.manager.get_session(payload.session_id)
        if payload.text_only:
            text = await session.page.evaluate(
                "() => document.body ? document.body.innerText : ''"
            )
            return {"session_id": payload.session_id, "content": text, "type": "text"}
        html = await session.page.content()
        return {"session_id": payload.session_id, "content": html, "type": "html"}
  • Registration of browser.get_html tool within McpToolGateway._tools.
        name="browser.get_html",
        description=(
            "Get the HTML source of the current page. "
            "Set text_only=true to strip tags and return plain text. "
            "Set full_page=false (default) for visible viewport only."
        ),
        input_model=GetPageHtmlInput,
        handler=self._get_html,
    ),
  • Input schema definition for browser.get_html tool.
    class GetPageHtmlInput(SessionIdInput):
        full_page: bool = False
        text_only: bool = False

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/LvcidPsyche/auto-browser'

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