
mikegc-aws/lambda-mcp-server 是从 https://github.com/mikegc-aws/lambda-mcp-server. 导入的 MCP 服务器候选
概览
mikegc-aws/lambda-mcp-server 是从 https://github.com/mikegc-aws/lambda-mcp-server. 导入的 MCP 服务器候选
概述(AI 翻译)
** ⚠️ 重要:Lambda MCP 服务器模块代码确实被维护,但不在此仓库中。该代码现托管并维护于 awslabs/mcp-lambda-handler。该仓库仍作为使用该模块的示例代码。**
要使用 Lambda MCP 服务器,请直接从 PyPI 安装包:
该服务器需要一个支持可流式HTTP(非SSE)的客户端。目前有一些MCP客户端支持可流式HTTP,包括MCP Inspector。本仓库中还包含一个可流式HTTP客户端,构建了Strands Agents。
该项目展示了一种强大且适合开发者使用AWS Lambda创建无服务器MCP(模型上下文协议)工具的方法。它展示了如何构建一个无状态、无服务器的MCP服务器,使用最少的模板和出色的开发者体验。
the_context()
在the_context的一期节目中,Tiffany Souterre 和 Mike 讨论了 MCP 的可流式 HTTP 以及运行(较早版本的)该项目:
示例
以下是让MCP服务器在AWS Lambda函数中运行的最小代码:
会议状态管理
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Lambda MCP Server Demo (Streamable HTTP)
⚠️ IMPORTANT: The Lambda MCP Server module code IS maintained, just not in this repository. It is now hosted and maintained at awslabs/mcp-lambda-handler. This repository remains as sample code of how to use the module.
To use the Lambda MCP Server, install the package directly from PyPI:
pip install awslabs.mcp_lambda_handler # or, if using uv: uv add awslabs.mcp_lambda_handler
This server requires a client that supports Streamable HTTP (not SSE). There are a few MCP clients that currently support Streamable HTTP including the MCP Inspector. There is also as a Streamable HTTP client included in this repo, built Strands Agents.
This project demonstrates a powerful and developer-friendly way to create serverless MCP (Model Context Protocol) tools using AWS Lambda. It showcases how to build a stateless, serverless MCP server with minimal boilerplate and an excellent developer experience.
the_context()
In an episode of the_context, Tiffany Souterre and Mike discussed streamable HTTP for MCP as well as running (an older version of) this project:
Example
Here is the minimal code to get an MCP server running in an AWS Lambda function:
from awslabs.mcp_lambda_handler import MCPLambdaHandler
mcp_server = MCPLambdaHandler(name="mcp-lambda-server", version="1.0.0")
@mcp_server.tool()
def get_time() -> str:
from datetime import datetime, UTC
return datetime.now(UTC).isoformat()
def lambda_handler(event, context):
return mcp_server.handle_request(event, context)
Session State Management
The Lambda MCP Server includes built-in session state management that persists across tool invocations within the same conversation. This is particularly useful for tools that need to maintain context or share data between calls.
Session data is stored in a DynamoDB table against a sessionId key. This is all managed for you.
Here’s an example of how to use session state:
from lambda_mcp.lambda_mcp import LambdaMCPServer
session_table = os.environ.get('MCP_SESSION_TABLE', 'mcp_sessions')
mcp_server = LambdaMCPServer(name="mcp-lambda-server", version="1.0.0", session_store=session_table)
@mcp_server.tool()
def increment_counter() -> int:
"""Increment a session-based counter."""
# Get the current counter value from session state, default to 0 if not set
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →