Skip to main content
Glama
jghidalgo

Lambda Performance MCP Server

by jghidalgo

monitor_real_time_performance

Monitor AWS Lambda function performance metrics and receive alerts in real-time to identify issues and optimize execution.

Instructions

Get real-time performance metrics and alerts for Lambda functions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
functionNameYesName of the Lambda function
durationNoMonitoring duration in minutes (default: 5)

Implementation Reference

  • Primary tool handler: destructures args, calls LambdaAnalyzer.monitorRealTime(), formats and returns the response content.
    async monitorRealTimePerformance(args) {
      const { functionName, duration = 5 } = args;
      
      const monitoring = await this.lambdaAnalyzer.monitorRealTime(
        functionName, 
        duration
      );
    
      return {
        content: [
          {
            type: 'text',
            text: `# Real-time Performance Monitoring: ${functionName}\n\n` +
                  `## Live Metrics (Last ${duration} minutes)\n` +
                  `- **Active Invocations**: ${monitoring.activeInvocations}\n` +
                  `- **Recent Invocations**: ${monitoring.recentInvocations}\n` +
                  `- **Average Duration**: ${monitoring.avgDuration}ms\n` +
                  `- **Error Rate**: ${monitoring.errorRate}%\n` +
                  `- **Cold Starts**: ${monitoring.coldStarts}\n\n` +
                  `## Performance Alerts\n` +
                  `${monitoring.alerts.length > 0 ? 
                    monitoring.alerts.map(alert => `${alert}`).join('\n') : 
                    'No performance issues detected'}\n\n` +
                  `## Recent Activity\n` +
                  `${monitoring.recentActivity.map(activity => 
                    `- ${activity.timestamp}: ${activity.event} (${activity.duration}ms)`
                  ).join('\n')}`
          }
        ]
      };
    }
  • Core implementation logic: fetches real-time metrics from CloudWatch, recent activity from logs, checks alerts, computes error rate and returns monitoring data.
    async monitorRealTime(functionName, duration) {
      const endTime = new Date();
      const startTime = new Date(endTime.getTime() - (duration * 60 * 1000));
    
      // Get recent metrics
      const metrics = await this.getMetrics(functionName, startTime, endTime);
      
      // Get recent log events
      const recentActivity = await this.getRecentActivity(functionName, startTime, endTime);
      
      // Check for alerts
      const alerts = await this.checkPerformanceAlerts(functionName, metrics);
    
      return {
        activeInvocations: metrics.concurrentExecutions || 0,
        recentInvocations: metrics.invocations || 0,
        avgDuration: metrics.avgDuration || 0,
        errorRate: this.calculateErrorRate(metrics.errors, metrics.invocations),
        coldStarts: await this.getRecentColdStarts(functionName, startTime, endTime),
        alerts,
        recentActivity
      };
    }
  • Tool schema definition including input schema with functionName (required) and optional duration.
    {
      name: 'monitor_real_time_performance',
      description: 'Get real-time performance metrics and alerts for Lambda functions',
      inputSchema: {
        type: 'object',
        properties: {
          functionName: {
            type: 'string',
            description: 'Name of the Lambda function'
          },
          duration: {
            type: 'number',
            description: 'Monitoring duration in minutes (default: 5)'
          }
        },
        required: ['functionName']
      }
    }
  • index.js:232-233 (registration)
    Tool dispatch/registration in the CallToolRequestSchema switch statement.
    case 'monitor_real_time_performance':
      return await this.monitorRealTimePerformance(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