DM

danilop/mcp2lambda

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

110 stars 20 forks 质量 81 趋势 8MIT

danilop/mcp2lambda 是从 https://github.com/danilop/mcp2lambda. 导入的 MCP 服务器候选

概览

danilop/mcp2lambda 是从 https://github.com/danilop/mcp2lambda. 导入的 MCP 服务器候选

概述(AI 翻译)

使用Anthropic的模型上下文协议(MCP),将任何AWS Lambda函数作为大型语言模型(LLM)工具运行,无需修改代码。

该MCP服务器作为MCP客户端与AWS Lambda函数之间的桥梁,使生成式AI模型能够访问并运行Lambda函数作为工具。例如,这对于访问私有资源如内部应用和数据库非常有用,而无需提供公共网络访问。这种方法允许模型使用其他AWS服务、私有网络和公共互联网。

从安全的角度来看,这种方法实现了职责分离,允许模型调用Lambda函数,但不能直接访问其他AWS服务。客户端只需AWS凭证即可调用Lambda函数。Lambda函数随后可以与其他AWS服务交互(使用函数角色),并访问公网或私有网络。

MCP 服务器提供两种工具访问:

  1. 第一个工具可以自动发现账户中所有与前缀或允许名称列表匹配的Lambda函数。该工具与模型共享函数名称及其描述。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP2Lambda

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

graph LR
    A[Model]  B[MCP Client]
    B  C["MCP2Lambda(MCP Server)"]
    C  D[Lambda Function]
    D  E[Other AWS Services]
    D  F[Internet]
    D  G[VPC]
    
    style A fill:#f9f,stroke:#333,stroke-width:2px
    style B fill:#bbf,stroke:#333,stroke-width:2px
    style C fill:#bfb,stroke:#333,stroke-width:4px
    style D fill:#fbb,stroke:#333,stroke-width:2px
    style E fill:#fbf,stroke:#333,stroke-width:2px
    style F fill:#dff,stroke:#333,stroke-width:2px
    style G fill:#ffd,stroke:#333,stroke-width:2px

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:

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

# Or using CLI flag to disable pre-discovery
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

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