Skip to main content
Glama
TheAlchemist6

CodeCompass MCP

analyze_codebase

Analyze GitHub repositories to understand code structure, architecture patterns, complexity metrics, and quality indicators through comprehensive automated analysis.

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
urlYesGitHub repository URL
file_pathsNoSpecific files to analyze (optional - analyzes all code files if not specified)
analysis_typesNoTypes of analysis to perform
optionsNo

Implementation Reference

  • Tool schema definition including input validation, description, 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)
    Registers the consolidatedTools array (including analyze_codebase) for the MCP listTools endpoint
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: consolidatedTools,
      };
    });
  • src/index.ts:269-271 (registration)
    Dispatch registration in the main tool switch statement mapping 'analyze_codebase' to its handler
    case 'analyze_codebase':
      result = await handleAnalyzeCodebase(args);
      break;
  • MCP tool handler function for analyze_codebase that extracts arguments and delegates to GitHubService
    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);
      }
    }
  • Core implementation performing code structure analysis: extracts functions/imports, calculates complexity metrics across 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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but lacks critical behavioral details. It doesn't disclose whether this is a read-only operation, potential performance/rate limits, authentication needs for GitHub URLs, or what the output format looks like. The description mentions analysis types but not how results are returned or any side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences that efficiently convey the tool's scope and capabilities. It's front-loaded with the core purpose and avoids unnecessary elaboration, though it could be slightly more structured by explicitly separating scope from output characteristics.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex analysis tool with 4 parameters, nested objects, no annotations, and no output schema, the description is insufficient. It doesn't explain what the unified view output contains, how analysis results are structured, performance considerations, or error conditions. The gap between tool complexity and description detail is significant.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 75%, providing good parameter documentation. The description adds minimal value beyond the schema by mentioning analysis types that correspond to the 'analysis_types' parameter enum, but doesn't explain parameter interactions or provide additional context about how parameters affect the analysis.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs 'comprehensive codebase analysis' with specific analysis types (structure, architecture, metrics, patterns, complexity) and quality indicators. It distinguishes itself from siblings like 'analyze_dependencies' or 'review_code' by offering a unified multi-faceted analysis, though it doesn't explicitly contrast with each sibling.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'analyze_dependencies' for dependency analysis, 'review_code' for code review, or 'explain_code' for explanations. It mentions analysis types but doesn't specify use cases or exclusions relative to sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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