Get the FREE Ultimate OpenClaw Setup Guide →

MCP2Lambda

Run any AWS Lambda function as a Large Language Model (LLM) tool without code changes using Anthropic's Model Context Protocol (MCP).

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio danilop-mcp2lambda python main.py \
  --env PRE_DISCOVERY="true|false (default: true; set to false to disable pre-discovery mode)"

How to use

MCP2Lambda acts as a bridge between MCP clients and AWS Lambda functions. It exposes two tools to the model: a Lambda function autodiscovery tool and an invoke tool. The autodiscovery tool scans your AWS account for Lambda functions whose names match a prefix or are on an allowlist, returning the function names and descriptions so the model can reason about what tools exist. The invoke tool lets the model call a specific Lambda function by name and pass the required parameters, returning the function's output. By default, functions starting with mcp2lambda- are discovered, but you can configure the discovery behavior with PRE_DISCOVERY and related options. The server enables safe, role-based interactions where the model can access Lambda functions and, through them, other AWS services or private resources via the function’s own IAM role and network access.

To use MCP2Lambda effectively, ensure your MCP client is configured to understand the available tools. You can provide descriptions for each discovered Lambda function to help the model select appropriate parameters. You can also reinforce the recommended usage in your system prompt, e.g., "Use the AWS Lambda tools to improve your answers." This helps the model understand that Lambda functions are available as tools and how to pass parameters. The server supports two strategies: pre-discovery mode (each Lambda function becomes its own named tool) and a generic mode (two generic tools: list_lambda_functions and invoke_lambda_function). You can toggle pre-discovery with the PRE_DISCOVERY environment variable or the --no-pre-discovery CLI flag.

Overall, MCP2Lambda enables LLMs to access private or restricted resources through Lambda, enabling real-time data access, computed results, and integration with other AWS services via the function’s execution environment without exposing direct network access to the model itself.

How to install

Prerequisites:

  • Python 3.12 or higher
  • AWS account with configured credentials (AWS CLI configured via aws configure or environment variables)
  • Access to Lambda functions you want to use (prefix mcp2lambda- by default)
  • Optional: Smithery for seamless installation with Claude Desktop or other MCP clients

Installation via Smithery (recommended for Claude Desktop integration):

npx -y @smithery/cli install @danilop/MCP2Lambda --client claude

Manual installation:

  1. Clone the repository:
git clone https://github.com/yourusername/mcp2lambda.git
cd mcp2lambda
  1. Create a Python environment and install dependencies (if a requirements.txt exists, otherwise install needed packages):
python -m venv venv
source venv/bin/activate  # macOS/Linux
# Windows: venv\Scripts\activate
pip install -r requirements.txt  # if provided
  1. Configure AWS credentials (example using AWS CLI):
aws configure
  1. Run the MCP2Lambda server:
python main.py
  1. If you need to customize discovery behavior, set PRE_DISCOVERY and other options as environment variables before starting:
export PRE_DISCOVERY=true
python main.py

Additional notes

Tips and common issues:

  • By default, only Lambda functions with names starting with mcp2lambda- are discoverable. Adjust this behavior by modifying the discovery configuration in your environment or code.
  • If you encounter permission errors, ensure the Lambda function’s execution role has the necessary permissions for the tasks you intend to run and that the MCP server's IAM role can invoke those functions.
  • When using pre-discovery, each Lambda function becomes its own tool with a distinct name. In generic mode, you’ll have two tools: list_lambda_functions and invoke_lambda_function, which may be more scalable for large inventories.
  • Ensure your MCP client (e.g., Claude Desktop or other) is aware of the available tools and their descriptions to maximize effective tool usage.
  • If running in a VPC or private network, Lambda functions can access private resources as long as they have the appropriate VPC and security group configurations. The MCP client does not need direct access to those resources; the Lambda functions handle it.
  • The provided sample functions illustrate common patterns (lookup by email, fetch by ID, and running arbitrary Python code in a sandbox). Replace or augment these with your own Lambda functions as needed.

Related MCP Servers

Sponsor this space

Reach thousands of developers