Skip to main content
Glama
TheAlchemist6

CodeCompass MCP

transform_code

Apply code transformations to modernize, migrate frameworks, improve structure, or convert syntax while preserving logic and comments.

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
transformationsYesList of transformations to apply
languageYesProgramming language of the code
target_languageNoTarget language (for language conversion)
target_frameworkNoTarget framework (for framework migration)
optionsNo

Implementation Reference

  • Tool schema definition for 'transform_code' including input validation schema
    {
      name: 'transform_code',
      description: '🔧 Apply code transformations including syntax changes, structural reorganization, framework migration, and modernization. Combines syntax-level and structural changes.',
      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:236-240 (registration)
    Registration of all tools including 'transform_code' via consolidatedTools in ListToolsRequestSchema handler
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: consolidatedTools,
      };
    });
  • MCP tool handler for 'transform_code' that extracts arguments and delegates to RefactorService.transformCode
    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);
      }
    }
  • Core implementation of code transformation logic in RefactorService, applying specified transformations
    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'],
      };
    }
  • src/index.ts:285-287 (registration)
    Dispatch routing in CallToolRequestSchema handler for 'transform_code' tool
    case 'transform_code':
      result = await handleTransformCode(args);
      break;
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions transformation types but lacks critical behavioral details: whether transformations are destructive (could break code), what permissions or authentication might be needed, rate limits, error handling, or what the output looks like (since no output schema exists). The description is insufficient for a mutation tool with complex parameters.

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

Conciseness4/5

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

The description is appropriately concise with two sentences that efficiently convey the tool's scope. The first sentence lists transformation types clearly, and the second adds useful context about combining syntax and structural changes. No wasted words, though it could be slightly more front-loaded with core 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 tool's complexity (6 parameters with nested objects, mutation functionality), absence of annotations, and no output schema, the description is incomplete. It doesn't address critical context like what the transformation output contains, error conditions, safety considerations, or how to interpret results. For a code transformation tool with significant behavioral implications, this leaves too many gaps.

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 83% (high), so the baseline is 3 even without parameter details in the description. The description adds minimal value beyond the schema by listing transformation categories (syntax, structural, framework, modernization) that align with the 'transformations.type' enum, but doesn't explain parameter interactions or provide examples. It doesn't compensate for the 17% coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/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 with specific verbs ('apply code transformations') and resources ('code'), listing concrete transformation types (syntax changes, structural reorganization, framework migration, modernization). It distinguishes from siblings like analyze_codebase, explain_code, or suggest_improvements by emphasizing active transformation rather than analysis or suggestion.

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. While it mentions 'combines syntax-level and structural changes,' it doesn't specify when to choose transform_code over suggest_improvements (which might recommend changes) or review_code (which might assess code quality). No prerequisites, exclusions, or comparison to sibling tools are provided.

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/TheAlchemist6/codecompass-mcp'

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