- Explore MCP Servers
- mcp-streamablehttp-lambda-sample
Mcp Streamablehttp Lambda Sample
What is Mcp Streamablehttp Lambda Sample
mcp-streamablehttp-lambda-sample is a serverless application that implements a Streamable HTTP API using the Model Context Protocol (MCP) on AWS Lambda. It serves as a proof of concept for deploying Lambda functions that support response streaming.
Use cases
Use cases for mcp-streamablehttp-lambda-sample include creating interactive chatbots, real-time calculators, and tools that require immediate feedback from user inputs.
How to use
To use mcp-streamablehttp-lambda-sample, you need to set up your local development environment with AWS CLI, SAM CLI, Node.js 22.x, and Docker. After cloning the repository, you can deploy the Lambda function using AWS SAM and access it via the provided Function URL.
Key features
Key features include tool invocation functionality using MCP, real-time responses through Lambda Response Streaming, and examples of simple echo and calculation tools.
Where to use
mcp-streamablehttp-lambda-sample can be used in fields that require serverless applications, real-time data processing, and applications that benefit from streaming APIs, such as chat applications, live data feeds, and interactive tools.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcp Streamablehttp Lambda Sample
mcp-streamablehttp-lambda-sample is a serverless application that implements a Streamable HTTP API using the Model Context Protocol (MCP) on AWS Lambda. It serves as a proof of concept for deploying Lambda functions that support response streaming.
Use cases
Use cases for mcp-streamablehttp-lambda-sample include creating interactive chatbots, real-time calculators, and tools that require immediate feedback from user inputs.
How to use
To use mcp-streamablehttp-lambda-sample, you need to set up your local development environment with AWS CLI, SAM CLI, Node.js 22.x, and Docker. After cloning the repository, you can deploy the Lambda function using AWS SAM and access it via the provided Function URL.
Key features
Key features include tool invocation functionality using MCP, real-time responses through Lambda Response Streaming, and examples of simple echo and calculation tools.
Where to use
mcp-streamablehttp-lambda-sample can be used in fields that require serverless applications, real-time data processing, and applications that benefit from streaming APIs, such as chat applications, live data feeds, and interactive tools.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Streamable MCP Lambda Function
This project is a serverless application that implements a Streamable HTTP API using the Model Context Protocol (MCP) on AWS Lambda.
Project Overview
This application deploys a Lambda function that supports response streaming using AWS SAM (Serverless Application Model). The main features include:
- Tool invocation functionality using the Model Context Protocol (MCP)
- Real-time responses utilizing Lambda Response Streaming
- Implementation examples of simple greeting tools and notification capabilities
About the Libraries Used
This project uses the Model Context Protocol (MCP) TypeScript library.
- Repository: github.com/anthropics/model-context-protocol
Architecture
This application consists of the following components:
- MCPStreamableFunction: Lambda function using Node.js 22.x runtime
- Lambda Adapter Layer: Layer to support response streaming
- Function URL: Endpoint for direct access to the Lambda function without authentication
Prerequisites
To use this project, you need:
Setup and Deployment
Setting up the Local Development Environment
# Clone the repository
git clone https://github.com/moritalous/mcp-streamablehttp-lambda-sample.git
# Navigate to the project directory
cd mcp-streamablehttp-lambda-sample
# Install dependencies
cd mcp-function
npm install
cd ..
Build and Deploy
# Build the application
sam build
# Deploy the application (interactive for the first time)
sam deploy --guided
During deployment, you will be prompted to enter the following information:
- Stack Name: Name of the CloudFormation stack (e.g., mcp-server-streamable-http)
- AWS Region: Region to deploy to
- Confirm changes before deploy: Whether to confirm changes
- Allow SAM CLI IAM role creation: Whether to allow IAM role creation
- Save arguments to samconfig.toml: Whether to save the configuration
After deployment completes, the Lambda Function URL will be output. You can use this URL to access the API.
Features and Endpoints
This application provides the following endpoints:
- POST /mcp: Initialize and send MCP requests
- GET /mcp: Method not allowed (returns 405)
- DELETE /mcp: Method not allowed (returns 405)
Implemented Tools
This sample application implements the following tools:
-
greet: A simple greeting tool
- Parameter:
name(string)
- Parameter:
-
multi-greet: A tool that sends multiple greetings with notifications
- Parameter:
name(string)
- Parameter:
-
greeting-template: A prompt template for generating greetings
- Parameter:
name(string)
- Parameter:
-
greeting-resource: A resource that provides a default greeting
Client Implementation
A client implementation example is available in mcp-function/src/client.ts. This client provides an interactive command-line interface to:
- Connect to the server
- List available tools, prompts, and resources
- Call tools with arguments
- Get prompts with arguments
- Handle notifications from the server
- Manage session termination and reconnection
Testing Connection from Local to Lambda
cd mcp-function
MCP_SERVER_URL=https://*****.lambda-url.us-east-1.on.aws/mcp npm run dev:client
Resource Cleanup
To remove resources when no longer needed:
sam delete --stack-name <your-stack-name>
Additional Information
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










