get_optimization_recommendations
Analyze AWS Lambda functions to identify performance improvements. Specify function name and analysis type (cold-start, memory, duration, cost, or all) to receive actionable optimization recommendations for enhanced efficiency and reduced costs.
Instructions
Get performance optimization recommendations for Lambda functions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| analysisType | No | Type of optimization analysis (default: all) | |
| functionName | Yes | Name of the Lambda function |
Implementation Reference
- index.js:317-351 (handler)The main handler function for the 'get_optimization_recommendations' tool. Parses arguments, calls PerformanceOptimizer.getRecommendations, and formats the response as markdown content.async getOptimizationRecommendations(args) { const { functionName, analysisType = 'all' } = args; const recommendations = await this.performanceOptimizer.getRecommendations( functionName, analysisType ); return { content: [ { type: 'text', text: `# Optimization Recommendations: ${functionName}\n\n` + `## Priority Recommendations\n` + `${recommendations.priority.map((rec, i) => `${i + 1}. **${rec.title}** (Impact: ${rec.impact})\n` + ` - ${rec.description}\n` + ` - Implementation: ${rec.implementation}\n` + ` - Expected Improvement: ${rec.expectedImprovement}\n` ).join('\n')}\n` + `## Additional Optimizations\n` + `${recommendations.additional.map(rec => `- ${rec}`).join('\n')}\n\n` + `## Configuration Recommendations\n` + `- **Memory**: ${recommendations.config.memory}MB\n` + `- **Timeout**: ${recommendations.config.timeout}s\n` + `- **Runtime**: ${recommendations.config.runtime}\n` + `- **Architecture**: ${recommendations.config.architecture}\n\n` + `## Cost Impact\n` + `- **Current Monthly Cost**: $${recommendations.cost.current}\n` + `- **Optimized Monthly Cost**: $${recommendations.cost.optimized}\n` + `- **Potential Savings**: $${recommendations.cost.savings} (${recommendations.cost.savingsPercent}%)` } ] }; }
- index.js:83-101 (schema)Input schema definition for the tool, specifying parameters functionName (required) and analysisType (optional with enum values).{ name: 'get_optimization_recommendations', description: 'Get performance optimization recommendations for Lambda functions', inputSchema: { type: 'object', properties: { functionName: { type: 'string', description: 'Name of the Lambda function' }, analysisType: { type: 'string', enum: ['cold-start', 'memory', 'duration', 'cost', 'all'], description: 'Type of optimization analysis (default: all)' } }, required: ['functionName'] } },
- index.js:217-218 (registration)Registration of the tool handler in the CallToolRequestSchema switch statement, routing calls to getOptimizationRecommendations method.case 'get_optimization_recommendations': return await this.getOptimizationRecommendations(args);
- src/performance-optimizer.js:6-42 (helper)Core helper method in PerformanceOptimizer class that generates optimization recommendations based on specified analysisType, using various specialized optimization methods.async getRecommendations(functionName, analysisType) { // Get function analysis data const analysis = await this.analyzeFunction(functionName); // Generate recommendations based on analysis type const recommendations = { priority: [], additional: [], config: {}, cost: {} }; switch (analysisType) { case 'cold-start': recommendations.priority = await this.getColdStartOptimizations(analysis); break; case 'memory': recommendations.priority = await this.getMemoryOptimizations(analysis); break; case 'duration': recommendations.priority = await this.getDurationOptimizations(analysis); break; case 'cost': recommendations.priority = await this.getCostOptimizations(analysis); break; case 'all': default: recommendations.priority = await this.getAllOptimizations(analysis); break; } recommendations.additional = await this.getAdditionalOptimizations(analysis); recommendations.config = await this.getConfigurationRecommendations(analysis); recommendations.cost = await this.getCostImpactAnalysis(analysis, recommendations); return recommendations; }