Skip to main content
Glama
jghidalgo

Lambda Performance MCP Server

by jghidalgo

compare_lambda_performance

Analyze and compare AWS Lambda function performance metrics including duration, cold starts, errors, invocations, and costs across specified time ranges to identify optimization opportunities.

Instructions

Compare performance metrics between multiple Lambda functions

Input Schema

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

Implementation Reference

  • The main handler function for the 'compare_lambda_performance' tool. Parses input arguments, delegates comparison logic to LambdaAnalyzer.compareFunctions, formats the results including a markdown table, insights, and recommendations into a text response.
    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, specifying required functionNames array and optional timeRange and metrics parameters.
    { 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'] } },
  • Core comparison utility that analyzes performance metrics for each specified Lambda function using analyzeFunction, extracts relevant metric values, generates insights and recommendations, and returns structured comparison data used by the tool handler.
    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 }; }
  • index.js:220-221 (registration)
    Dispatch registration in the CallToolRequest handler switch statement, mapping the tool name to the compareLambdaPerformance handler.
    case 'compare_lambda_performance': return await this.compareLambdaPerformance(args);
  • Helper function to format comparison data into a markdown table, used in the tool handler response.
    formatComparisonTable(comparison) { const headers = ['Function', ...comparison.metrics]; const rows = comparison.functions.map(func => [ func.name, ...comparison.metrics.map(metric => func.values[metric]) ]); return `| ${headers.join(' | ')} |\n` + `| ${headers.map(() => '---').join(' | ')} |\n` + rows.map(row => `| ${row.join(' | ')} |`).join('\n'); }

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