Skip to main content
Glama
sloth-wq

Prompt Auto-Optimizer MCP

by sloth-wq

gepa_restore_backup

Restore the Prompt Auto-Optimizer MCP system from a specific backup, performing integrity validation and creating a pre-restore backup for safety.

Instructions

Restore system from a specific backup

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
backupIdYesID of the backup to restore from
validateIntegrityNoPerform integrity validation before restore
createPreRestoreBackupNoCreate backup before restoration

Implementation Reference

  • Main handler function for 'gepa_restore_backup' tool. Extracts parameters, initializes disaster recovery, calls restoreSystemFromBackup on the DisasterRecoverySystem instance, formats and returns the detailed response including success status, components restored/failed, warnings, and integrity checks.
      private async restoreBackup(params: {
        backupId: string;
        validateIntegrity?: boolean;
        createPreRestoreBackup?: boolean;
      }): Promise<{ content: { type: string; text: string; }[] }> {
        const { backupId, validateIntegrity = true, createPreRestoreBackup = true } = params;
    
        try {
          await this.disasterRecovery.initialize();
          
          const result = await this.disasterRecovery.restoreSystemFromBackup(backupId, {
            validateIntegrity,
            createPreRestoreBackup
          });
    
          return {
            content: [
              {
                type: 'text',
                text: `# System Restore ${result.success ? 'Completed' : 'Failed'}
    
    ## Restore Details
    - **Backup ID**: ${result.backupId}
    - **Success**: ${result.success ? 'Yes' : 'No'}
    - **Restore Time**: ${result.restoreTime} ms
    - **Pre-restore Backup**: ${result.preRestoreBackupId || 'None created'}
    
    ## Components Restored
    ${result.restoredComponents.map(comp => `✅ ${comp}`).join('\n')}
    
    ${result.failedComponents.length > 0 ? `## Failed Components
    ${result.failedComponents.map(comp => `❌ ${comp}`).join('\n')}` : ''}
    
    ${result.warnings.length > 0 ? `## Warnings
    ${result.warnings.map(w => `⚠️ ${w}`).join('\n')}` : ''}
    
    ${result.integrityChecks.length > 0 ? `## Integrity Checks
    ${result.integrityChecks.map(check => `- ${check.component}: ${check.valid ? '✅ Valid' : '❌ Invalid'}`).join('\n')}` : ''}
    
    ${result.success ? 'System has been successfully restored from backup.' : 'Restore completed with errors. Please check the failed components and warnings.'}`,
              },
            ],
          };
        } catch (error) {
          throw new Error(`Failed to restore backup: ${error instanceof Error ? error.message : 'Unknown error'}`);
        }
  • Input schema definition for the gepa_restore_backup tool, specifying parameters backupId (required), validateIntegrity, and createPreRestoreBackup.
    name: 'gepa_restore_backup',
    description: 'Restore system from a specific backup',
    inputSchema: {
      type: 'object',
      properties: {
        backupId: {
          type: 'string',
          description: 'ID of the backup to restore from'
        },
        validateIntegrity: {
          type: 'boolean',
          default: true,
          description: 'Perform integrity validation before restore'
        },
        createPreRestoreBackup: {
          type: 'boolean',
          default: true,
          description: 'Create backup before restoration'
        }
      },
      required: ['backupId']
    }
  • Tool call request handler registration in the MCP server. The switch statement dispatches 'gepa_restore_backup' calls to the restoreBackup method.
      // Handle tool calls
      this.server.setRequestHandler(CallToolRequestSchema, async (request: any) => {
        const { name, arguments: args } = request.params;
    
        try {
          if (!this.isInitialized) {
            throw new Error('GEPA components not properly initialized');
          }
    
          switch (name) {
            case 'gepa_start_evolution':
              return await this.startEvolution(args as unknown as StartEvolutionParams);
            
            case 'gepa_record_trajectory':
              return await this.recordTrajectory(args as unknown as RecordTrajectoryParams);
            
            case 'gepa_evaluate_prompt':
              return await this.evaluatePrompt(args as unknown as EvaluatePromptParams);
            
            case 'gepa_reflect':
              return await this.reflect(args as unknown as ReflectParams);
            
            case 'gepa_get_pareto_frontier':
              return await this.getParetoFrontier(args as unknown as GetParetoFrontierParams);
            
            case 'gepa_select_optimal':
              return await this.selectOptimal(args as unknown as SelectOptimalParams);
            
            // Legacy tools for backward compatibility
            case 'gepa_evolve_prompt':
              return await this.evolvePrompt(args as {
                prompt: string;
                fitness_criteria: string;
                generations?: number;
                population_size?: number;
              });
            
            case 'gepa_analyze_prompt':
              return await this.analyzePrompt(args as {
                prompt: string;
                analysis_type?: string;
              });
            
            case 'gepa_optimize_prompt':
              return await this.optimizePrompt(args as {
                prompt: string;
                optimization_target: string;
                constraints?: Record<string, unknown>;
              });
            
            case 'gepa_generate_variants':
              return await this.generateVariants(args as {
                prompt: string;
                variant_count?: number;
                strategy?: string;
              });
            
            // Disaster Recovery Tools
            case 'gepa_create_backup':
              return await this.createBackup(args as {
                label?: string;
                includeTrajectories?: boolean;
              });
            
            case 'gepa_restore_backup':
              return await this.restoreBackup(args as {
                backupId: string;
                validateIntegrity?: boolean;
                createPreRestoreBackup?: boolean;
              });
            
            case 'gepa_list_backups':
              return await this.listBackups(args as {
                limit?: number;
                filterLabel?: string;
              });
            
            case 'gepa_recovery_status':
              return await this.getRecoveryStatus(args as {
                includeMetrics?: boolean;
              });
            
            case 'gepa_recover_component':
              return await this.recoverComponent(args as {
                componentType: string;
                strategy?: string;
              });
            
            case 'gepa_integrity_check':
              return await this.performIntegrityCheck(args as {
                component?: string;
                autoRepair?: boolean;
              });
            
            default:
              throw new Error(`Unknown tool: ${name}`);
          }
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
          return {
            content: [
              {
                type: 'text',
                text: `Error executing ${name}: ${errorMessage}`,
              },
            ],
            isError: true,
          };
        }
      });
    }
  • Lists all available tools including gepa_restore_backup via the TOOLS array.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: 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/sloth-wq/prompt-auto-optimizer-mcp'

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