Skip to main content
Glama
jghidalgo

Lambda Performance MCP Server

by jghidalgo

track_cold_starts

Analyze AWS Lambda cold start patterns to identify performance bottlenecks and optimize function initialization times. Specify a function name and time range to track cold start occurrences and durations.

Instructions

Track and analyze cold start patterns for Lambda functions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
functionNameYesName of the Lambda function
timeRangeNoTime range for cold start analysis (default: 24h)

Implementation Reference

  • index.js:64-82 (registration)
    Registration of the track_cold_starts tool in the ListTools response, including name, description, and input schema
    { name: 'track_cold_starts', description: 'Track and analyze cold start patterns for Lambda functions', inputSchema: { type: 'object', properties: { functionName: { type: 'string', description: 'Name of the Lambda function' }, timeRange: { type: 'string', enum: ['1h', '6h', '24h', '7d'], description: 'Time range for cold start analysis (default: 24h)' } }, required: ['functionName'] } },
  • Input schema definition for track_cold_starts tool parameters
    inputSchema: { type: 'object', properties: { functionName: { type: 'string', description: 'Name of the Lambda function' }, timeRange: { type: 'string', enum: ['1h', '6h', '24h', '7d'], description: 'Time range for cold start analysis (default: 24h)' } }, required: ['functionName'] }
  • Tool handler method that processes tool arguments, delegates to ColdStartTracker for analysis, formats the markdown response, and returns it
    async trackColdStarts(args) { const { functionName, timeRange = '24h' } = args; const coldStartData = await this.coldStartTracker.trackColdStarts( functionName, timeRange ); return { content: [ { type: 'text', text: `# Cold Start Analysis: ${functionName}\n\n` + `## Cold Start Statistics\n` + `- **Total Cold Starts**: ${coldStartData.total}\n` + `- **Cold Start Rate**: ${coldStartData.rate}%\n` + `- **Average Cold Start Duration**: ${coldStartData.avgDuration}ms\n` + `- **Longest Cold Start**: ${coldStartData.maxDuration}ms\n\n` + `## Cold Start Patterns\n` + `- **Peak Hours**: ${coldStartData.peakHours.join(', ')}\n` + `- **Frequency**: ${coldStartData.frequency}\n` + `- **Triggers**: ${coldStartData.triggers.join(', ')}\n\n` + `## Optimization Opportunities\n` + `${coldStartData.recommendations.map(rec => `- ${rec}`).join('\n')}\n\n` + `## Timeline\n` + `${this.formatColdStartTimeline(coldStartData.timeline)}` } ] }; }
  • Core helper function in ColdStartTracker that fetches cold start events from CloudWatch Logs, performs analysis on patterns, statistics, and generates recommendations
    async trackColdStarts(functionName, timeRange) { const timeRangeMs = this.parseTimeRange(timeRange); const endTime = new Date(); const startTime = new Date(endTime.getTime() - timeRangeMs); const logGroupName = `/aws/lambda/${functionName}`; try { // Get cold start events const coldStartEvents = await this.getColdStartEvents(logGroupName, startTime, endTime); // Get all invocation events for comparison const allInvocations = await this.getAllInvocations(logGroupName, startTime, endTime); // Analyze patterns const analysis = this.analyzeColdStartPatterns(coldStartEvents, allInvocations, timeRange); return { total: coldStartEvents.length, rate: this.calculateColdStartRate(coldStartEvents.length, allInvocations.length), avgDuration: analysis.avgDuration, maxDuration: analysis.maxDuration, minDuration: analysis.minDuration, peakHours: analysis.peakHours, frequency: analysis.frequency, triggers: analysis.triggers, recommendations: this.generateRecommendations(analysis), timeline: this.createTimeline(coldStartEvents, timeRange), patterns: analysis.patterns, statistics: analysis.statistics }; } catch (error) { console.error('Error tracking cold starts:', error); return this.getEmptyResult(); } }

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