get_doc_content
Extract specific content from MSFS SDK documentation pages by providing the URL and optional section name, enabling structured access to detailed SDK information.
Instructions
Get detailed content from a specific MSFS SDK documentation page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| section | No | Specific section to extract (e.g., "overview", "examples", "api-reference") | |
| url | Yes | URL of the documentation page to retrieve |
Implementation Reference
- The core handler function that implements the tool logic: fetches the MSFS documentation page at the given URL, parses HTML with cheerio, extracts main content (optionally specific section), code examples, and formats the response.async getDocumentationContent( url: string, section?: string ): Promise<{ content: Array<{ type: string; text: string }> }> { try { const fetchResponse = await fetch(url); if (!fetchResponse.ok) { throw new Error(`Failed to fetch documentation: ${fetchResponse.status}`); } const html = await fetchResponse.text(); const $ = cheerio.load(html); // Remove navigation and headers $('nav, header, footer, .navigation, .toc').remove(); let contentText = ''; let title = $('title').text() || 'MSFS SDK Documentation'; if (section) { // Try to find specific section const sectionElement = $(`#${section}, .${section}, [data-section="${section}"]`); if (sectionElement.length > 0) { contentText = sectionElement.text().trim(); } else { contentText = $('main, .content, body').text().trim(); } } else { contentText = $('main, .content, body').text().trim(); } // Extract code examples const codeExamples: string[] = []; $('code, pre').each((_, element) => { const code = $(element).text().trim(); if (code.length > 10) { // Filter out small snippets codeExamples.push(code); } }); const formattedContent = `**${title}**\n\nURL: ${url}\n\n${contentText.substring(0, 4000)}${contentText.length > 4000 ? '...' : ''}`; let finalResponse = formattedContent; if (codeExamples.length > 0) { finalResponse += '\n\n**Code Examples:**\n'; codeExamples.slice(0, 3).forEach((example, index) => { finalResponse += `\n\nExample ${index + 1}:\n\`\`\`\n${example}\n\`\`\``; }); } return { content: [ { type: 'text', text: finalResponse, }, ], }; } catch (error) { throw new Error(`Failed to get documentation content: ${error}`); } }
- src/index.ts:63-80 (schema)The input schema definition for the get_doc_content tool, registered in the ListToolsRequestHandler.{ name: 'get_doc_content', description: 'Get detailed content from a specific MSFS SDK documentation page', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL of the documentation page to retrieve', }, section: { type: 'string', description: 'Specific section to extract (e.g., "overview", "examples", "api-reference")', } }, required: ['url'] } },
- src/index.ts:137-144 (registration)Direct registration and dispatching to the handler in the main CallToolRequestSchema switch statement.case 'get_doc_content': if (!args?.url) { throw new Error('URL parameter is required'); } return await this.documentationService.getDocumentationContent( String(args.url), args.section ? String(args.section) : undefined );
- src/index.ts:170-174 (registration)Indirect registration via natural language query parsing in the CallToolRequestSchema for 'natural_language_query' tool.case 'get_doc_content': return await this.documentationService.getDocumentationContent( String(parsedCommand.arguments.url), parsedCommand.arguments.section ? String(parsedCommand.arguments.section) : undefined );
- Helper parse function that recognizes natural language commands like 'Get content for [url]' and maps them to the get_doc_content tool call.// Match "Get content for [url]" const contentPattern = /^Get\s+content\s+for\s+(https?:\/\/.+)$/i; const contentMatch = command.match(contentPattern); if (contentMatch) { const url = contentMatch[1]; return { tool: "get_doc_content", arguments: { url: url } }; }