Skip to main content
Glama
code-alchemist01

Development Tools MCP Server

suggest_refactoring

Analyzes code files to identify refactoring opportunities that improve maintainability and reduce complexity.

Instructions

Suggest refactoring opportunities based on code analysis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesFile paths to analyze

Implementation Reference

  • The switch case in handleCodeQualityTool that implements the 'suggest_refactoring' tool. It reads the specified files, analyzes their code quality, and returns a list of refactoring suggestions based on detected code smells and duplications.
    case 'suggest_refactoring': {
      const files = params.files as string[];
      const codeFiles = await FileReader.readFiles(files.join(','));
      const metrics = await codeAnalyzer.analyzeCodeQuality(codeFiles);
    
      const suggestions = [
        ...metrics.codeSmells.map((smell) => ({
          type: 'code_smell',
          location: smell.location,
          description: smell.description,
          suggestion: smell.suggestion || 'Consider refactoring',
          priority: smell.severity === 'critical' || smell.severity === 'high' ? 'high' : 'medium',
        })),
        ...metrics.duplications.map((dup) => ({
          type: 'duplication',
          location: dup.firstFile,
          description: `Duplicate code found with ${dup.secondFile}`,
          suggestion: 'Extract common code into shared function',
          priority: 'medium',
        })),
      ];
    
      return suggestions;
    }
  • The tool registration object for 'suggest_refactoring' exported in the codeQualityTools array, defining its name, description, and input schema requiring an array of file paths.
    {
      name: 'suggest_refactoring',
      description: 'Suggest refactoring opportunities based on code analysis',
      inputSchema: {
        type: 'object',
        properties: {
          files: {
            type: 'array',
            items: { type: 'string' },
            description: 'File paths to analyze',
          },
        },
        required: ['files'],
      },
    },
  • The input schema for the 'suggest_refactoring' tool, specifying an object with a required 'files' array of strings.
    inputSchema: {
      type: 'object',
      properties: {
        files: {
          type: 'array',
          items: { type: 'string' },
          description: 'File paths to analyze',
        },
      },
      required: ['files'],
Behavior2/5

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

With no annotations, the description carries full burden but only states it 'suggests' based on analysis. It doesn't disclose behavioral traits such as whether it's read-only, what analysis methods it uses, if it requires specific permissions, or what the output format looks like, leaving significant gaps.

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 zero waste. It's front-loaded with the core purpose and appropriately sized for the tool's complexity.

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 no annotations, no output schema, and a single parameter with high schema coverage, the description is incomplete. It doesn't explain what refactoring opportunities are suggested, how they're presented, or any behavioral context, making it inadequate for effective use.

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 the 'files' parameter. The description adds no additional meaning beyond implying code analysis, which is minimal value over the schema. Baseline 3 is appropriate as the 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 verb ('suggest') and resource ('refactoring opportunities'), specifying it's based on code analysis. It distinguishes from siblings like 'detect_code_smells' or 'find_duplicate_code' by focusing on suggestions rather than detection, but doesn't explicitly differentiate them.

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?

No guidance on when to use this tool versus alternatives like 'detect_code_smells' or 'analyze_code_quality' is provided. The description implies usage for code analysis but lacks context about prerequisites, appropriate scenarios, or exclusions.

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