Skip to main content
Glama
jghidalgo

Lambda Performance MCP Server

by jghidalgo

analyze_lambda_performance

Analyze AWS Lambda function performance metrics including cold starts, duration, and errors to identify optimization opportunities and reduce costs.

Instructions

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

Input Schema

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

Implementation Reference

  • The main handler function that processes the analyze_lambda_performance tool request, delegates to LambdaAnalyzer for analysis, and formats the results into an MCP text response.
    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) : ''}` } ] }; }
  • Core helper method that performs the actual AWS API calls to Lambda, CloudWatch metrics, and logs to compute comprehensive performance analysis.
    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; }
  • Input schema defining the parameters for the analyze_lambda_performance tool: functionName (required), timeRange, includeDetails.
    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'] }
  • index.js:41-63 (registration)
    Tool registration in the ListTools response, including 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'] } },
  • index.js:211-212 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes requests for this tool to the handler method.
    case 'analyze_lambda_performance': return await this.analyzeLambdaPerformance(args);

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