Skip to main content
Glama

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'],

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