npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rri-lambda-analyzer

v1.0.8

Published

A comprehensive toolkit for analyzing AWS Lambda functions - get function details, logs, metrics, and perform security audits

Readme

AWS Lambda Analyzer

A comprehensive TypeScript/JavaScript toolkit for analyzing AWS Lambda functions. Get function details, logs, performance metrics, and perform security audits with ease.

Note: This library also includes an optional MCP (Model Context Protocol) server for integration with Claude and other AI tools.

Features

  • 🔍 Function Analysis: Get detailed function information, code, and configuration
  • 📊 Performance Metrics: Analyze execution time, memory usage, cold starts, and errors
  • 🛡️ Security Auditing: Automated security checks and recommendations
  • 📋 Log Analysis: Retrieve and analyze CloudWatch logs with filtering
  • Function Invocation: Test functions with custom payloads
  • 🏗️ Layer Management: List and analyze Lambda layers
  • 🔧 Batch Operations: Analyze multiple functions simultaneously
  • 📈 Cost Analysis: Calculate approximate Lambda costs
  • Configuration Validation: Validate function configurations

Before Installing, check out MCP Server Integration for one line installation to begin using this MCP from the Claude CLI

Installation

npm install rri-lambda-analyzer

Quick Start

import { LambdaAnalyzer, analyzeLambdaFunction } from 'rri-lambda-analyzer';

// Initialize analyzer (uses AWS credentials from environment)
const analyzer = new LambdaAnalyzer();

// Get basic function information
const functions = await analyzer.listFunctions();
console.log('Functions:', functions);

// Analyze a specific function
const details = await analyzer.getFunctionDetails('my-function');
console.log('Function details:', details);

// Quick analysis with utility function
const analysis = await analyzeLambdaFunction('my-function');
console.log('Complete analysis:', analysis);

Configuration

AWS Credentials

The library uses AWS SDK v3 and supports all standard AWS credential methods:

  • Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)
  • AWS credentials file (~/.aws/credentials)
  • IAM roles (for EC2/Lambda/ECS)
  • AWS SSO

You can also provide credentials explicitly:

import { LambdaAnalyzer } from 'rri-lambda-analyzer';

const analyzer = new LambdaAnalyzer({
  region: 'us-east-1',
  accessKeyId: 'your-access-key',
  secretAccessKey: 'your-secret-key'
});

Required IAM Permissions

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "lambda:ListFunctions",
        "lambda:GetFunction",
        "lambda:InvokeFunction",
        "lambda:ListLayers",
        "logs:DescribeLogGroups",
        "logs:FilterLogEvents"
      ],
      "Resource": "*"
    }
  ]
}

API Reference

LambdaAnalyzer Class

The main class for analyzing Lambda functions.

import { LambdaAnalyzer } from 'rri-lambda-analyzer';

const analyzer = new LambdaAnalyzer(config?: AWSConfig);

Methods

  • listFunctions(options?: ListFunctionsOptions): Promise<FunctionInfo[]> - List all functions
  • getFunctionDetails(name: string, version?: string): Promise<FunctionCodeInfo> - Get function details
  • getFunctionLogs(name: string, options?: LogOptions): Promise<LogEvent[]> - Get function logs
  • invokeFunction(name: string, payload?: any, options?: InvokeOptions): Promise<InvokeFunctionResult> - Invoke function
  • analyzeFunctionPerformance(name: string, timeRange?: TimeRange): Promise<PerformanceMetrics> - Analyze performance
  • auditFunction(name: string): Promise<SecurityAuditResult> - Security audit
  • compareFunctionVersions(name: string, versions: string[]): Promise<ComparisonResult> - Compare versions

Utility Functions

import { 
  analyzeLambdaFunction,
  getLambdaMetrics,
  validateLambdaConfig,
  batchAnalyzeFunctions,
  findFunctionsByRuntime,
  findOversizedFunctions,
  findFunctionsWithErrors
} from 'rri-lambda-analyzer';

Examples

Performance Monitoring

const analyzer = new LambdaAnalyzer();
const performance = await analyzer.analyzeFunctionPerformance('my-function');

console.log(`Invocations: ${performance.invocationCount}`);
console.log(`Errors: ${performance.errorCount}`);
console.log(`Average Duration: ${performance.averageDuration}ms`);
console.log(`Cold Starts: ${performance.coldStarts}`);

Security Audit

const audit = await analyzer.auditFunction('my-function');
console.log(`Risk Score: ${audit.riskScore}/100`);

audit.findings
  .filter(f => f.severity === 'HIGH')
  .forEach(finding => {
    console.log(`- ${finding.title}: ${finding.description}`);
  });

Batch Analysis

import { batchAnalyzeFunctions, findFunctionsByRuntime } from 'rri-lambda-analyzer';

// Analyze multiple functions
const analyses = await batchAnalyzeFunctions(['func1', 'func2', 'func3']);

// Find functions by runtime
const pythonFunctions = await findFunctionsByRuntime('python3.9');

MCP Server Integration

This library also includes an MCP server for Claude integration. There are three ways to use it:

Method 1: Claude CLI Installation (Recommended)

Use the Claude CLI to install and configure the MCP server automatically:

# Install using Claude CLI (requires Claude CLI to be installed)
npm install -g rri-lambda-analyzer && claude mcp add rri-lambda-analyzer rri-lambda-analyzer

This method will:

  • Automatically install the package from npm
  • Add the MCP server configuration to your Claude CLI settings
  • Handle the setup for you without manual configuration

Region Selection: When using the MCP server with Claude CLI, you can dynamically change the AWS region during your session by asking Claude to use the set_region tool:

Use the set_region tool to change the AWS region to us-west-2

The MCP server will switch to the new region and all subsequent Lambda operations will use that region.

All methods will start the MCP server and make all Lambda analysis tools available to Claude as native capabilities.

Method 2: Direct NPM Installation

Install globally and run as a subprocess:

# Install globally
npm install -g rri-lambda-analyzer

# Run as MCP server
rri-lambda-analyzer

Add to Claude Desktop configuration:

{
  "mcpServers": {
    "lambda-analyzer": {
      "command": "rri-lambda-analyzer",
      "env": {
        "AWS_REGION": "us-east-1",
        "AWS_PROFILE": "your-profile"
      }
    }
  }
}

Method 3: Using npx

Run directly with npx without global installation:

# Run as MCP server
npx rri-lambda-analyzer

Add to Claude Desktop configuration:

{
  "mcpServers": {
    "lambda-analyzer": {
      "command": "npx",
      "args": ["rri-lambda-analyzer"],
      "env": {
        "AWS_REGION": "us-east-1",
        "AWS_PROFILE": "your-profile"
      }
    }
  }
}

Available MCP Tools

When using the MCP server, Claude has access to these tools:

  • set_region: Change the AWS region for all Lambda operations
  • list_functions: List AWS Lambda functions in the current region
  • get_function_code: Get function code and configuration details
  • get_function_logs: Retrieve CloudWatch logs for a function
  • invoke_function: Invoke a function with custom payloads
  • list_layers: List available Lambda layers

Installing Claude CLI

To install the Claude Code CLI, you can follow these steps:

  1. Install Node.js and npm. Claude Code requires npm and Node.js version 18 or higher.

  2. Run the following command to install Claude Code globally:

npm install -g @anthropic-ai/claude-code This command installs the Claude Code CLI on your system.

  1. Launch Claude Code by running:

claude

  1. Follow the prompts to generate and use an API key from Anthropic console

These steps will get you started with Claude Code CLI, allowing you to start coding with AI in your terminal.

If you encounter any issues during the installation, you can refer to the official documentation for more detailed instructions

https://docs.anthropic.com/en/docs/claude-code/overview

TypeScript Support

Full TypeScript support with exported types:

import { 
  FunctionInfo, 
  PerformanceMetrics, 
  SecurityAuditResult,
  AWSConfig 
} from 'rri-lambda-analyzer';

Error Handling

All methods include comprehensive error handling:

try {
  const details = await analyzer.getFunctionDetails('my-function');
} catch (error) {
  console.error('Failed to get function details:', error.message);
}

Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.

License

MIT License - see LICENSE file for details.