discover_documentation_links
Parse the dh.lan homepage to list all available EDSS documentation links.
Instructions
Discover all available EDSS documentation by parsing dh.lan homepage
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "discover_documentation_links"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| refresh | No | Force refresh discovery cache |
Implementation Reference
- index.js:313-335 (handler)The discoverLinks method is the direct handler for the 'discover_documentation_links' tool call. It accepts optional 'refresh' boolean, clears cache if requested, calls discoverDocumentationLinks(), and returns JSON with discovered links, timestamp, and count.
async discoverLinks(args) { const refresh = args?.refresh || false; if (refresh) { this.discoveredLinks = null; this.lastDiscovery = null; } const links = await this.discoverDocumentationLinks(); return { content: [ { type: "text", text: JSON.stringify({ links: links, discoveredAt: new Date().toISOString(), totalFound: Object.keys(links).length }, null, 2) } ] }; } - index.js:135-148 (schema)The tool registration with its input schema. Defines the tool name, description, and accepts an optional 'refresh' boolean parameter.
{ name: "discover_documentation_links", description: "Discover all available EDSS documentation by parsing dh.lan homepage", inputSchema: { type: "object", properties: { refresh: { type: "boolean", default: false, description: "Force refresh discovery cache" } } } }, - index.js:198-199 (registration)The switch-case mapping that routes the 'discover_documentation_links' tool name to the discoverLinks handler method.
case "discover_documentation_links": return await this.discoverLinks(args); - index.js:223-248 (helper)The core discovery logic: checks cache (10-min TTL), fetches the dh.lan homepage HTML, calls parseDocumentationLinks() to extract links, caches results, and falls back to buildLegacyLinks() on failure.
async discoverDocumentationLinks() { // Check cache first if (this.discoveredLinks && this.lastDiscovery && (Date.now() - this.lastDiscovery) < this.cacheTimeout) { return this.discoveredLinks; } try { const response = await fetch(this.baseUrl); if (!response.ok) { throw new Error(`Failed to fetch homepage: ${response.status}`); } const html = await response.text(); const links = this.parseDocumentationLinks(html); // Cache the results this.discoveredLinks = links; this.lastDiscovery = Date.now(); return links; } catch (error) { console.error('Discovery failed, using legacy URLs:', error.message); return this.buildLegacyLinks(); } } - index.js:250-290 (helper)Helper that parses the homepage HTML using a regex to find anchor tags with documentation URLs, extracts release/version info, constructs full URLs and ZIP download links, and creates aliases for non-trunk releases.
parseDocumentationLinks(html) { const links = {}; // Updated regex to match relative URLs without leading slash const linkRegex = /<a[^>]+href="([^"]*docs\/EDSS[^"]*documentation\/v[34][^"]*?)"[^>]*>([^<]*)<\/a>/gi; let match; while ((match = linkRegex.exec(html)) !== null) { const url = match[1]; const linkText = match[2].trim(); // Parse the URL to extract version and release info const urlMatch = url.match(/docs\/EDSS\/([^\/]+)\/documentation\/(v[34])\/?$/); if (urlMatch) { const release = urlMatch[1]; const apiVersion = urlMatch[2]; // Construct full URL (add leading slash if missing) const fullUrl = url.startsWith('http') ? url : `${this.baseUrl}${url.startsWith('/') ? url.slice(1) : url}`; const zipUrl = fullUrl + (fullUrl.endsWith('/') ? '' : '/') + 'get_doc.php?t=zip'; const key = `${release.toLowerCase()}_${apiVersion}`; links[key] = { url: fullUrl, zipUrl: zipUrl, release: release, apiVersion: apiVersion, linkText: linkText, discovered: true }; // Create aliases for latest if (release !== 'trunk') { const aliasKey = `latest_${apiVersion}`; links[aliasKey] = { ...links[key] }; } } } return links; }