Skip to main content
Glama
sloth-wq

Prompt Auto-Optimizer MCP

by sloth-wq

gepa_recover_component

Recover malfunctioning components in the Prompt Auto-Optimizer MCP by restarting, restoring from backup, rebuilding, or resetting to defaults to restore prompt optimization functionality.

Instructions

Recover a specific GEPA component

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentTypeYesType of component to recover
strategyNoRecovery strategy to userestart

Implementation Reference

  • Defines the input schema, description, and parameters for the gepa_recover_component MCP tool.
      name: 'gepa_recover_component',
      description: 'Recover a specific GEPA component',
      inputSchema: {
        type: 'object',
        properties: {
          componentType: {
            type: 'string',
            enum: ['evolution_engine', 'pareto_frontier', 'llm_adapter', 'trajectory_store', 'memory_cache'],
            description: 'Type of component to recover'
          },
          strategy: {
            type: 'string',
            enum: ['restart', 'restore_from_backup', 'rebuild', 'reset_to_defaults'],
            default: 'restart',
            description: 'Recovery strategy to use'
          }
        },
        required: ['componentType']
      }
    },
  • Registers the gepa_recover_component tool in the MCP server's CallToolRequestSchema handler switch statement.
    case 'gepa_recover_component':
      return await this.recoverComponent(args as {
        componentType: string;
        strategy?: string;
      });
  • MCP server handler method for gepa_recover_component tool. Maps parameters, calls DisasterRecoverySystem.recoverComponent, handles response formatting and errors.
      private async recoverComponent(params: {
        componentType: string;
        strategy?: string;
      }): Promise<{ content: { type: string; text: string; }[] }> {
        const { componentType, strategy = 'restart' } = params;
    
        try {
          await this.disasterRecovery.initialize();
          
          // Map component types to internal types
          const componentMap: Record<string, any> = {
            'evolution_engine': 'evolution_engine',
            'pareto_frontier': 'pareto_frontier', 
            'llm_adapter': 'llm_adapter',
            'trajectory_store': 'trajectory_store',
            'memory_cache': 'memory_cache'
          };
    
          const mappedComponentType = componentMap[componentType];
          if (!mappedComponentType) {
            throw new Error(`Unknown component type: ${componentType}`);
          }
    
          const strategyMap: Record<string, any> = {
            'restart': 'restart',
            'restore_from_backup': 'restore_from_backup', 
            'rebuild': 'rebuild',
            'reset_to_defaults': 'reset_to_defaults'
          };
    
          const mappedStrategy = strategyMap[strategy];
          if (!mappedStrategy) {
            throw new Error(`Unknown recovery strategy: ${strategy}`);
          }
    
          const result = await this.disasterRecovery.recoverComponent(mappedComponentType, mappedStrategy);
    
          return {
            content: [
              {
                type: 'text',
                text: `# Component Recovery ${result.success ? 'Completed' : 'Failed'}
    
    ## Recovery Details
    - **Component**: ${componentType}
    - **Strategy**: ${strategy}
    - **Success**: ${result.success ? 'Yes' : 'No'}
    - **Duration**: ${result.duration} ms
    - **Start Time**: ${result.startTime.toISOString()}
    - **End Time**: ${result.endTime?.toISOString() || 'In progress'}
    
    ## Recovery Logs
    ${result.logs.map(log => `[${log}]`).join('\n')}
    
    ${result.preRecoveryState ? `## Pre-Recovery State
    - Status: ${result.preRecoveryState.status}
    - Last Action: ${result.preRecoveryState.lastAction}` : ''}
    
    ${result.postRecoveryState ? `## Post-Recovery State  
    - Status: ${result.postRecoveryState.status}
    - Last Action: ${result.postRecoveryState.lastAction}` : ''}
    
    ${result.error ? `## Error
    ${result.error.message}` : ''}
    
    ${result.success ? `Component ${componentType} has been successfully recovered using ${strategy} strategy.` : `Component recovery failed. Check the error details and logs above.`}`,
              },
            ],
          };
        } catch (error) {
          throw new Error(`Failed to recover component: ${error instanceof Error ? error.message : 'Unknown error'}`);
        }
      }
  • Core implementation of component recovery logic in ComponentRecoveryManager. Orchestrates the recovery process including strategy execution, health checks, and state management.
    async recoverComponent(
      componentType: ComponentType,
      strategy?: RecoveryStrategy
    ): Promise<RecoveryAttempt> {
      return this.resilience.executeWithFullProtection(
        async () => {
          // Check if component is already being recovered
          const activeRecovery = Array.from(this.activeRecoveries.values())
            .find(r => r.componentType === componentType && !r.endTime);
          
          if (activeRecovery) {
            throw new Error(`Component ${componentType} is already being recovered`);
          }
          
          // Get component configuration
          const componentConfig = this.config.componentConfigs.get(componentType);
          if (!componentConfig) {
            throw new Error(`No configuration found for component: ${componentType}`);
          }
          
          // Determine recovery strategy
          const selectedStrategy = strategy || this.selectOptimalStrategy(componentType);
          
          // Create recovery attempt
          const attempt: RecoveryAttempt = {
            id: this.generateRecoveryId(),
            componentType,
            strategy: selectedStrategy,
            startTime: new Date(),
            success: false,
            logs: [],
            preRecoveryState: await this.captureComponentState(componentType)
          };
          
          this.activeRecoveries.set(attempt.id, attempt);
          
          try {
            // Execute recovery strategy
            await this.executeRecoveryStrategy(attempt);
            
            attempt.success = true;
            attempt.endTime = new Date();
            attempt.duration = attempt.endTime.getTime() - attempt.startTime.getTime();
            attempt.postRecoveryState = await this.captureComponentState(componentType);
            
            // Update component health
            await this.updateComponentHealth(componentType);
            
            // Record recovery history
            this.recordRecoveryAttempt(attempt);
            
            this.emit('componentRecovered', attempt);
            
          } catch (error) {
            attempt.success = false;
            attempt.error = error as Error;
            attempt.endTime = new Date();
            attempt.duration = attempt.endTime.getTime() - attempt.startTime.getTime();
            attempt.logs.push(`Recovery failed: ${(error as Error).message}`);
            
            this.recordRecoveryAttempt(attempt);
            
            this.emit('componentRecoveryFailed', attempt);
            throw error;
            
          } finally {
            this.activeRecoveries.delete(attempt.id);
          }
          
          return attempt;
        },
        {
          serviceName: 'component-recovery',
          context: {
            name: 'recover-component',
            priority: 'high'
          }
        }
      );
    }
  • Proxy method in DisasterRecoverySystem that delegates to ComponentRecoveryManager.recoverComponent.
    async recoverComponent(componentType: ComponentType, strategy?: RecoveryStrategy): Promise<RecoveryAttempt> {
      return this.componentRecoveryManager.recoverComponent(componentType, strategy);
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'recover' but doesn't specify whether this is a destructive operation, what permissions are needed, potential side effects, or expected outcomes. This leaves critical behavioral traits unclear for a tool that likely involves system changes.

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

Conciseness5/5

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

The description is a single, direct sentence with no wasted words. It is appropriately sized and front-loaded, efficiently stating the tool's core function without unnecessary elaboration.

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 complexity of a recovery operation with no annotations or output schema, the description is incomplete. It fails to address behavioral aspects like safety, permissions, or result format, leaving gaps in understanding how to use the tool effectively in context with its siblings.

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?

The input schema has 100% description coverage, with clear enums and defaults for both parameters. The description adds no additional meaning beyond the schema, such as explaining the implications of different component types or strategies. Since schema coverage is high, the baseline score of 3 is appropriate.

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

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the action ('recover') and target ('a specific GEPA component'), which provides a basic purpose. However, it lacks specificity about what 'recover' entails and doesn't differentiate from sibling tools like 'gepa_recovery_status' or 'gepa_restore_backup', making it somewhat vague.

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?

No guidance is provided on when to use this tool versus alternatives such as 'gepa_recovery_status' for checking status or 'gepa_restore_backup' for backup restoration. The description implies usage for recovery but offers no context on prerequisites, timing, or exclusions.

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/sloth-wq/prompt-auto-optimizer-mcp'

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