Skip to main content
Glama
jghidalgo

Lambda Performance MCP Server

by jghidalgo

compare_lambda_performance

Analyze and compare AWS Lambda function performance metrics including duration, cold starts, errors, invocations, and costs across specified time ranges to identify optimization opportunities.

Instructions

Compare performance metrics between multiple Lambda functions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
functionNamesYesList of Lambda function names to compare
timeRangeNoTime range for comparison (default: 24h)
metricsNoMetrics to compare (default: all)

Implementation Reference

  • The main handler function for the 'compare_lambda_performance' tool. Parses input arguments, delegates comparison logic to LambdaAnalyzer.compareFunctions, formats the results including a markdown table, insights, and recommendations into a text response.
    async compareLambdaPerformance(args) {
      const { functionNames, timeRange = '24h', metrics = ['duration', 'cold-starts', 'errors', 'invocations', 'cost'] } = args;
      
      const comparison = await this.lambdaAnalyzer.compareFunctions(
        functionNames, 
        timeRange, 
        metrics
      );
    
      return {
        content: [
          {
            type: 'text',
            text: `# Lambda Performance Comparison\n\n` +
                  `## Functions Analyzed\n` +
                  `${functionNames.map(name => `- ${name}`).join('\n')}\n\n` +
                  `## Performance Comparison\n` +
                  `${this.formatComparisonTable(comparison)}\n\n` +
                  `## Key Insights\n` +
                  `${comparison.insights.map(insight => `- ${insight}`).join('\n')}\n\n` +
                  `## Recommendations\n` +
                  `${comparison.recommendations.map(rec => `- ${rec}`).join('\n')}`
          }
        ]
      };
    }
  • Input schema definition for the 'compare_lambda_performance' tool, specifying required functionNames array and optional timeRange and metrics parameters.
    {
      name: 'compare_lambda_performance',
      description: 'Compare performance metrics between multiple Lambda functions',
      inputSchema: {
        type: 'object',
        properties: {
          functionNames: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of Lambda function names to compare'
          },
          timeRange: {
            type: 'string',
            enum: ['1h', '6h', '24h', '7d'],
            description: 'Time range for comparison (default: 24h)'
          },
          metrics: {
            type: 'array',
            items: {
              type: 'string',
              enum: ['duration', 'cold-starts', 'errors', 'invocations', 'cost']
            },
            description: 'Metrics to compare (default: all)'
          }
        },
        required: ['functionNames']
      }
    },
  • Core comparison utility that analyzes performance metrics for each specified Lambda function using analyzeFunction, extracts relevant metric values, generates insights and recommendations, and returns structured comparison data used by the tool handler.
    async compareFunctions(functionNames, timeRange, metrics) {
      const comparisons = [];
      
      for (const functionName of functionNames) {
        const analysis = await this.analyzeFunction(functionName, timeRange, false);
        comparisons.push({
          name: functionName,
          values: {
            duration: analysis.avgDuration,
            'cold-starts': analysis.coldStartRate,
            errors: analysis.errorRate,
            invocations: analysis.totalInvocations,
            cost: await this.estimateCost(analysis)
          }
        });
      }
    
      const insights = this.generateComparisonInsights(comparisons);
      const recommendations = this.generateComparisonRecommendations(comparisons);
    
      return {
        functions: comparisons,
        metrics,
        insights,
        recommendations
      };
    }
  • index.js:220-221 (registration)
    Dispatch registration in the CallToolRequest handler switch statement, mapping the tool name to the compareLambdaPerformance handler.
    case 'compare_lambda_performance':
      return await this.compareLambdaPerformance(args);
  • Helper function to format comparison data into a markdown table, used in the tool handler response.
    formatComparisonTable(comparison) {
      const headers = ['Function', ...comparison.metrics];
      const rows = comparison.functions.map(func => [
        func.name,
        ...comparison.metrics.map(metric => func.values[metric])
      ]);
    
      return `| ${headers.join(' | ')} |\n` +
             `| ${headers.map(() => '---').join(' | ')} |\n` +
             rows.map(row => `| ${row.join(' | ')} |`).join('\n');
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'compare performance metrics' implies a read-only operation, it doesn't specify whether this requires specific permissions, what format the comparison results take, whether data is aggregated or real-time, or any rate limits. For a tool with 3 parameters and no annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any unnecessary words. It's appropriately sized and front-loaded with the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 3 parameters with full schema coverage but no annotations and no output schema, the description is minimally adequate. However, for a comparison tool that likely returns complex performance data, the lack of output information and behavioral context leaves significant gaps in understanding how to interpret results.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with all parameters well-documented in the schema itself. The description doesn't add any meaningful parameter semantics beyond what's already in the schema descriptions. This meets the baseline expectation when schema coverage is complete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'compare' and the resource 'performance metrics between multiple Lambda functions', which is specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'analyze_lambda_performance' or 'monitor_real_time_performance', which likely have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling tools related to Lambda performance analysis (analyze_lambda_performance, monitor_real_time_performance, track_cold_starts), there's no indication of what makes this tool distinct or when it's the appropriate choice.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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