Логотип MCP2Lambda

MCP2Lambda

Спільнота
danilop

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

Видавецьdanilop
РепозиторійMCP2Lambda
МоваPython
Форки
21
Зірки
109
Доступні інструменти
0
Тип транспортуstdio
Категорії
ЛіцензіяMIT
Посилання
  • Підключайте інструменти до робочих процесів із ШІ

    MCP2Lambda надає можливості MCP, які можуть використовувати сумісні клієнтські ШІ-застосунки та агенти.

  • Доступні інструменти: 0

    Перегляньте нижче дії, які можна викликати, з назвами й описами, якщо сервер їх надає.

  • Готова конфігурація для копіювання

    Скористайтеся прикладами конфігурації, щоб налаштувати цей сервер у вибраному клієнті MCP.

  • Показники інтересу до відкритого коду

    Зірки: 109, форки: 21 — у пов’язаному репозиторії.

MCP2Lambda

smithery badge

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

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.

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.

The MCP server gives access to two tools:

  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.

  2. The second tool allows to invoke those Lambda functions by name passing the required parameters.

No code changes are required. You should change these configurations to improve results:

Strategy Selection

The gateway supports two different strategies for handling Lambda functions:

  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.

  2. Generic Mode: Uses two generic tools (list_lambda_functions and invoke_lambda_function) to interact with Lambda functions.

You can control this behavior through:

  • Environment variable: PRE_DISCOVERY=true|false
  • CLI flag: --no-pre-discovery (disables pre-discovery mode)

Example:

bash
# Disable pre-discovery mode
export PRE_DISCOVERY=false
python main.py

# Or using CLI flag to disable pre-discovery
python main.py --no-pre-discovery
  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.

  2. To help the model use the tools available via AWS Lambda, you can add something like this to your system prompt:

Use the AWS Lambda tools to improve your answers.

Overview

MCP2Lambda enables LLMs to interact with AWS Lambda functions as tools, extending their capabilities beyond text generation. This allows models to:

  • Access real-time and private data, including data sources in your VPCs
  • Execute custom code using a Lambda function as sandbox environment
  • Interact with external services and APIs using Lambda functions internet access (and bandwidth)
  • Perform specialized calculations or data processing

The server uses the MCP protocol, which standardizes the way AI models can access external tools.

By default, only functions whose name starts with mcp2lambda- will be available to the model.

Prerequisites

  • Python 3.12 or higher
  • AWS account with configured credentials
  • AWS Lambda functions (sample functions provided in the repo)
  • An application using Amazon Bedrock with the Converse API
  • An MCP-compatible client like Claude Desktop

Installation

Installing via Smithery

To install MCP2Lambda for Claude Desktop automatically via Smithery:

bash
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:

    aws configure

Sample Lambda Functions

This repository includes three sample Lambda functions that demonstrate different use cases. These functions have basic permissions and can only write to CloudWatch logs.

CustomerIdFromEmail

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.

CustomerInfoFromId

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.

RunPythonCode

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".

Deploying Sample Lambda Functions

The repository includes sample Lambda functions in the sample_functions directory.

  1. Install the AWS SAM CLI: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html

  2. Deploy the sample functions:

    cd sample_functions
    sam build
    sam deploy

The sample functions will be deployed with the prefix mcp2lambda-.

Using with Amazon Bedrock

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.

The mcp_client_bedrock directory contains a client implementation that connects MCP2Lambda to Amazon Bedrock models.

See https://github.com/mikegc-aws/amazon-bedrock-mcp for more information.

Prerequisites

  • Amazon Bedrock access and permissions to use models like Claude, Mistral, Llama, etc.
  • Boto3 configured with appropriate credentials

Installation and Setup

  1. Navigate to the mcp_client_bedrock directory:

    cd mcp_client_bedrock
  2. Install dependencies:

    uv pip install -e .
  3. Run the client:

    python main.py

Configuration

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:

python
# Examples of supported models:
model_id = "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
#model_id = "us.amazon.nova-pro-v1:0"

You can also customize the system prompt in the same file to change how the model behaves.

Usage

  1. Start the MCP2Lambda server in one terminal:

    cd mcp2lambda
    uv run main.py
  2. Run the Bedrock client in another terminal:

    cd mcp_client_bedrock
    python main.py
  3. Interact with the model through the command-line interface. The model will have access to the Lambda functions deployed earlier.

Using with Claude Desktop

Add the following to your Claude Desktop configuration file:

json
{
  "mcpServers": {
    "mcp2lambda": {
      "command": "uv",
      "args": [
        "--directory",
        "<full path to the mcp2lambda directory>",
        "run",
        "main.py"
      ]
    }
  }
}

To help the model use tools via AWS Lambda, in your settings profile, you can add to your personal preferences a sentence like:

Use the AWS Lambda tools to improve your answers.

Starting the MCP Server

Start the MCP server locally:

sh
cd mcp2lambda
uv run main.py

Встановлення

TypingMind
{
  "mcpServers": {
    "mcp2lambda": {
      "command": "npx",
      "args": [
        "@danilop/MCP2Lambda",
        "--client",
        "claude"
      ]
    }
  }
}

Використовуйте MCP MCP2Lambda з різними моделями ШІ

TypingMind підключає інструменти MCP на рівні робочого простору, тож після підключення MCP2Lambda ви можете використовувати їх із різними моделями ШІ в TypingMind, а не налаштовувати окремо для кожної моделі. Ця інтеграція MCP працює локально через конектор MCP TypingMind на вашому пристрої.

Інструкція з налаштування локального конектора

Виберіть цей варіант, якщо серверу MCP потрібен доступ до локальних файлів, програм або приватних ресурсів на вашому комп’ютері.

1

Відкрийте налаштування MCP

У TypingMind перейдіть до розділу «Налаштування», відкрийте «Розширені налаштування», потім «Протокол контексту моделі» й виберіть «Параметри конектора».

  1. Відкрийте TypingMind у браузері.
  2. Натисніть значок налаштувань.
  3. Перейдіть до розділу «Розширені налаштування».
  4. Відкрийте розділ «Протокол контексту моделі».
  5. Натисніть «Параметри конектора» й виберіть «Цей пристрій».
Екран налаштування конектора MCP у TypingMind з вибраним варіантом «Цей пристрій»
2

Виконайте команду конектора

Виберіть «Цей пристрій», скопіюйте команду з TypingMind і виконайте її в терміналі. Не зупиняйте процес, поки користуєтеся MCP.

  1. Скопіюйте команду налаштування, показану в TypingMind.
  2. Відкрийте «Термінал» у macOS або Windows Terminal у Windows.
  3. Вставте й виконайте команду.
  4. Підтвердьте встановлення пакета, якщо термінал запитає дозволу продовжити.
  5. Не закривайте вікно термінала й не зупиняйте процес, поки користуєтеся інструментами MCP.
3

Додайте MCP2Lambda як сервер

Коли статус конектора зміниться на «Готово», натисніть «Змінити сервери» та вставте конфігурацію сервера MCP.

  1. Зачекайте, доки статус конектора зміниться на «Готово».
  2. Натисніть «Змінити сервери».
  3. Вставте конфігурацію сервера MCP MCP2Lambda.
  4. Збережіть список серверів.
  5. Оновіть дані, щоб переконатися, що конектор досі готовий до роботи.
Налаштування MCP у TypingMind з активним сервером і кнопкою «Змінити сервери»
{
  "mcpServers": {
    "mcp2lambda": {
      "command": "npx",
      "args": [
        "-y",
        "@danilop/MCP2Lambda"
      ]
    }
  }
}
4

Використовуйте підключення з різними моделями

Збережіть список серверів, відкрийте «Плагіни», увімкніть інструменти MCP для MCP2Lambda, а потім виберіть будь-яку підтримувану модель ШІ в TypingMind і використовуйте інструменти в чаті або призначте їх агенту ШІ.

  1. Відкрийте сторінку «Плагіни» в TypingMind.
  2. Увімкніть інструменти MCP для MCP2Lambda.
  3. Почніть чат і виберіть модель ШІ, яку хочете використовувати.
  4. Використовуйте інструменти MCP у чаті або призначте їх агенту ШІ.
  5. За потреби перемикайтеся на іншу модель ШІ без повторного підключення MCP.
Чат TypingMind із використанням увімкнених інструментів MCP і вибраної моделі ШІ
Допоможете з цим завданням через MCP2Lambda?
MCP2Lambda
Звісно. Я це прочитав.
Ось що я знайшов за допомогою MCP2Lambda.

Поширені запитання

Для чого використовується сервер MCP MCP2Lambda?

MCP2Lambda — це сервер MCP, який дає змогу сумісним клієнтам ШІ підключатися до зовнішніх інструментів і контексту. У TypingMind ви можете додати цей сервер MCP один раз і зробити його інструменти доступними у своєму робочому просторі ШІ.

Чи можу я використовувати MCP MCP2Lambda з кількома моделями ШІ в TypingMind?

Так. TypingMind підключає інструменти MCP на рівні робочого простору, тому ви можете використовувати MCP2Lambda з різними моделями ШІ, як-от Claude, ChatGPT, Gemini або іншими моделями, які ви налаштували в TypingMind, без окремого налаштування сервера MCP для кожної моделі.

Навіщо використовувати MCP MCP2Lambda із TypingMind?

TypingMind — один із найкращих інтерфейсів для чату з великими мовними моделями, адже він об’єднує різні моделі ШІ, промпти, плагіни, агентів ШІ, ключі API та інструменти MCP в одному робочому просторі. Підключивши MCP2Lambda, ви зможете використовувати його інструменти MCP з вибраними моделями та впорядковано працювати з чатами в TypingMind.

Як підключити MCP MCP2Lambda до TypingMind?

MCP2Lambda працює через локальний конектор MCP TypingMind. Це найкращий варіант, коли серверу MCP потрібен доступ до локальних файлів, настільних застосунків, інструментів командного рядка або приватних ресурсів на вашому комп’ютері.

Які інструменти надає MCP MCP2Lambda у TypingMind?

MCP2Lambda надає можливості MCP, які можна ввімкнути на сторінці «Плагіни» в TypingMind і використовувати в чаті або призначати агентам ШІ.

Чи потрібно передавати свої ключі API в TypingMind, щоб використовувати MCP MCP2Lambda?

Ні. TypingMind орієнтований насамперед на локальну роботу й дає змогу зберігати контроль над постачальниками моделей, ключами API, промптами та конфігурацією MCP. Якщо MCP2Lambda потребує автентифікації, під час створення підключення додайте потрібні заголовки, налаштування OAuth або локальну конфігурацію для цього сервера MCP.

Схожі сервери MCP

Усі

Створіть власний ШІ-простір уже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇