list_sections
Retrieve a list of navigable sections from the authenticated internal CAEZ Urekin website. Specify a root path to filter sections by directory.
Instructions
Lista secciones navegables del sitio.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| root_path | No | / |
Implementation Reference
- src/index.js:338-369 (handler)The async handler function that executes the 'list_sections' tool logic: fetches a page, extracts all anchor links within BASE_URL, deduplicates them, and returns up to 100 sections with title, path, and url.
async ({ root_path }) => { try { const { html } = await fetchPage(root_path); const $ = cheerio.load(html); const sections = []; $('a[href]').each((_, el) => { const title = $(el).text().trim(); const href = $(el).attr('href'); if (!title || !href) return; const url = normalizeUrl(href); if (!url.startsWith(BASE_URL)) return; sections.push({ title, path: new URL(url).pathname, url }); }); return { content: [ { type: 'text', text: JSON.stringify({ sections: dedupeLinks(sections).slice(0, 100) }, null, 2) } ] }; } catch (error) { return mcpError(error); } } ); - src/index.js:335-336 (schema)Input schema for 'list_sections': accepts an optional 'root_path' string parameter defaulting to '/'.
{ root_path: z.string().default('/') - src/index.js:332-369 (registration)Registration of the 'list_sections' tool via server.tool() on the McpServer instance with name 'list_sections' and description 'Lista secciones navegables del sitio.'.
server.tool( 'list_sections', 'Lista secciones navegables del sitio.', { root_path: z.string().default('/') }, async ({ root_path }) => { try { const { html } = await fetchPage(root_path); const $ = cheerio.load(html); const sections = []; $('a[href]').each((_, el) => { const title = $(el).text().trim(); const href = $(el).attr('href'); if (!title || !href) return; const url = normalizeUrl(href); if (!url.startsWith(BASE_URL)) return; sections.push({ title, path: new URL(url).pathname, url }); }); return { content: [ { type: 'text', text: JSON.stringify({ sections: dedupeLinks(sections).slice(0, 100) }, null, 2) } ] }; } catch (error) { return mcpError(error); } } ); - src/index.js:34-40 (helper)Helper function normalizeUrl() used by the handler to resolve relative URLs against BASE_URL.
function normalizeUrl(input) { try { return new URL(input, BASE_URL).toString(); } catch { throw new Error('INVALID_URL'); } } - src/index.js:166-173 (helper)Helper function dedupeLinks() used by the handler to remove duplicate URLs from the sections list.
function dedupeLinks(links) { const seen = new Set(); return links.filter((link) => { if (seen.has(link.url)) return false; seen.add(link.url); return true; }); }