Skip to main content
Glama

render.extract_dom

Extract webpage DOM structures for security analysis and vulnerability testing by providing a URL and optional wait time.

Instructions

Extract and return the DOM structure of a webpage

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to extract DOM from
waitTimeNoWait time in ms

Implementation Reference

  • Handler function that launches a Puppeteer browser, navigates to the given URL, waits, extracts the page HTML, title, forms with inputs, and top links, then returns a structured result.
    async ({ url, waitTime = 2000 }: any): Promise<ToolResult> => {
      let page: Page | null = null;
      try {
        const browserInstance = await getBrowser();
        page = await browserInstance.newPage();
        
        await page.goto(url, { waitUntil: 'networkidle2', timeout: 30000 });
        await new Promise(resolve => setTimeout(resolve, waitTime));
    
        const html = await page.content();
        const title = await page.title();
        const forms = await page.$$eval('form', (forms) =>
          forms.map((form) => ({
            action: form.action,
            method: form.method,
            inputs: Array.from(form.querySelectorAll('input')).map((input: any) => ({
              name: input.name,
              type: input.type,
              id: input.id,
            })),
          }))
        );
    
        const links = await page.$$eval('a', (links) =>
          links.map((link: any) => ({
            href: link.href,
            text: link.textContent?.trim(),
          }))
        );
    
        await page.close();
    
        return formatToolResult(true, {
          url,
          title,
          html: html.substring(0, 50000), // Limit size
          forms,
          links: links.slice(0, 100), // Limit links
          summary: {
            formsCount: forms.length,
            linksCount: links.length,
          },
        });
      } catch (error: any) {
        if (page) await page.close().catch(() => {});
        return formatToolResult(false, null, error.message);
      }
    }
  • Schema definition for the render.extract_dom tool, specifying input parameters url (required) and optional waitTime.
      description: 'Extract and return the DOM structure of a webpage',
      inputSchema: {
        type: 'object',
        properties: {
          url: { type: 'string', description: 'URL to extract DOM from' },
          waitTime: { type: 'number', description: 'Wait time in ms', default: 2000 },
        },
        required: ['url'],
      },
    },
  • Tool registration call using server.tool() with name 'render.extract_dom', its schema, and handler function within registerRenderTools.
      'render.extract_dom',
      {
        description: 'Extract and return the DOM structure of a webpage',
        inputSchema: {
          type: 'object',
          properties: {
            url: { type: 'string', description: 'URL to extract DOM from' },
            waitTime: { type: 'number', description: 'Wait time in ms', default: 2000 },
          },
          required: ['url'],
        },
      },
      async ({ url, waitTime = 2000 }: any): Promise<ToolResult> => {
        let page: Page | null = null;
        try {
          const browserInstance = await getBrowser();
          page = await browserInstance.newPage();
          
          await page.goto(url, { waitUntil: 'networkidle2', timeout: 30000 });
          await new Promise(resolve => setTimeout(resolve, waitTime));
    
          const html = await page.content();
          const title = await page.title();
          const forms = await page.$$eval('form', (forms) =>
            forms.map((form) => ({
              action: form.action,
              method: form.method,
              inputs: Array.from(form.querySelectorAll('input')).map((input: any) => ({
                name: input.name,
                type: input.type,
                id: input.id,
              })),
            }))
          );
    
          const links = await page.$$eval('a', (links) =>
            links.map((link: any) => ({
              href: link.href,
              text: link.textContent?.trim(),
            }))
          );
    
          await page.close();
    
          return formatToolResult(true, {
            url,
            title,
            html: html.substring(0, 50000), // Limit size
            forms,
            links: links.slice(0, 100), // Limit links
            summary: {
              formsCount: forms.length,
              linksCount: links.length,
            },
          });
        } catch (error: any) {
          if (page) await page.close().catch(() => {});
          return formatToolResult(false, null, error.message);
        }
      }
    );
  • Helper function to lazily initialize and return a shared Puppeteer browser instance used by all render tools.
    async function getBrowser(): Promise<Browser> {
      if (!browser) {
        browser = await puppeteer.launch({
          headless: true,
          args: ['--no-sandbox', '--disable-setuid-sandbox'],
        });
      }
      return browser;
    }
  • src/index.ts:42-42 (registration)
    Invocation of registerRenderTools which registers all render tools including render.extract_dom.
    registerRenderTools(server);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden but only states the basic action without disclosing behavioral traits. It doesn't mention potential side effects (e.g., network requests, rendering overhead), authentication needs, rate limits, or error handling, leaving significant gaps for a tool that interacts with external webpages.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It is front-loaded and wastes no space, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of extracting DOM from webpages, no annotations, and no output schema, the description is insufficient. It doesn't explain what the returned DOM structure includes (e.g., HTML format, depth), error scenarios, or dependencies, leaving the agent with incomplete context for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('url' and 'waitTime') adequately. The description adds no additional meaning beyond what the schema provides, such as explaining the DOM extraction process or format, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('extract and return') and resource ('DOM structure of a webpage'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'render.extract_forms' or 'render.screenshot' that also operate on webpages, missing explicit distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as 'render.extract_forms' for form extraction or 'render.screenshot' for visual capture. The description lacks context about use cases or prerequisites, offering no help in tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/telmon95/VulneraMCP'

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