UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

66 lines 2.83 kB
/** * Get Migration Status Tool - Individual Module * @description Retrieves status information about entity migrations * @since 2025-08-04 * @author Tool Modularization Team * * Migration Status: COMPLETED * Original Method: OptimizelyMCPTools.getMigrationStatus * Complexity: MEDIUM * Dependencies: logger, errorMapper, fs */ import * as fs from 'fs'; /** * Creates the Get Migration Status tool with injected dependencies * @param deps - Injected dependencies (storage, logger, errorMapper, etc.) * @returns Tool definition with handler */ export function createGetMigrationStatusTool(deps) { return { name: 'get_migration_status', requiresCache: false, // This reads from filesystem, not cache category: 'operations', description: 'Get migration status from a checkpoint file', handler: async (args) => { const { checkpoint_path: checkpointPath } = args; try { deps.logger.debug({ checkpointPath }, 'OptimizelyMCPTools.getMigrationStatus: Reading migration checkpoint'); const checkpointContent = await fs.promises.readFile(checkpointPath, 'utf-8'); const checkpoint = JSON.parse(checkpointContent); // Calculate completion percentage const totalEntities = checkpoint.completedEntities.length + (checkpoint.remainingEntities?.length || 0); const completionPercent = totalEntities > 0 ? Math.round((checkpoint.completedEntities.length / totalEntities) * 100) : 0; return { result: 'success', data: { checkpoint_id: checkpoint.id, timestamp: checkpoint.timestamp, phase: checkpoint.phase, completion_percent: completionPercent, completed_entities: checkpoint.completedEntities.length, total_entities: totalEntities, current_entity: checkpoint.currentEntity, mapping_state: checkpoint.mappingState }, metadata: { checkpoint_file: checkpointPath, can_resume: true } }; } catch (error) { deps.logger.error({ checkpointPath, error: error.message }, 'OptimizelyMCPTools.getMigrationStatus: Failed to read checkpoint'); throw deps.errorMapper.toMCPError(error, 'Failed to read migration checkpoint'); } } }; } //# sourceMappingURL=GetMigrationStatus.js.map