Skip to content
Back to search

MCP2Lambda

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

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/danilop--mcp2lambda/badge.svg)](/listings/danilop--mcp2lambda)

HTML

<a href="/listings/danilop--mcp2lambda"><img src="/api/listings/danilop--mcp2lambda/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Installing via Smithery

To install MCP2Lambda for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@danilop/MCP2Lambda):

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

2. Configure AWS credentials. For example, using the [AWS CLI](https://aws.amazon.com/cli):

   aws configure

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 223 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # MCP2Lambda
  2. <a href="https://glama.ai/mcp/servers/4hokv207sz">
  3. <img width="380" height="200" src="https://glama.ai/mcp/servers/4hokv207sz/badge" alt="MCP2Lambda MCP server" />
  4. </a>
  5. Run any [AWS Lambda](https://aws.amazon.com/lambda/) function as a Large Language Model (LLM) **tool** without code changes using [Anthropic](https://www.anthropic.com)'s [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol).
  6. ```mermaid
  7. graph LR
  8. A[Model] <--> B[MCP Client]
  9. B <--> C["MCP2Lambda<br>(MCP Server)"]
  10. C <--> D[Lambda Function]
  11. D <--> E[Other AWS Services]
  12. D <--> F[Internet]
  13. D <--> G[VPC]
  14. style A fill:#f9f,stroke:#333,stroke-width:2px
  15. style B fill:#bbf,stroke:#333,stroke-width:2px
  16. style C fill:#bfb,stroke:#333,stroke-width:4px
  17. style D fill:#fbb,stroke:#333,stroke-width:2px
  18. style E fill:#fbf,stroke:#333,stroke-width:2px
  19. style F fill:#dff,stroke:#333,stroke-width:2px
  20. style G fill:#ffd,stroke:#333,stroke-width:2px
  21. ```
  22. This MCP server acts as a **bridge** between MCP clients and AWS Lambda functions, allowing generative AI models to access and run Lambda functions as tools. This is useful, for example, to access private resources such as internal applications and databases without the need to provide public network access. This approach allows the model to use other AWS services, private networks, and the public internet.
  23. From a **security** perspective, this approach implements segregation of duties by allowing the model to invoke the Lambda functions but not to access the other AWS services directly. The client only needs AWS credentials to invoke the Lambda functions. The Lambda functions can then interact with other AWS services (using the function role) and access public or private networks.
  24. The MCP server gives access to two tools:
  25. 1. The first tool can **autodiscover** all Lambda functions in your account that match a prefix or an allowed list of names. This tool shares the names of the functions and their descriptions with the model.
  26. 2. The second tool allows to **invoke** those Lambda functions by name passing the required parameters.
  27. No code changes are required. You should change these configurations to improve results:
  28. ## Strategy Selection
  29. The gateway supports two different strategies for handling Lambda functions:
  30. 1. **Pre-Discovery Mode** (default: enabled): Registers each Lambda function as an individual tool at startup. This provides a more intuitive interface where each function appears as its own named tool.
  31. 2. **Generic Mode**: Uses two generic tools (`list_lambda_functions` and `invoke_lambda_function`) to interact with Lambda functions.
  32. You can control this behavior through:
  33. - Environment variable: `PRE_DISCOVERY=true|false`
  34. - CLI flag: `--no-pre-discovery` (disables pre-discovery mode)
  35. Example:
  36. ```bash
  37. # Disable pre-discovery mode
  38. export PRE_DISCOVERY=false
  39. python main.py
  40. # Or using CLI flag to disable pre-discovery
  41. python main.py --no-pre-discovery
  42. ```
  43. 1. To provide the MCP client with the knowledge to use a Lambda function, the **description of the Lambda function** should indicate what the function does and which parameters it uses. See the sample functions for a quick demo and more details.
  44. 2. To help the model use the tools available via AWS Lambda, you can add something like this to your **system prompt**:
  45. ```
  46. Use the AWS Lambda tools to improve your answers.
  47. ```
  48. ## Overview
  49. MCP2Lambda enables LLMs to interact with AWS Lambda functions as tools, extending their capabilities beyond text generation. This allows models to:
  50. - Access real-time and private data, including data sources in your VPCs
  51. - Execute custom code using a Lambda function as sandbox environment
  52. - Interact with external services and APIs using Lambda functions internet access (and bandwidth)
  53. - Perform specialized calculations or data processing
  54. The server uses the MCP protocol, which standardizes the way AI models can access external tools.
  55. By default, only functions whose name starts with `mcp2lambda-` will be available to the model.
  56. ## Prerequisites
  57. - Python 3.12 or higher
  58. - AWS account with configured credentials
  59. - AWS Lambda functions (sample functions provided in the repo)
  60. - An application using [Amazon Bedrock](https://aws.amazon.com/bedrock/) with the [Converse API](https://docs.aws.amazon.com/bedrock/latest/userguide/converse.html)
  61. - An MCP-compatible client like [Claude Desktop](https://docs.anthropic.com/en/docs/claude-desktop)
  62. ## Installation
  63. 1. Clone the repository:
  64. ```
  65. git clone https://github.com/danilop/MCP2Lambda.git
  66. cd MCP2Lambda
  67. ```
  68. 2. Configure AWS credentials. For example, using the [AWS CLI](https://aws.amazon.com/cli):
  69. ```
  70. aws configure
  71. ```
  72. ## Sample Lambda Functions
  73. This repository includes three *sample* Lambda functions that demonstrate different use cases. These functions have basic permissions and can only write to CloudWatch logs.
  74. ### CustomerIdFromEmail
  75. Retrieves a customer ID based on an email address. This function takes an email parameter and returns the associated customer ID, demonstrating how to build simple lookup tools. The function is hard coded to reply to the `user@example.com` email address. For example, you can ask the model to get the customer ID for the email `user@example.com`.
  76. ### CustomerInfoFromId
  77. Retrieves detailed customer information based on a customer ID. This function returns customer details like name, email, and status, showing how Lambda can provide context-specific data. The function is hard coded to reply to the customer ID returned by the previous function. For example, you can ask the model to "Get the customer status for email `user@example.com`". This will use both functions to get to the result.
  78. ### RunPythonCode
  79. Executes arbitrary Python code within a Lambda sandbox environment. This powerful function allows Claude to write and run Python code to perform calculations, data processing, or other operations not built into the model. For example, you can ask the model to "Calculate the number of prime numbers between 1 and 10, 1 and 100, and so on up to 1M".
  80. ## Deploying Sample Lambda Functions
  81. The repository includes sample Lambda functions in the `sample_functions` directory.
  82. 1. Install the AWS SAM CLI: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html
  83. 2. Deploy the sample functions:
  84. ```
  85. cd sample_functions
  86. sam build
  87. sam deploy
  88. ```
  89. The sample functions will be deployed with the prefix `mcp2lambda-`.
  90. ## Using with Amazon Bedrock
  91. MCP2Lambda can also be used with Amazon Bedrock's Converse API, allowing you to use the MCP protocol with any of the models supported by Bedrock.
  92. The `mcp_client_bedrock` directory contains a client implementation that connects MCP2Lambda to Amazon Bedrock models.
  93. See https://github.com/mikegc-aws/amazon-bedrock-mcp for more information.
  94. ### Prerequisites
  95. - Amazon Bedrock access and permissions to use models like Claude, Mistral, Llama, etc.
  96. - Boto3 configured with appropriate credentials
  97. ### Installation and Setup
  98. 1. Navigate to the mcp_client_bedrock directory:
  99. ```
  100. cd mcp_client_bedrock
  101. ```
  102. 2. Install dependencies:
  103. ```
  104. uv pip install -e .
  105. ```
  106. 3. Run the client:
  107. ```
  108. python main.py
  109. ```
  110. ### Configuration
  111. The client is configured to use Anthropic's Claude 3.7 Sonnet by default, but you can modify the `model_id` in `main.py` to use other Bedrock models:
  112. ```python
  113. # Examples of supported models:
  114. model_id = "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
  115. #model_id = "us.amazon.nova-pro-v1:0"
  116. ```
  117. You can also customize the system prompt in the same file to change how the model behaves.
  118. ### Usage
  119. 1. Start the MCP2Lambda server in one terminal:
  120. ```
  121. cd MCP2Lambda
  122. uv run main.py
  123. ```
  124. 2. Run the Bedrock client in another terminal:
  125. ```
  126. cd mcp_client_bedrock
  127. python main.py
  128. ```
  129. 3. Interact with the model through the command-line interface. The model will have access to the Lambda functions deployed earlier.
  130. ## Using with Claude Desktop
  131. Add the following to your Claude Desktop configuration file:
  132. ```json
  133. {
  134. "mcpServers": {
  135. "mcp2lambda": {
  136. "command": "uv",
  137. "args": [
  138. "--directory",
  139. "<full path to the mcp2lambda directory>",
  140. "run",
  141. "main.py"
  142. ]
  143. }
  144. }
  145. }
  146. ```
  147. To help the model use tools via AWS Lambda, in your settings profile, you can add to your personal preferences a sentence like:
  148. ```
  149. Use the AWS Lambda tools to improve your answers.
  150. ```
  151. ## Starting the MCP Server
  152. Start the MCP server locally:
  153. ```sh
  154. cd MCP2Lambda
  155. uv run main.py
  156. ```

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.