Skip to main content
Glama
code-alchemist01

Development Tools MCP Server

analyze_maintainability

Calculate maintainability index for code files to assess software quality and identify improvement areas in development workflows.

Instructions

Calculate maintainability index for code

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesFile paths to analyze

Implementation Reference

  • The switch case handler that executes the 'analyze_maintainability' tool. It processes input files, uses CodeAnalyzer to compute metrics, and returns maintainability index, complexity, and lines of code.
    case 'analyze_maintainability': {
      const files = params.files as string[];
      const codeFiles = await FileReader.readFiles(files.join(','));
      const metrics = await codeAnalyzer.analyzeCodeQuality(codeFiles);
      return {
        maintainabilityIndex: metrics.maintainabilityIndex,
        complexity: metrics.complexity,
        linesOfCode: metrics.linesOfCode,
      };
    }
  • The tool definition including name, description, and input schema for 'analyze_maintainability'.
    {
      name: 'analyze_maintainability',
      description: 'Calculate maintainability index for code',
      inputSchema: {
        type: 'object',
        properties: {
          files: {
            type: 'array',
            items: { type: 'string' },
            description: 'File paths to analyze',
          },
        },
        required: ['files'],
      },
    },
  • src/server.ts:64-65 (registration)
    Registration and dispatch logic in the main server that routes calls to 'analyze_maintainability' (via codeQualityTools check) to the handleCodeQualityTool function.
    } else if (codeQualityTools.some((t) => t.name === name)) {
      result = await handleCodeQualityTool(name, args || {});
  • Core analysis method in CodeAnalyzer that computes the maintainabilityIndex along with other code quality metrics, called by the tool handler.
    async analyzeCodeQuality(
      files: CodeFile[] | string[],
      options?: CodeAnalysisOptions
    ): Promise<CodeQualityMetrics> {
      const codeFiles = await this.getCodeFiles(files);
      
      const totalLines = codeFiles.reduce((sum, file) => sum + file.lines, 0);
      const complexity = this.calculateAverageComplexity(codeFiles);
      const maintainabilityIndex = this.calculateMaintainabilityIndex(codeFiles, complexity);
      const codeSmells = options?.checkCodeSmells !== false 
        ? this.detectCodeSmells(codeFiles, options)
        : [];
      const duplications = options?.checkDuplicates !== false
        ? await this.findDuplications(codeFiles, options)
        : [];
    
      return {
        complexity,
        maintainabilityIndex,
        technicalDebt: this.estimateTechnicalDebt(codeSmells, duplications.length),
        codeSmells,
        duplications,
        linesOfCode: totalLines,
        cyclomaticComplexity: complexity,
      };
    }
  • The private method that implements the maintainability index formula using Halstead volume, complexity, and lines of code.
    private calculateMaintainabilityIndex(files: CodeFile[], complexity: number): number {
      if (files.length === 0) return 100;
    
      const totalLines = files.reduce((sum, file) => sum + file.lines, 0);
      const avgLines = totalLines / files.length;
      
      // Simplified maintainability index calculation
      const halsteadVolume = this.estimateHalsteadVolume(files);
      const mi = 171 - 5.2 * Math.log(halsteadVolume || 1) - 0.23 * complexity - 16.2 * Math.log(avgLines || 1);
      
      // Clamp between 0 and 100
      return Math.max(0, Math.min(100, Math.round(mi * 100) / 100));
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states what the tool does ('calculate maintainability index') without mentioning how it works (e.g., algorithm used, output format, whether it's read-only or has side effects, or any performance considerations). This is insufficient for a tool with no annotation coverage.

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

Conciseness5/5

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

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core action ('calculate') and resource ('maintainability index for code'), making it easy to parse quickly. Every word contributes directly to the tool's purpose.

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?

Given the complexity of code analysis tools and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the maintainability index measures, how results are returned, or any prerequisites (e.g., supported file types). This leaves significant gaps for an agent to use the tool effectively in context with many sibling alternatives.

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?

The input schema has 100% description coverage, with the 'files' parameter clearly documented as 'File paths to analyze'. The description adds no additional meaning beyond this, but since the schema is comprehensive, a baseline score of 3 is appropriate as the schema handles the parameter documentation adequately.

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 verb ('calculate') and resource ('maintainability index for code'), making the tool's purpose understandable. However, it doesn't differentiate from sibling tools like 'calculate_complexity' or 'generate_code_metrics', which also compute code-related metrics, leaving some ambiguity about when to choose this specific tool.

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. With many sibling tools focused on code analysis (e.g., 'analyze_code_quality', 'calculate_complexity'), there's no indication of whether this tool is for specific file types, programming languages, or scenarios, leaving the agent to guess based on the name alone.

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/code-alchemist01/development-tools-mcp-Server'

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