Skip to main content
Glama
jghidalgo

Lambda Performance MCP Server

by jghidalgo

compare_lambda_performance

Analyze and compare AWS Lambda function performance by evaluating metrics such as duration, cold starts, errors, invocations, and costs across specified time ranges to optimize efficiency and reduce expenses.

Instructions

Compare performance metrics between multiple Lambda functions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
functionNamesYesList of Lambda function names to compare
metricsNoMetrics to compare (default: all)
timeRangeNoTime range for comparison (default: 24h)

Implementation Reference

  • Main MCP tool handler that parses arguments, calls LambdaAnalyzer.compareFunctions, and formats the comparison response as markdown.
    async compareLambdaPerformance(args) { const { functionNames, timeRange = '24h', metrics = ['duration', 'cold-starts', 'errors', 'invocations', 'cost'] } = args; const comparison = await this.lambdaAnalyzer.compareFunctions( functionNames, timeRange, metrics ); return { content: [ { type: 'text', text: `# Lambda Performance Comparison\n\n` + `## Functions Analyzed\n` + `${functionNames.map(name => `- ${name}`).join('\n')}\n\n` + `## Performance Comparison\n` + `${this.formatComparisonTable(comparison)}\n\n` + `## Key Insights\n` + `${comparison.insights.map(insight => `- ${insight}`).join('\n')}\n\n` + `## Recommendations\n` + `${comparison.recommendations.map(rec => `- ${rec}`).join('\n')}` } ] }; }
  • Input schema definition for the compare_lambda_performance tool, returned by ListTools handler.
    { name: 'compare_lambda_performance', description: 'Compare performance metrics between multiple Lambda functions', inputSchema: { type: 'object', properties: { functionNames: { type: 'array', items: { type: 'string' }, description: 'List of Lambda function names to compare' }, timeRange: { type: 'string', enum: ['1h', '6h', '24h', '7d'], description: 'Time range for comparison (default: 24h)' }, metrics: { type: 'array', items: { type: 'string', enum: ['duration', 'cold-starts', 'errors', 'invocations', 'cost'] }, description: 'Metrics to compare (default: all)' } }, required: ['functionNames'] } },
  • index.js:220-221 (registration)
    Dispatch registration in the CallToolRequestSchema handler's switch statement.
    case 'compare_lambda_performance': return await this.compareLambdaPerformance(args);
  • Core helper method implementing the comparison logic by analyzing each Lambda function and compiling metrics, insights, and recommendations.
    async compareFunctions(functionNames, timeRange, metrics) { const comparisons = []; for (const functionName of functionNames) { const analysis = await this.analyzeFunction(functionName, timeRange, false); comparisons.push({ name: functionName, values: { duration: analysis.avgDuration, 'cold-starts': analysis.coldStartRate, errors: analysis.errorRate, invocations: analysis.totalInvocations, cost: await this.estimateCost(analysis) } }); } const insights = this.generateComparisonInsights(comparisons); const recommendations = this.generateComparisonRecommendations(comparisons); return { functions: comparisons, metrics, insights, recommendations }; }
  • Helper function to generate key insights from the comparison data.
    generateComparisonInsights(comparisons) { const insights = []; // Find best and worst performers const bestDuration = comparisons.reduce((best, current) => current.values.duration < best.values.duration ? current : best ); const worstColdStart = comparisons.reduce((worst, current) => current.values['cold-starts'] > worst.values['cold-starts'] ? current : worst ); insights.push(`${bestDuration.name} has the best average duration (${bestDuration.values.duration}ms)`); insights.push(`${worstColdStart.name} has the highest cold start rate (${worstColdStart.values['cold-starts']}%)`); return insights; }

Other Tools

Related 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/jghidalgo/lambda-performance-mcp-nodejs'

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