Skip to main content
Glama

get_dom

Extract complete HTML content from the current page DOM for web development debugging and analysis. Use this tool to inspect page structure and retrieve formatted HTML output.

Instructions

Extrai o HTML completo do DOM atual da página

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prettifyNoSe true, formata o HTML de forma legível

Implementation Reference

  • Handler function that implements the core logic of the 'get_dom' tool: fetches page HTML, optionally prettifies it, and returns as MCP ToolResponse.
    export async function handleGetDom(args: unknown, currentPage: Page): Promise<ToolResponse> {
      const typedArgs = args as unknown as GetDomArgs;
      const { prettify = true } = typedArgs;
    
      let html = await currentPage.content();
    
      if (prettify) {
        html = await currentPage.evaluate(() => {
          const div = document.createElement('div');
          div.innerHTML = document.documentElement.outerHTML;
          return div.innerHTML;
        });
      }
    
      return {
        content: [
          {
            type: 'text',
            text: html,
          },
        ],
      };
  • TypeScript interface defining the input schema for get_dom tool arguments.
    export interface GetDomArgs {
      prettify?: boolean;
    }
  • src/tools.ts:27-40 (registration)
    Tool registration entry in the tools array, including name, description, and JSON schema for input validation used by MCP listTools.
    {
      name: 'get_dom',
      description: 'Extrai o HTML completo do DOM atual da página',
      inputSchema: {
        type: 'object',
        properties: {
          prettify: {
            type: 'boolean',
            description: 'Se true, formata o HTML de forma legível',
            default: true,
          },
        },
      },
    },
  • src/index.ts:71-74 (registration)
    Dispatch case in the main tool call handler that routes 'get_dom' calls to the handleGetDom function.
    case 'get_dom': {
      const currentPage = await initBrowser();
      return await handleGetDom(args, currentPage);
    }

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/EmmanuelBarbosaMonteiro/mcp-server-browser'

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