by mikegc-aws
Creates a simple MCP tool server with "streaming" HTTP.
# Add to your Claude Code skills
git clone https://github.com/mikegc-aws/Lambda-MCP-Server⚠️ 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.
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:
<p align="center"> <a href="https://youtu.be/Ejua5LQTqek"> <img src="thumb.png" alt="MCP - Can Lambda do it? - Streamable HTTP Model Context Protocol" width="600" /><br> </a> </p>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)
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
counter = mcp_serv...