Skip to main content
Glama
TheAlchemist6

CodeCompass MCP

analyze_codebase

Analyzes GitHub repositories for code structure, architecture, metrics, complexity, and design patterns. Offers insights into organization, quality, and reusable components for better code understanding and optimization.

Instructions

🔬 Comprehensive codebase analysis combining structure, architecture, and metrics. Provides unified view of code organization, design patterns, complexity, and quality indicators.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
analysis_typesNoTypes of analysis to perform
file_pathsNoSpecific files to analyze (optional - analyzes all code files if not specified)
optionsNo
urlYesGitHub repository URL

Implementation Reference

  • Core handler implementation in GitHubService: analyzes code structure by extracting functions, imports/dependencies, and computing complexity metrics from key repository files.
    async analyzeCodeStructure(url: string, file_paths?: string[], options: any = {}): Promise<any> { const keyFiles = await this.getKeyFiles(url); const codeStructure: any = { functions: [], classes: [], imports: [], exports: [], complexity: { cyclomatic: 0, cognitive: 0, maintainability: 0, }, }; for (const [filePath, content] of Object.entries(keyFiles)) { if (file_paths && !file_paths.includes(filePath)) continue; // Extract functions const functions = this.extractFunctions(content); codeStructure.functions.push(...functions.map(func => ({ name: func, signature: `function ${func}()`, startLine: 0, endLine: 0, complexity: 1, parameters: [], documentation: '', }))); // Extract imports const imports = this.extractDependencies(content); codeStructure.imports.push(...imports.map(imp => ({ source: imp, imports: [], type: 'import', isExternal: !imp.startsWith('.'), }))); // Calculate complexity codeStructure.complexity.cyclomatic += this.calculateFileComplexity(content); } codeStructure.complexity.maintainability = this.calculateMaintainability(keyFiles); return codeStructure; }
  • Top-level MCP tool handler: wraps GitHubService analysis and formats response with error handling.
    async function handleAnalyzeCodebase(args: any) { try { const { url, file_paths, options = {} } = args; const analysis = await githubService.analyzeCodeStructure(url, file_paths, options); const response = createResponse(analysis); return formatToolResponse(response); } catch (error) { const response = createResponse(null, error); return formatToolResponse(response); } }
  • src/index.ts:269-271 (registration)
    Dispatch registration in main CallToolRequestSchema switch statement.
    case 'analyze_codebase': result = await handleAnalyzeCodebase(args); break;
  • Tool schema definition including input validation and parameters for analyze_codebase.
    { name: 'analyze_codebase', description: '🔬 Comprehensive codebase analysis combining structure, architecture, and metrics. Provides unified view of code organization, design patterns, complexity, and quality indicators.', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'GitHub repository URL', }, file_paths: { type: 'array', items: { type: 'string' }, description: 'Specific files to analyze (optional - analyzes all code files if not specified)', }, analysis_types: { type: 'array', items: { type: 'string', enum: ['structure', 'architecture', 'metrics', 'patterns', 'complexity'], }, description: 'Types of analysis to perform', default: ['structure', 'architecture', 'metrics'], }, options: { type: 'object', properties: { include_functions: { type: 'boolean', description: 'Include function analysis', default: true, }, include_classes: { type: 'boolean', description: 'Include class analysis', default: true, }, include_imports: { type: 'boolean', description: 'Include import/dependency analysis', default: true, }, include_complexity: { type: 'boolean', description: 'Include complexity metrics', default: true, }, include_patterns: { type: 'boolean', description: 'Include design pattern detection', default: true, }, include_components: { type: 'boolean', description: 'Include reusable component identification', default: false, }, languages: { type: 'array', items: { type: 'string' }, description: 'Programming languages to analyze', }, confidence_threshold: { type: 'number', description: 'Minimum confidence score for pattern detection', default: 0.7, }, }, }, }, required: ['url'], }, },
  • src/index.ts:236-240 (registration)
    Server registration for ListToolsRequestSchema returning consolidatedTools which includes analyze_codebase.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: consolidatedTools, }; });

Other Tools

Related Tools

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/TheAlchemist6/codecompass-mcp'

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