Skip to main content
Glama
code-alchemist01

Development Tools MCP Server

scrape_html

Extract HTML content from web pages for development workflows, handling both static and dynamic content with configurable options.

Instructions

Scrape HTML content from a URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to scrape
useBrowserNoUse browser for dynamic content
timeoutNoRequest timeout in milliseconds
headersNoCustom HTTP headers

Implementation Reference

  • Tool registration and schema definition for 'scrape_html' including input parameters for URL, browser usage, timeout, and headers.
    {
      name: 'scrape_html',
      description: 'Scrape HTML content from a URL',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'URL to scrape',
          },
          useBrowser: {
            type: 'boolean',
            description: 'Use browser for dynamic content',
            default: false,
          },
          timeout: {
            type: 'number',
            description: 'Request timeout in milliseconds',
            default: 30000,
          },
          headers: {
            type: 'object',
            description: 'Custom HTTP headers',
          },
        },
        required: ['url'],
      },
    },
  • Dispatch handler for 'scrape_html' tool call, choosing between dynamic and static scraper based on useBrowser, then formatting the result.
    case 'scrape_html': {
      if (config.useBrowser) {
        const data = await dynamicScraper.scrapeDynamicContent(config);
        return Formatters.formatScrapedData(data);
      } else {
        const data = await staticScraper.scrapeHTML(config);
        return Formatters.formatScrapedData(data);
      }
    }
  • Core implementation of HTML scraping: fetches page with axios, parses with cheerio, extracts title, text, HTML, links, images, and tables.
    async scrapeHTML(config: ScrapingConfig): Promise<ScrapedData> {
      const validation = Validators.validateScrapingConfig(config);
      if (!validation.valid) {
        throw new Error(`Invalid scraping config: ${validation.errors.join(', ')}`);
      }
    
      try {
        const response = await axios.get(config.url, {
          headers: config.headers || {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
          },
          timeout: config.timeout || 30000,
          maxRedirects: config.maxRedirects || 5,
          validateStatus: (status) => status < 500,
        });
    
        const $ = cheerio.load(response.data);
        const title = $('title').text().trim();
        const text = $('body').text().replace(/\s+/g, ' ').trim();
        const html = response.data;
    
        // Extract links
        const links: string[] = [];
        $('a[href]').each((_, element) => {
          const href = $(element).attr('href');
          if (href) {
            try {
              const url = new URL(href, config.url);
              links.push(url.href);
            } catch {
              // Invalid URL, skip
            }
          }
        });
    
        // Extract images
        const images: string[] = [];
        $('img[src]').each((_, element) => {
          const src = $(element).attr('src');
          if (src) {
            try {
              const url = new URL(src, config.url);
              images.push(url.href);
            } catch {
              // Invalid URL, skip
            }
          }
        });
    
        // Extract tables
        const tables: TableData[] = [];
        $('table').each((_, tableElement) => {
          const table: TableData = {
            headers: [],
            rows: [],
          };
    
          // Extract caption
          const caption = $(tableElement).find('caption').text().trim();
          if (caption) {
            table.caption = caption;
          }
    
          // Extract headers
          $(tableElement)
            .find('thead th, thead td, tr:first-child th, tr:first-child td')
            .each((_, header) => {
              table.headers.push($(header).text().trim());
            });
    
          // Extract rows
          $(tableElement)
            .find('tbody tr, tr')
            .each((_, row) => {
              const rowData: string[] = [];
              $(row)
                .find('td, th')
                .each((_, cell) => {
                  rowData.push($(cell).text().trim());
                });
              if (rowData.length > 0) {
                table.rows.push(rowData);
              }
            });
    
          if (table.headers.length > 0 || table.rows.length > 0) {
            tables.push(table);
          }
        });
    
        return {
          url: config.url,
          title,
          text,
          html,
          links: [...new Set(links)], // Remove duplicates
          images: [...new Set(images)], // Remove duplicates
          tables,
          scrapedAt: new Date(),
        };
      } catch (error) {
        throw new Error(`Failed to scrape ${config.url}: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • src/server.ts:18-25 (registration)
    Central registration of all tools, including webScrapingTools which contains 'scrape_html'.
    const allTools = [
      ...codeAnalysisTools,
      ...codeQualityTools,
      ...dependencyAnalysisTools,
      ...lintingTools,
      ...webScrapingTools,
      ...apiDiscoveryTools,
    ];
  • MCP server dispatch logic that routes 'scrape_html' calls (via webScrapingTools check) to the web scraping handler.
    } else if (webScrapingTools.some((t) => t.name === name)) {
      result = await handleWebScrapingTool(name, args || {});
    } else if (apiDiscoveryTools.some((t) => t.name === name)) {
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions scraping HTML content but doesn't address critical aspects like error handling, rate limits, authentication needs, response format, or whether it performs destructive operations. This leaves significant gaps for an agent to understand how the tool behaves in practice.

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 gets straight to the point with no wasted words. It's appropriately sized for a tool with this complexity and is front-loaded with the core functionality.

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 lack of annotations and output schema, the description is insufficiently complete. It doesn't explain what the tool returns (e.g., raw HTML, structured data), error conditions, or performance characteristics. For a scraping tool with multiple parameters and no structured output documentation, more context is needed.

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 fully documents all four parameters (url, useBrowser, timeout, headers). The description adds no additional parameter semantics beyond what's already in the schema, which meets the baseline expectation but doesn't provide extra value.

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 ('scrape') and resource ('HTML content from a URL'), making the purpose immediately understandable. However, it doesn't differentiate from sibling scraping tools like scrape_by_selector, scrape_dynamic_content, or scrape_with_interaction, which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling scraping tools available (e.g., scrape_dynamic_content, scrape_by_selector), the agent receives no indication of which tool is appropriate for different scenarios like static vs. dynamic content or targeted extraction.

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/code-alchemist01/development-tools-mcp-Server'

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