Skip to main content
Glama
jghidalgo

Lambda Performance MCP Server

by jghidalgo

analyze_lambda_performance

Evaluate AWS Lambda function metrics such as cold starts, duration, and errors within specified time ranges. Provides detailed insights to optimize performance and identify issues effectively.

Instructions

Analyze Lambda function performance metrics including cold starts, duration, and errors

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
functionNameYesName of the Lambda function to analyze
includeDetailsNoInclude detailed metrics and logs (default: true)
timeRangeNoTime range for analysis (default: 24h)

Implementation Reference

  • The primary handler function for the analyze_lambda_performance tool. Parses input arguments, delegates analysis to LambdaAnalyzer, and constructs a formatted markdown response with performance summary, metrics, and cold start analysis.
    async analyzeLambdaPerformance(args) { const { functionName, timeRange = '24h', includeDetails = true } = args; const analysis = await this.lambdaAnalyzer.analyzeFunction( functionName, timeRange, includeDetails ); return { content: [ { type: 'text', text: `# Lambda Performance Analysis: ${functionName}\n\n` + `## Summary\n` + `- **Total Invocations**: ${analysis.totalInvocations.toLocaleString()}\n` + `- **Average Duration**: ${analysis.avgDuration}ms\n` + `- **Cold Start Rate**: ${analysis.coldStartRate}%\n` + `- **Error Rate**: ${analysis.errorRate}%\n` + `- **Memory Utilization**: ${analysis.memoryUtilization}%\n\n` + `## Performance Metrics\n` + `- **P50 Duration**: ${analysis.p50Duration}ms\n` + `- **P95 Duration**: ${analysis.p95Duration}ms\n` + `- **P99 Duration**: ${analysis.p99Duration}ms\n` + `- **Max Duration**: ${analysis.maxDuration}ms\n\n` + `## Cold Start Analysis\n` + `- **Total Cold Starts**: ${analysis.coldStarts.total}\n` + `- **Average Cold Start Duration**: ${analysis.coldStarts.avgDuration}ms\n` + `- **Cold Start Pattern**: ${analysis.coldStarts.pattern}\n\n` + `${includeDetails ? this.formatDetailedMetrics(analysis.details) : ''}` } ] }; }
  • index.js:42-63 (registration)
    Tool registration entry in the ListToolsRequest handler, defining the tool name, description, and input schema.
    name: 'analyze_lambda_performance', description: 'Analyze Lambda function performance metrics including cold starts, duration, and errors', inputSchema: { type: 'object', properties: { functionName: { type: 'string', description: 'Name of the Lambda function to analyze' }, timeRange: { type: 'string', enum: ['1h', '6h', '24h', '7d', '30d'], description: 'Time range for analysis (default: 24h)' }, includeDetails: { type: 'boolean', description: 'Include detailed metrics and logs (default: true)' } }, required: ['functionName'] } },
  • Input schema for the analyze_lambda_performance tool, specifying required functionName and optional timeRange and includeDetails parameters.
    inputSchema: { type: 'object', properties: { functionName: { type: 'string', description: 'Name of the Lambda function to analyze' }, timeRange: { type: 'string', enum: ['1h', '6h', '24h', '7d', '30d'], description: 'Time range for analysis (default: 24h)' }, includeDetails: { type: 'boolean', description: 'Include detailed metrics and logs (default: true)' } }, required: ['functionName'] }
  • Key helper method implementing the core Lambda performance analysis: retrieves function config, CloudWatch metrics (invocations, durations, errors), analyzes cold starts from logs, computes statistics (rates, percentiles), and optionally fetches detailed errors, trends, and memory usage.
    async analyzeFunction(functionName, timeRange, includeDetails) { const timeRangeMs = this.parseTimeRange(timeRange); const endTime = new Date(); const startTime = new Date(endTime.getTime() - timeRangeMs); // Get function configuration const functionConfig = await this.getFunctionConfig(functionName); // Get CloudWatch metrics const metrics = await this.getMetrics(functionName, startTime, endTime); // Analyze cold starts from logs const coldStartAnalysis = await this.analyzeColdStartsFromLogs(functionName, startTime, endTime); // Calculate performance statistics const analysis = { functionName, timeRange, totalInvocations: metrics.invocations || 0, avgDuration: metrics.avgDuration || 0, p50Duration: metrics.p50Duration || 0, p95Duration: metrics.p95Duration || 0, p99Duration: metrics.p99Duration || 0, maxDuration: metrics.maxDuration || 0, errorRate: this.calculateErrorRate(metrics.errors, metrics.invocations), coldStartRate: this.calculateColdStartRate(coldStartAnalysis.total, metrics.invocations), memoryUtilization: await this.calculateMemoryUtilization(functionName, startTime, endTime), coldStarts: { total: coldStartAnalysis.total, avgDuration: coldStartAnalysis.avgDuration, pattern: coldStartAnalysis.pattern }, config: functionConfig }; if (includeDetails) { analysis.details = { errors: await this.analyzeErrors(functionName, startTime, endTime), trends: await this.analyzeTrends(functionName, startTime, endTime), memoryUsage: await this.getMemoryUsageDetails(functionName, startTime, endTime) }; } return analysis; }
  • Helper function to format detailed metrics (errors and trends) into markdown when includeDetails is true.
    formatDetailedMetrics(details) { return `## Detailed Metrics\n` + `### Error Analysis\n` + `${details.errors.map(error => `- ${error.type}: ${error.count} occurrences`).join('\n')}\n\n` + `### Performance Trends\n` + `${details.trends.map(trend => `- ${trend}`).join('\n')}\n\n`; }

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