Skip to main content
Glama
code-alchemist01

Development Tools MCP Server

analyze_code_quality

Analyze code quality by detecting complexity, maintainability issues, code smells, and duplications to improve development workflows.

Instructions

Analyze overall code quality including complexity, maintainability, code smells, and duplications

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesFile paths or glob patterns to analyze
includePatternsNoFile patterns to include
excludePatternsNoFile patterns to exclude
maxComplexityNoMaximum allowed complexity
checkDuplicatesNoCheck for duplicate code
checkCodeSmellsNoCheck for code smells

Implementation Reference

  • Handler function block for the 'analyze_code_quality' tool. Processes arguments, reads files using FileReader, calls CodeAnalyzer.analyzeCodeQuality, and returns formatted metrics.
    case 'analyze_code_quality': {
      const files = params.files as string[];
      const options: CodeAnalysisOptions = {
        includePatterns: params.includePatterns as string[],
        excludePatterns: params.excludePatterns as string[],
        maxComplexity: params.maxComplexity as number,
        checkDuplicates: params.checkDuplicates as boolean,
        checkCodeSmells: params.checkCodeSmells as boolean,
      };
    
      const codeFiles = await FileReader.readFiles(files.join(','), {
        ignore: options.excludePatterns,
      });
    
      const metrics = await codeAnalyzer.analyzeCodeQuality(codeFiles, options);
      return Formatters.formatCodeQualityMetrics(metrics);
    }
  • Input schema definition for the 'analyze_code_quality' tool, specifying parameters like files, patterns, options.
    inputSchema: {
      type: 'object',
      properties: {
        files: {
          type: 'array',
          items: { type: 'string' },
          description: 'File paths or glob patterns to analyze',
        },
        includePatterns: {
          type: 'array',
          items: { type: 'string' },
          description: 'File patterns to include',
        },
        excludePatterns: {
          type: 'array',
          items: { type: 'string' },
          description: 'File patterns to exclude',
        },
        maxComplexity: {
          type: 'number',
          description: 'Maximum allowed complexity',
        },
        checkDuplicates: {
          type: 'boolean',
          description: 'Check for duplicate code',
          default: true,
        },
        checkCodeSmells: {
          type: 'boolean',
          description: 'Check for code smells',
          default: true,
        },
      },
      required: ['files'],
    },
  • Tool registration/definition in the codeQualityTools array, including name, description, and input schema.
    {
      name: 'analyze_code_quality',
      description: 'Analyze overall code quality including complexity, maintainability, code smells, and duplications',
      inputSchema: {
        type: 'object',
        properties: {
          files: {
            type: 'array',
            items: { type: 'string' },
            description: 'File paths or glob patterns to analyze',
          },
          includePatterns: {
            type: 'array',
            items: { type: 'string' },
            description: 'File patterns to include',
          },
          excludePatterns: {
            type: 'array',
            items: { type: 'string' },
            description: 'File patterns to exclude',
          },
          maxComplexity: {
            type: 'number',
            description: 'Maximum allowed complexity',
          },
          checkDuplicates: {
            type: 'boolean',
            description: 'Check for duplicate code',
            default: true,
          },
          checkCodeSmells: {
            type: 'boolean',
            description: 'Check for code smells',
            default: true,
          },
        },
        required: ['files'],
      },
    },
  • Core implementation of code quality analysis in CodeAnalyzer class. Computes metrics like complexity, maintainability, smells, duplications.
    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,
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'analyze' implies a read-only operation, the description doesn't clarify whether this tool modifies files, requires specific permissions, has rate limits, or what the output format looks like. For a multi-parameter analysis tool with no annotation coverage, this is insufficient behavioral context.

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 that clearly states the tool's purpose. It's appropriately sized and front-loaded with the core functionality, with zero wasted words or redundant information.

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

Completeness3/5

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

Given the tool's complexity (6 parameters, no output schema, no annotations), the description is minimally adequate but has clear gaps. It states what the tool does but lacks crucial context about when to use it versus specialized siblings, behavioral characteristics, and output format. For a comprehensive analysis tool in a crowded namespace, more guidance would be helpful.

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 100%, so the schema already documents all 6 parameters thoroughly. The description mentions the analysis dimensions (complexity, maintainability, code smells, duplications) which loosely map to some parameters like maxComplexity, checkDuplicates, and checkCodeSmells, but doesn't add significant semantic value beyond what the schema provides. Baseline 3 is appropriate when schema does the heavy lifting.

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's purpose: analyzing code quality across multiple dimensions (complexity, maintainability, code smells, duplications). It uses specific verbs ('analyze') and identifies the resource ('code quality'), but doesn't explicitly differentiate from sibling tools like 'calculate_complexity', 'detect_code_smells', or 'find_duplicate_code' which appear to cover overlapping functionality.

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 multiple sibling tools covering similar aspects (e.g., calculate_complexity, detect_code_smells, find_duplicate_code), there's no indication whether this is a comprehensive analysis tool versus those specialized tools, or what context would make this the appropriate choice.

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