Skip to main content
Glama
luistorres789321

ia-cae-zurekin-mcp

search_pages

Search authenticated internal web pages by query. Specify optional limit and section to retrieve relevant content from the secure intranet.

Instructions

Busca contenido dentro de la web interna autenticada.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo
sectionNo

Implementation Reference

  • The handler function for the 'search_pages' tool. It fetches a search page, parses HTML with cheerio, filters 'a[href]' elements that match the query and belong to the same base URL, and returns results with title, url, path, snippet, and score.
    async ({ query, limit, section }) => {
      try {
        const searchUrl = SEARCH_PATH
          ? `${SEARCH_PATH}${SEARCH_PATH.includes('?') ? '&' : '?'}q=${encodeURIComponent(query)}`
          : section || '/';
    
        const { html, finalUrl } = await fetchPage(searchUrl);
        const $ = cheerio.load(html);
        const results = [];
    
        $('a[href]').each((_, el) => {
          if (results.length >= limit) return false;
          const title = $(el).text().trim();
          const href = $(el).attr('href');
          if (!title || !href) return;
          const snippet = $(el).parent().text().trim().slice(0, 240);
          const url = normalizeUrl(href);
          if (!url.startsWith(BASE_URL)) return;
          if (!`${title} ${snippet}`.toLowerCase().includes(query.toLowerCase())) return;
          results.push({
            title,
            url,
            path: new URL(url).pathname,
            snippet,
            score: 0.5
          });
        });
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({ results, total: results.length, searched_from: finalUrl }, null, 2)
            }
          ]
        };
      } catch (error) {
        return mcpError(error);
      }
    }
  • Input schema for the 'search_pages' tool: 'query' (string, required), 'limit' (number 1-20, default 10), 'section' (optional string).
    {
      query: z.string(),
      limit: z.number().int().min(1).max(20).default(10),
      section: z.string().optional()
    },
  • src/index.js:214-262 (registration)
    Registration of the 'search_pages' tool on the MCP server using server.tool(), with the description 'Busca contenido dentro de la web interna autenticada.'
    server.tool(
      'search_pages',
      'Busca contenido dentro de la web interna autenticada.',
      {
        query: z.string(),
        limit: z.number().int().min(1).max(20).default(10),
        section: z.string().optional()
      },
      async ({ query, limit, section }) => {
        try {
          const searchUrl = SEARCH_PATH
            ? `${SEARCH_PATH}${SEARCH_PATH.includes('?') ? '&' : '?'}q=${encodeURIComponent(query)}`
            : section || '/';
    
          const { html, finalUrl } = await fetchPage(searchUrl);
          const $ = cheerio.load(html);
          const results = [];
    
          $('a[href]').each((_, el) => {
            if (results.length >= limit) return false;
            const title = $(el).text().trim();
            const href = $(el).attr('href');
            if (!title || !href) return;
            const snippet = $(el).parent().text().trim().slice(0, 240);
            const url = normalizeUrl(href);
            if (!url.startsWith(BASE_URL)) return;
            if (!`${title} ${snippet}`.toLowerCase().includes(query.toLowerCase())) return;
            results.push({
              title,
              url,
              path: new URL(url).pathname,
              snippet,
              score: 0.5
            });
          });
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({ results, total: results.length, searched_from: finalUrl }, null, 2)
              }
            ]
          };
        } catch (error) {
          return mcpError(error);
        }
      }
    );
  • Helper function 'fetchPage' used by the handler to fetch authenticated page content.
    async function fetchPage(urlOrPath) {
      await ensureAuthenticated();
      const response = await request(urlOrPath, { method: 'GET' });
      if (!response.ok) {
        throw new Error(response.status === 404 ? 'PAGE_NOT_FOUND' : 'INTERNAL_ERROR');
      }
      const finalUrl = response.url || normalizeUrl(urlOrPath);
      const html = await response.text();
      return { html, finalUrl };
    }
  • Helper function 'mcpError' used by the handler to return structured error responses.
    function mcpError(error) {
      const message = error instanceof Error ? error.message : 'INTERNAL_ERROR';
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              error: {
                code: message.split(':')[0],
                message
              }
            }, null, 2)
          }
        ],
        isError: true
      };
    }
Behavior2/5

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

With no annotations, the description bears full responsibility for behavioral disclosure. It only states 'Busca contenido' without detailing outcomes (e.g., returns page titles, snippets, or URLs), authentication specifics, or limits on input.

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

Conciseness3/5

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

The description is a single short sentence, which is concise but overly sparse. It does not waste words, but it lacks sufficient detail to be fully useful, sacrificing completeness for 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 three parameters, no output schema, and sibling tools, the description is incomplete. It does not explain return format, how to use the 'section' parameter, or behavior for missing/empty queries, leaving critical gaps.

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?

The input schema has 0% description coverage. The description adds no explanation for any parameter (query, limit, section), leaving their meaning entirely to the schema names. This fails to add value beyond the bare schema.

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 verb 'Busca' (search) and the resource 'contenido dentro de la web interna autenticada' (content within the authenticated internal web). It adequately distinguishes from sibling tools like get_page and extract_page_content by indicating a search capability.

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 such as get_page or list_sections. It does not mention any 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