get_doc_structure
Retrieve the structure of available Laravel documentation files to navigate and access development resources efficiently.
Instructions
Get the structure of all available documentation files
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:62-94 (registration)Tool registration for 'get_doc_structure' with schema and handler. The registration defines the tool name, description, empty input schema (no parameters required), and the async handler function that executes the tool logic.
server.registerTool( 'get_doc_structure', { description: 'Get the structure of all available documentation files', inputSchema: {}, }, async () => { const files = getDocFiles(DOCS_PATH); const structure = { documentation_root: DOCS_PATH, files: files.map(f => ({ path: f.path, name: f.name, })), summary: { total_files: files.length, categories: { ai: files.filter(f => f.path.startsWith('ai/')).length, patterns: files.filter(f => f.path.startsWith('patterns/')).length, domains: files.filter(f => f.path.startsWith('domains/')).length, }, }, }; return { content: [{ type: 'text', text: JSON.stringify(structure, null, 2), }], }; } ); - index.js:68-93 (handler)Handler function for get_doc_structure tool. It calls getDocFiles(DOCS_PATH) to retrieve all markdown files, constructs a structure object with documentation_root, files array, and summary containing total_files count and category breakdown (ai, patterns, domains), then returns the result as JSON text content.
async () => { const files = getDocFiles(DOCS_PATH); const structure = { documentation_root: DOCS_PATH, files: files.map(f => ({ path: f.path, name: f.name, })), summary: { total_files: files.length, categories: { ai: files.filter(f => f.path.startsWith('ai/')).length, patterns: files.filter(f => f.path.startsWith('patterns/')).length, domains: files.filter(f => f.path.startsWith('domains/')).length, }, }, }; return { content: [{ type: 'text', text: JSON.stringify(structure, null, 2), }], }; } - index.js:22-50 (helper)Helper function getDocFiles that recursively scans a directory to find all markdown files. It skips hidden directories and node_modules, returns an array of file objects containing relative path, full path, and filename. This is used by get_doc_structure to build the file structure.
function getDocFiles(dir, basePath = dir) { const files = []; if (!fs.existsSync(dir)) { return files; } const entries = fs.readdirSync(dir, { withFileTypes: true }); for (const entry of entries) { const fullPath = path.join(dir, entry.name); const relativePath = path.relative(basePath, fullPath); if (entry.isDirectory()) { // Skip node_modules and hidden directories if (!entry.name.startsWith('.') && entry.name !== 'node_modules') { files.push(...getDocFiles(fullPath, basePath)); } } else if (entry.name.endsWith('.md')) { files.push({ path: relativePath, full_path: fullPath, name: entry.name, }); } } return files; }