Skip to main content
Glama
TheAlchemist6

CodeCompass MCP

transform_code

Apply syntax and structural code transformations for renaming, performance optimization, framework migration, and modernization. Supports multiple programming languages and preserves business logic.

Instructions

🔧 Apply code transformations including syntax changes, structural reorganization, framework migration, and modernization. Combines syntax-level and structural changes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesSource code to transform
languageYesProgramming language of the code
optionsNo
target_frameworkNoTarget framework (for framework migration)
target_languageNoTarget language (for language conversion)
transformationsYesList of transformations to apply

Implementation Reference

  • Core implementation of the transform_code tool. Applies a series of transformations (naming, modernize, etc.) to the input code and returns the transformed code with changes and warnings.
    async transformCode(code: string, transformations: any[], language: string, target_language?: string, options: any = {}): Promise<any> { let transformedCode = code; const changes = []; const warnings = []; for (const transformation of transformations) { switch (transformation.type) { case 'naming': const namingResult = await this.transformNamingConvention(transformedCode, transformation.options); transformedCode = namingResult.code; changes.push(...namingResult.changes); break; case 'modernize': const modernizeResult = await this.modernizeCode(transformedCode, language); transformedCode = modernizeResult.refactoredCode; changes.push(...modernizeResult.changes); break; case 'performance': warnings.push('Performance optimization not implemented'); break; case 'security': warnings.push('Security transformation not implemented'); break; } } return { originalCode: code, transformedCode, changes, warnings, instructions: ['Review transformed code for correctness'], }; }
  • Input schema definition for the transform_code tool, specifying parameters like code, transformations list, language, and options.
    inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'Source code to transform', }, transformations: { type: 'array', items: { type: 'object', properties: { type: { type: 'string', enum: ['naming', 'modernize', 'framework', 'performance', 'security', 'structure', 'migration'], description: 'Type of transformation', }, options: { type: 'object', description: 'Transformation-specific options', }, }, required: ['type'], }, description: 'List of transformations to apply', }, language: { type: 'string', description: 'Programming language of the code', }, target_language: { type: 'string', description: 'Target language (for language conversion)', }, target_framework: { type: 'string', description: 'Target framework (for framework migration)', }, options: { type: 'object', properties: { preserve_comments: { type: 'boolean', description: 'Preserve code comments', default: true, }, preserve_logic: { type: 'boolean', description: 'Preserve business logic during transformation', default: true, }, update_imports: { type: 'boolean', description: 'Update import paths automatically', default: true, }, include_instructions: { type: 'boolean', description: 'Include transformation instructions', default: true, }, validate_syntax: { type: 'boolean', description: 'Validate syntax after transformation', default: true, }, }, }, }, required: ['code', 'transformations', 'language'], },
  • src/index.ts:285-287 (registration)
    Tool dispatch registration in the main switch statement handling CallToolRequestSchema.
    case 'transform_code': result = await handleTransformCode(args); break;
  • Wrapper handler function in index.ts that extracts arguments and delegates to refactorService.transformCode, handling response formatting and errors.
    async function handleTransformCode(args: any) { try { const { code, transformations, language, target_language, options = {} } = args; const result = await refactorService.transformCode( code, transformations, language, target_language, options ); const response = createResponse(result); return formatToolResponse(response); } catch (error) { const response = createResponse(null, error); return formatToolResponse(response); } }

Other Tools

Related 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