Lambda Performance MCP Server
The Lambda Performance MCP Server is a Node.js-based tool that provides comprehensive analysis, monitoring, and optimization of AWS Lambda functions. It enables you to:
Analyze performance metrics including cold starts, duration, memory usage, error rates, and invocation counts for individual functions
Track cold start patterns and frequency to identify optimization opportunities
Get targeted optimization recommendations for cold start performance, memory allocation, execution duration, and cost reduction
Compare performance metrics (duration, cold starts, errors, invocations, cost) across multiple Lambda functions over specified time ranges
List all Lambda functions in your AWS account with optional basic performance metrics
Analyze memory utilization and provide right-sizing recommendations to optimize resource allocation
Perform cost analysis for individual functions or across your entire account to identify cost optimization opportunities
Monitor real-time performance metrics and receive alerts for ongoing Lambda function monitoring
Provides comprehensive performance analysis, cold start tracking, memory utilization monitoring, cost analysis, and optimization recommendations for AWS Lambda functions through CloudWatch metrics and logs
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Lambda Performance MCP Server analyze cold starts for my-api-function over the last week"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Lambda Performance MCP Server (Node.js)
A comprehensive Model Context Protocol (MCP) server for analyzing AWS Lambda performance, tracking cold starts, and providing optimization recommendations. Built with Node.js and the AWS SDK v3.
Features
Performance Analysis
Comprehensive Metrics: Duration, memory usage, error rates, invocation counts
Cold Start Tracking: Detailed analysis of cold start patterns and frequency
Real-time Monitoring: Live performance metrics and alerts
Cost Analysis: Detailed cost breakdown and optimization opportunities
Advanced Analytics
Percentile Analysis: P50, P90, P95, P99 duration metrics
Memory Utilization: Right-sizing recommendations based on actual usage
Error Pattern Analysis: Identify and categorize error types
Trend Analysis: Performance trends over time
Optimization Recommendations
Cold Start Optimization: Provisioned concurrency, package size, initialization
Memory Right-sizing: Optimal memory allocation based on usage patterns
Cost Optimization: ARM architecture, duration optimization, resource efficiency
Performance Tuning: Code optimization, connection pooling, caching strategies
Comparative Analysis
Multi-function Comparison: Compare performance across multiple Lambda functions
Benchmarking: Identify best and worst performers
Resource Utilization: Compare memory, duration, and cost metrics
Related MCP server: Cloud FinOps Analyst MCP Server
Installation
Clone the repository:
git clone <repository-url>
cd lambda-performance-mcp-nodejsInstall dependencies:
npm installConfigure environment:
cp .env.example .env
# Edit .env with your AWS credentials and configurationSet up AWS credentials:
# Option 1: Environment variables
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_REGION=us-east-1
# Option 2: AWS CLI profile
aws configure --profile lambda-analyzer
export AWS_PROFILE=lambda-analyzer
# Option 3: IAM roles (for EC2/Lambda execution)Required AWS Permissions
The MCP server requires the following AWS permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"lambda:ListFunctions",
"lambda:GetFunction",
"lambda:GetFunctionConfiguration",
"cloudwatch:GetMetricStatistics",
"cloudwatch:GetMetricData",
"logs:FilterLogEvents",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams"
],
"Resource": "*"
}
]
}Usage
Running the MCP Server
# Start the server
npm start
# Development mode with auto-reload
npm run devAvailable Tools
1. Analyze Lambda Performance
{
"name": "analyze_lambda_performance",
"arguments": {
"functionName": "my-lambda-function",
"timeRange": "24h",
"includeDetails": true
}
}2. Track Cold Starts
{
"name": "track_cold_starts",
"arguments": {
"functionName": "my-lambda-function",
"timeRange": "24h"
}
}3. Get Optimization Recommendations
{
"name": "get_optimization_recommendations",
"arguments": {
"functionName": "my-lambda-function",
"analysisType": "all"
}
}4. Compare Lambda Performance
{
"name": "compare_lambda_performance",
"arguments": {
"functionNames": ["function-1", "function-2", "function-3"],
"timeRange": "24h",
"metrics": ["duration", "cold-starts", "errors", "cost"]
}
}5. List Lambda Functions
{
"name": "list_lambda_functions",
"arguments": {
"runtime": "nodejs18.x",
"includeMetrics": true
}
}6. Analyze Memory Utilization
{
"name": "analyze_memory_utilization",
"arguments": {
"functionName": "my-lambda-function",
"timeRange": "24h"
}
}7. Get Cost Analysis
{
"name": "get_cost_analysis",
"arguments": {
"functionName": "my-lambda-function",
"timeRange": "30d"
}
}8. Monitor Real-time Performance
{
"name": "monitor_real_time_performance",
"arguments": {
"functionName": "my-lambda-function",
"duration": 5
}
}Configuration with MCP Clients
To use this MCP server with MCP clients, add it to your MCP configuration:
Workspace Configuration (.mcp/settings/mcp.json)
{
"mcpServers": {
"lambda-performance": {
"command": "node",
"args": ["path/to/lambda-performance-mcp-nodejs/index.js"],
"env": {
"AWS_REGION": "us-east-1",
"AWS_ACCESS_KEY_ID": "your_access_key",
"AWS_SECRET_ACCESS_KEY": "your_secret_key"
},
"disabled": false,
"autoApprove": [
"list_lambda_functions",
"analyze_lambda_performance",
"track_cold_starts"
]
}
}
}Global Configuration (~/.mcp/settings/mcp.json)
{
"mcpServers": {
"lambda-performance": {
"command": "node",
"args": ["path/to/lambda-performance-mcp-nodejs/index.js"],
"env": {
"AWS_PROFILE": "default"
},
"disabled": false
}
}
}Key Features Explained
Cold Start Analysis
Pattern Detection: Identifies when and why cold starts occur
Duration Analysis: Tracks initialization times and optimization opportunities
Trigger Identification: Determines what causes cold starts (idle time, scaling, deployments)
Timeline Visualization: Shows cold start frequency over time
Performance Optimization
Memory Right-sizing: Analyzes actual memory usage vs. allocated memory
Duration Optimization: Identifies performance bottlenecks and optimization opportunities
Cost Optimization: Provides recommendations to reduce Lambda costs
Architecture Recommendations: Suggests ARM vs x86 based on workload compatibility
Real-time Monitoring
Live Metrics: Current invocation rates, duration, and error rates
Performance Alerts: Automatic detection of performance issues
Activity Tracking: Recent invocation history and patterns
Example Outputs
Performance Analysis
# Lambda Performance Analysis: my-function
## Summary
- **Total Invocations**: 15,432
- **Average Duration**: 245ms
- **Cold Start Rate**: 12.3%
- **Error Rate**: 0.8%
- **Memory Utilization**: 67%
## Performance Metrics
- **P50 Duration**: 180ms
- **P95 Duration**: 450ms
- **P99 Duration**: 890ms
- **Max Duration**: 1,200ms
## Cold Start Analysis
- **Total Cold Starts**: 1,898
- **Average Cold Start Duration**: 1,200ms
- **Cold Start Pattern**: Moderate frequency during low trafficOptimization Recommendations
# Optimization Recommendations: my-function
## Priority Recommendations
1. **Right-size Memory Allocation** (Impact: High)
- Current memory is over-provisioned
- Implementation: Reduce memory from 512MB to 256MB
- Expected Improvement: Reduce costs by 25%
2. **Optimize Cold Start Performance** (Impact: High)
- High cold start rate detected
- Implementation: Implement provisioned concurrency for 2-3 instances
- Expected Improvement: Reduce cold starts by 85%Troubleshooting
Common Issues
Permission Errors
Ensure AWS credentials have required permissions
Check CloudWatch Logs access for cold start analysis
No Data Available
Verify function name is correct
Check if function has been invoked in the specified time range
Ensure CloudWatch logging is enabled
Connection Timeouts
Check AWS region configuration
Verify network connectivity to AWS services
Debug Mode
# Enable debug logging
export LOG_LEVEL=debug
npm startContributing
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Submit a pull request
Support
For issues and questions:
Check the troubleshooting section
Review AWS permissions
Verify environment configuration
Check CloudWatch Logs for detailed error messages
Available Tools
8 toolsanalyze_lambda_performanceC
Analyze Lambda function performance metrics including cold starts, duration, and errors
Inputs: functionName (required), timeRange, includeDetails.
analyze_memory_utilizationC
Analyze memory utilization and provide right-sizing recommendations
Inputs: functionName (required), timeRange.
compare_lambda_performanceB
Compare performance metrics between multiple Lambda functions
Inputs: functionNames (required), timeRange, metrics.
get_cost_analysisC
Analyze Lambda function costs and identify optimization opportunities
Inputs: functionName, timeRange.
get_optimization_recommendationsC
Get performance optimization recommendations for Lambda functions
Inputs: functionName (required), analysisType.
list_lambda_functionsC
List all Lambda functions in the account with basic performance info
Inputs: runtime, includeMetrics.
monitor_real_time_performanceC
Get real-time performance metrics and alerts for Lambda functions
Inputs: functionName (required), duration.
track_cold_startsC
Track and analyze cold start patterns for Lambda functions
Inputs: functionName (required), timeRange.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Most tools have distinct purposes, such as analyze_lambda_performance for general metrics, analyze_memory_utilization for memory-specific analysis, and compare_lambda_performance for comparisons. However, analyze_lambda_performance and monitor_real_time_performance could be confused, as both involve performance metrics, though one is general analysis and the other is real-time monitoring.
All tool names follow a consistent verb_noun pattern using snake_case, such as analyze_lambda_performance, list_lambda_functions, and track_cold_starts. This uniformity makes the tool set predictable and easy to understand.
With 8 tools, the server is well-scoped for Lambda performance analysis, covering key areas like monitoring, cost, optimization, and specific metrics. Each tool serves a clear purpose without being overwhelming or insufficient.
The tool set covers core aspects of Lambda performance analysis, including listing functions, analyzing metrics, cost, optimization, and cold starts. A minor gap is the lack of tools for configuration updates or direct action implementation, but agents can work around this by using recommendations from existing tools.
Maintenance
Related MCP Connectors
Watches reliability, change safety, security and cloud cost across your code and clouds.
Real-time infrastructure monitoring with metrics, logs, alerts, and ML-based anomaly detection.
Track errors, manage performance alerts, and configure dashboards and monitors
Gain visibility into the performance, availability, and health of your apps and infrastructure.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides a comprehensive suite of 76 tools for AWS cloud resource optimization, cost management, and infrastructure monitoring. It enables users to identify unused resources, analyze cost trends, right-size capacity, and maintain security compliance through natural language.76MIT
- AlicenseAqualityCmaintenanceEnables analyzing AWS cloud costs through natural language queries, providing cost summaries, anomaly detection, idle resource identification, rightsizing recommendations, and tagging compliance via Claude.10MIT
- AlicenseAqualityDmaintenanceEnables analyzing AWS cloud costs from billing data, identifying waste, and providing mergeable fixes, with findings reconciled to actual invoices and priced at your negotiated rates.612 PyPIMIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to diagnose and analyze AWS serverless infrastructure through Model Context Protocol, providing access to CloudWatch logs, Lambda functions, DynamoDB tables, IAM policies, and Bedrock-powered incident root-cause analysis.-