Skip to main content
Glama
luistorres789321

ia-cae-zurekin-mcp

extract_page_content

Extract structured content from a webpage, including tables and links, for data analysis or archiving. Solves the problem of retrieving clean, organized page content without manual scraping.

Instructions

Extrae el contenido estructurado de una p�gina.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
include_tablesNo
include_linksNo

Implementation Reference

  • src/index.js:299-330 (registration)
    Tool registration for 'extract_page_content' via server.tool() with name, description, schema, and handler.
    server.tool(
      'extract_page_content',
      'Extrae el contenido estructurado de una p�gina.',
      {
        url: z.string(),
        include_tables: z.boolean().default(true),
        include_links: z.boolean().default(true)
      },
      async ({ url, include_tables, include_links }) => {
        try {
          const { html, finalUrl } = await fetchPage(url);
          const extracted = extractReadableContent(html, finalUrl);
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  title: extracted.title,
                  url: finalUrl,
                  sections: extracted.sections,
                  tables: include_tables ? extractTables(html) : [],
                  links: include_links ? extracted.links : []
                }, null, 2)
              }
            ]
          };
        } catch (error) {
          return mcpError(error);
        }
      }
    );
  • Input schema for extract_page_content: url (required string), include_tables (boolean, default true), include_links (boolean, default true).
    {
      url: z.string(),
      include_tables: z.boolean().default(true),
      include_links: z.boolean().default(true)
    },
  • Handler function that fetches the page, extracts readable content, and returns title, sections, tables (optional), and links (optional) as JSON.
    async ({ url, include_tables, include_links }) => {
      try {
        const { html, finalUrl } = await fetchPage(url);
        const extracted = extractReadableContent(html, finalUrl);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                title: extracted.title,
                url: finalUrl,
                sections: extracted.sections,
                tables: include_tables ? extractTables(html) : [],
                links: include_links ? extracted.links : []
              }, null, 2)
            }
          ]
        };
      } catch (error) {
        return mcpError(error);
      }
    }
  • extractReadableContent() helper: parses HTML with cheerio, extracts title, heading-based sections, and deduplicated internal links.
    function extractReadableContent(html, pageUrl) {
      const $ = cheerio.load(html);
      $('script, style, noscript').remove();
    
      const title = $('title').first().text().trim() || $('h1').first().text().trim() || pageUrl;
      const sections = [];
    
      $('h1, h2, h3').each((_, el) => {
        const heading = $(el).text().trim();
        const texts = [];
        let current = $(el).next();
    
        while (current.length && !['h1', 'h2', 'h3'].includes(current.get(0)?.tagName)) {
          const text = current.text().trim();
          if (text) texts.push(text);
          current = current.next();
        }
    
        if (heading || texts.length) {
          sections.push({ heading, text: texts.join('\n\n') });
        }
      });
    
      const links = [];
      $('a[href]').each((_, el) => {
        const href = $(el).attr('href');
        const label = $(el).text().trim();
        if (!href) return;
        try {
          const url = new URL(href, pageUrl).toString();
          if (url.startsWith(BASE_URL)) {
            links.push({ label: label || url, url });
          }
        } catch {
        }
      });
    
      const contentText = $('body')
        .text()
        .replace(/\s+\n/g, '\n')
        .replace(/\n\s+/g, '\n')
        .replace(/\n{3,}/g, '\n\n')
        .trim();
    
      return {
        title,
        contentText,
        sections,
        links: dedupeLinks(links)
      };
    }
  • extractTables() helper: parses HTML tables into headers/rows structure.
    function extractTables(html) {
      const $ = cheerio.load(html);
      const tables = [];
    
      $('table').each((_, table) => {
        const headers = [];
        $(table).find('thead th').each((__, th) => headers.push($(th).text().trim()));
    
        const rows = [];
        $(table).find('tbody tr').each((__, tr) => {
          const row = [];
          $(tr).find('td').each((___, td) => row.push($(td).text().trim()));
          if (row.length) rows.push(row);
        });
    
        if (headers.length || rows.length) {
          tables.push({ title: null, headers, rows });
        }
      });
    
      return tables;
    }
Behavior2/5

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

No annotations provided, so the description bears full burden. It implies a read operation ('extracts') but does not disclose side effects, idempotency, error handling, or any behavioral traits. Insufficient for a tool with zero annotations.

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

Conciseness4/5

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

Single sentence, concise and front-loaded. No extraneous information. However, lacks structure (e.g., bullet points), but this does not detract from its brevity.

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 3 parameters, no output schema, and no annotations, the description is too brief. Does not explain what 'structured content' means, how boolean parameters affect extraction, or the output format. Inadequate for effective agent usage.

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

Parameters1/5

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

Schema has 0% coverage (no property descriptions). The description does not explain what include_tables or include_links do, nor does it add any meaning beyond the schema. The description adds zero value for parameter understanding.

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 tool extracts structured content from a page, using a specific verb and resource. It distinguishes from siblings like get_page (likely raw content) and list_sections (sections), but does not explicitly differentiate.

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 on when to use this tool versus alternatives like get_page or list_sections. No context about prerequisites or scenarios where this tool is preferred.

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/luistorres789321/ia-cae-zurekin-mcp'

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