Skip to main content
Glama
sloth-wq

Prompt Auto-Optimizer MCP

by sloth-wq

gepa_get_pareto_frontier

Retrieve optimal prompt candidates from the Pareto frontier for AI prompt optimization, filtering by performance thresholds and task types to identify balanced solutions.

Instructions

Retrieve optimal candidates from Pareto frontier

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
minPerformanceNoMinimum performance threshold for candidates (optional)
taskFilterNoFilter candidates by specific task types (optional)
limitNoMaximum number of candidates to return

Implementation Reference

  • The handler function that implements the core logic for the 'gepa_get_pareto_frontier' tool. It fetches the Pareto frontier, applies optional filters for minimum performance and task types, limits the results, and returns formatted statistics and top candidates.
      private async getParetoFrontier(params: GetParetoFrontierParams): Promise<{
        content: { type: string; text: string; }[];
      }> {
        const { minPerformance, taskFilter, limit = 10 } = params;
    
        try {
          // Get current Pareto frontier
          const frontierCandidates = this.paretoFrontier.getFrontier();
          
          // Apply filters
          let filteredCandidates = frontierCandidates;
    
          if (minPerformance !== undefined) {
            filteredCandidates = filteredCandidates.filter(
              frontierPoint => frontierPoint.candidate.averageScore >= minPerformance
            );
          }
    
          if (taskFilter && taskFilter.length > 0) {
            filteredCandidates = filteredCandidates.filter(
              _candidate => {
                // Trajectory ID would be available from candidate.candidate.id if needed
                // In a real implementation, you'd check which tasks the trajectory covered
                return true; // Simplified for now
              }
            );
          }
    
          // Sort by fitness and limit results
          const limitedCandidates = filteredCandidates
            .sort((a, b) => b.candidate.averageScore - a.candidate.averageScore)
            .slice(0, limit);
    
          // Get frontier statistics
          const stats = this.paretoFrontier.getStatistics();
    
          return {
            content: [
              {
                type: 'text',
                text: `# Pareto Frontier Results
    
    ## Query Parameters
    - **Minimum Performance**: ${minPerformance ?? 'None'}
    - **Task Filter**: ${taskFilter?.join(', ') || 'None'}
    - **Limit**: ${limit}
    
    ## Frontier Statistics
    - **Total Candidates**: ${frontierCandidates.length}
    - **Filtered Candidates**: ${filteredCandidates.length}
    - **Returned**: ${limitedCandidates.length}
    - **Frontend Size**: ${stats.frontierSize}
    - **Average Rank**: ${stats.averageRank.toFixed(3)}
    
    ## Top Candidates
    ${limitedCandidates.map((frontierPoint, idx) => 
      `### ${idx + 1}. Candidate ${frontierPoint.candidate.id}
    - **Fitness Score**: ${frontierPoint.candidate.averageScore.toFixed(3)}
    - **Generation**: ${frontierPoint.candidate.generation}
    - **Parent ID**: ${frontierPoint.candidate.parentId || 'None'}
    - **Mutation Type**: ${frontierPoint.candidate.mutationType || 'Unknown'}`
    ).join('\n\n')}
    
    ## Frontier Quality Metrics
    - **Total Candidates**: ${stats.totalCandidates}
    - **Frontend Size**: ${stats.frontierSize}
    - **Average Rank**: ${stats.averageRank.toFixed(3)}
    
    Use \`gepa_select_optimal\` to choose the best candidate for your specific context.`,
              },
            ],
          };
        } catch (error) {
          throw new Error(`Failed to retrieve Pareto frontier: ${error instanceof Error ? error.message : 'Unknown error'}`);
        }
      }
  • The tool schema definition including input schema for parameters: minPerformance, taskFilter, and limit. This defines the expected input structure for the MCP tool.
    {
      name: 'gepa_get_pareto_frontier',
      description: 'Retrieve optimal candidates from Pareto frontier',
      inputSchema: {
        type: 'object',
        properties: {
          minPerformance: {
            type: 'number',
            description: 'Minimum performance threshold for candidates (optional)'
          },
          taskFilter: {
            type: 'array',
            items: { type: 'string' },
            description: 'Filter candidates by specific task types (optional)'
          },
          limit: {
            type: 'number',
            default: 10,
            description: 'Maximum number of candidates to return'
          }
        }
      }
    },
  • Registration of the tool handler in the MCP request handler switch statement, mapping the tool name to the getParetoFrontier method.
    case 'gepa_get_pareto_frontier':
      return await this.getParetoFrontier(args as unknown as GetParetoFrontierParams);
  • TypeScript interface defining the input parameters for the getParetoFrontier handler.
    export interface GetParetoFrontierParams {
      minPerformance?: number;
      taskFilter?: string[];
      limit?: number;
    }
  • Core helper method in ParetoFrontier class that returns the current non-dominated candidates, used by the tool handler.
    getFrontier(): ParetoPoint[] {
      return [...this.frontier];
  • Initialization of the ParetoFrontier instance used by the tool, defining objectives for performance and diversity.
    // Initialize Pareto frontier
    this.paretoFrontier = new ParetoFrontier({
      maxSize: 100,
      objectives: [
        { 
          name: 'performance', 
          direction: 'maximize', 
          weight: 0.7,
          extractor: (candidate: GEPAPromptCandidate) => candidate.averageScore
        },
        { 
          name: 'diversity', 
          direction: 'maximize', 
          weight: 0.3,
          extractor: (candidate: GEPAPromptCandidate) => candidate.generation / 10 // Simple diversity metric
        }
      ],
      archiveEnabled: true,
      samplingStrategy: { name: 'ucb', parameters: { exploration: 1.4 } }
    });
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'retrieve' which implies a read operation, but doesn't specify whether this is a safe operation, if it requires specific permissions, what happens on failure, or any rate limits. The description is too brief to adequately cover behavioral traits for a tool with no annotation support.

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 a single, efficient sentence with no wasted words, making it appropriately concise. However, it could be more front-loaded with critical details, but given its brevity, it scores well for structure.

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 (involving Pareto frontiers and candidate selection), no annotations, and no output schema, the description is incomplete. It doesn't explain what 'optimal candidates' are, how they're determined, what the return format looks like, or any error conditions. This leaves significant gaps for an AI agent to understand the tool fully.

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 100%, so the schema already documents all parameters (minPerformance, taskFilter, limit) with their types and optional/default status. The description adds no additional meaning beyond what's in the schema, such as explaining how 'optimal candidates' relate to these parameters or providing examples. Baseline 3 is appropriate when the schema does the heavy lifting.

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 'Retrieve optimal candidates from Pareto frontier' states a clear verb ('Retrieve') and resource ('optimal candidates from Pareto frontier'), but it's somewhat vague about what 'optimal candidates' specifically means in this context. It doesn't distinguish this tool from sibling tools like 'gepa_select_optimal', which might have overlapping functionality.

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 like 'gepa_select_optimal' or other sibling tools. It lacks context about prerequisites, when this tool is appropriate, or any exclusions, leaving the agent with minimal usage direction.

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