Skip to main content
Glama
bsmi021

MCP File Context Server

by bsmi021

generate_outline

Analyze code files to generate structural outlines showing classes, functions, and imports for TypeScript, JavaScript, and Python.

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
NameRequiredDescriptionDefault
pathYesPath to the file to analyze

Implementation Reference

  • The primary handler function for the 'generate_outline' MCP tool. It validates the file path and returns a basic outline containing the file name, type (extension), full path, and timestamp.
        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);
            }
        }
  • Input schema definition for the generate_outline tool in the MCP server capabilities, specifying the required 'path' parameter.
    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:1546-1558 (registration)
    Tool registration in the ListToolsRequestSchema handler, listing generate_outline with its description and input schema.
        name: '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']
        }
    },
  • Routing logic in the main CallToolRequestSchema handler that dispatches generate_outline tool calls to the specific handleGenerateOutline method.
    case 'generate_outline':
        return await this.handleGenerateOutline(request.params.arguments);
  • Supporting helper method in CodeAnalysisService that generates a detailed outline (imports, classes, functions, metrics) matching the tool's description, called 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');
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bsmi021/mcp-file-context-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server