list_lambda_functions
Retrieve all AWS Lambda functions in your account with basic performance information. Filter by runtime or include metrics to analyze function performance.
Instructions
List all Lambda functions in the account with basic performance info
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| runtime | No | Filter by runtime (e.g., nodejs18.x, python3.9) | |
| includeMetrics | No | Include basic performance metrics (default: false) |
Implementation Reference
- index.js:380-408 (handler)Main MCP tool handler for 'list_lambda_functions'. Parses input args, calls LambdaAnalyzer.listFunctions helper, and returns formatted markdown response with function list and optional metrics.async listLambdaFunctions(args) { const { runtime, includeMetrics = false } = args; const functions = await this.lambdaAnalyzer.listFunctions(runtime, includeMetrics); return { content: [ { type: 'text', text: `# Lambda Functions\n\n` + `## Summary\n` + `- **Total Functions**: ${functions.length}\n` + `- **Runtimes**: ${[...new Set(functions.map(f => f.runtime))].join(', ')}\n\n` + `## Functions List\n` + `${functions.map(func => `### ${func.name}\n` + `- **Runtime**: ${func.runtime}\n` + `- **Memory**: ${func.memory}MB\n` + `- **Timeout**: ${func.timeout}s\n` + `- **Last Modified**: ${func.lastModified}\n` + `${includeMetrics ? `- **Avg Duration**: ${func.metrics?.avgDuration || 'N/A'}ms\n` + `- **Cold Start Rate**: ${func.metrics?.coldStartRate || 'N/A'}%\n` + `- **Error Rate**: ${func.metrics?.errorRate || 'N/A'}%\n` : ''}\n` ).join('')}` } ] }; }
- index.js:133-145 (schema)Input schema defining parameters for the list_lambda_functions tool: optional runtime filter and includeMetrics flag.inputSchema: { type: 'object', properties: { runtime: { type: 'string', description: 'Filter by runtime (e.g., nodejs18.x, python3.9)' }, includeMetrics: { type: 'boolean', description: 'Include basic performance metrics (default: false)' } } }
- index.js:130-146 (registration)Registration of the list_lambda_functions tool in the ListToolsRequest handler response, providing name, description, and schema.{ name: 'list_lambda_functions', description: 'List all Lambda functions in the account with basic performance info', inputSchema: { type: 'object', properties: { runtime: { type: 'string', description: 'Filter by runtime (e.g., nodejs18.x, python3.9)' }, includeMetrics: { type: 'boolean', description: 'Include basic performance metrics (default: false)' } } } },
- src/lambda-analyzer.js:127-164 (helper)Helper method in LambdaAnalyzer that implements the core logic: lists all Lambda functions via AWS SDK, filters by runtime, enriches with config and optional performance metrics.async listFunctions(runtime, includeMetrics) { const command = new ListFunctionsCommand({}); const response = await this.lambdaClient.send(command); let functions = response.Functions || []; if (runtime) { functions = functions.filter(func => func.Runtime === runtime); } const result = []; for (const func of functions) { const functionInfo = { name: func.FunctionName, runtime: func.Runtime, memory: func.MemorySize, timeout: func.Timeout, lastModified: func.LastModified }; if (includeMetrics) { try { const quickAnalysis = await this.analyzeFunction(func.FunctionName, '24h', false); functionInfo.metrics = { avgDuration: quickAnalysis.avgDuration, coldStartRate: quickAnalysis.coldStartRate, errorRate: quickAnalysis.errorRate }; } catch (error) { functionInfo.metrics = null; } } result.push(functionInfo); } return result; }