generate_outline
Create a structured code outline for TypeScript, JavaScript, or Python files, displaying classes, functions, and imports to simplify code analysis and navigation.
Instructions
Generate a code outline for a file, showing its structure (classes, functions, imports, etc). Supports TypeScript/JavaScript and Python files.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the file to analyze |
Implementation Reference
- src/index.ts:1352-1373 (handler)Handler function for the generate_outline MCP tool. Currently implements a basic stub that returns file name, type, and path. Logs the operation and validates access.private async handleGenerateOutline(args: any) { const { path: filePath } = args; await this.loggingService.debug('Generating outline for file', { filePath, operation: 'generate_outline' }); try { await this.validateAccess(filePath); const outline = `File: ${path.basename(filePath)} Type: ${path.extname(filePath) || 'unknown'} Path: ${filePath}`; return this.createJsonResponse({ path: filePath, outline, timestamp: new Date().toISOString() }); } catch (error) { throw this.handleFileOperationError(error, 'generate outline', filePath); } }
- src/index.ts:401-413 (schema)Input schema definition and description for the generate_outline tool in server capabilities.generate_outline: { description: 'Generate a code outline for a file, showing its structure (classes, functions, imports, etc). Supports TypeScript/JavaScript and Python files.', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the file to analyze' } }, required: ['path'] } }
- src/index.ts:1617-1618 (registration)Tool dispatch/registration in the CallToolRequestSchema handler switch statement.case 'generate_outline': return await this.handleGenerateOutline(request.params.arguments);
- Detailed generateOutline method in CodeAnalysisService that creates comprehensive code outlines with imports, classes, functions, and metrics. Used by analyzeCode method.private async generateOutline(content: string, language: string): Promise<string> { const metrics = await this.calculateMetrics(content, language); const sections: string[] = []; // Add imports section if (metrics.imports.length > 0) { sections.push('Imports:', ...metrics.imports.map(imp => ` - ${imp}`)); } // Add definitions section if (metrics.definitions.classes.length > 0) { sections.push('\nClasses:', ...metrics.definitions.classes.map(cls => ` - ${cls}`)); } if (metrics.definitions.functions.length > 0) { sections.push('\nFunctions:', ...metrics.definitions.functions.map(func => ` - ${func}`)); } // Add metrics section sections.push('\nMetrics:', ` Lines: ${metrics.lineCount.total} (${metrics.lineCount.code} code, ${metrics.lineCount.comment} comments, ${metrics.lineCount.blank} blank)`, ` Complexity: ${metrics.complexity}`, ` Quality Issues:`, ` - ${metrics.quality.longLines} long lines`, ` - ${metrics.quality.duplicateLines} duplicate lines`, ` - ${metrics.quality.complexFunctions} complex functions` ); return sections.join('\n'); }