awslabs/run-model-context-protocol-servers-with-aws-lambda
Run existing Model Context Protocol (MCP) stdio-based servers in AWS Lambda functions
What it solves
Most Model Context Protocol (MCP) servers are designed to run locally as child processes communicating via standard input/output (stdio). This project provides a way to wrap these stdio-based servers into AWS Lambda functions, allowing them to be hosted in the cloud and accessed via HTTPS instead of being tied to a single local machine.
How it works
The library manages the lifecycle of the MCP server within a Lambda function. For every invocation, the Lambda function starts the MCP server as a child process, initializes it, forwards the incoming request, returns the response, and then shuts down the process. It supports four connection methods:
- Amazon API Gateway: Uses the MCP Streamable HTTP transport with OAuth authentication.
- Amazon Bedrock AgentCore Gateway: Uses the MCP Streamable HTTP transport with OAuth authentication.
- Lambda Function URLs: Uses a custom Streamable HTTP transport authenticated with AWS IAM (SigV4).
- Lambda Invoke API: Uses a custom transport calling the Lambda API directly via AWS IAM.
Who it’s for
Developers who want to move their MCP servers from local environments to a distributed cloud architecture while maintaining compatibility with MCP clients (like Cursor, Cline, or Claude Desktop).
Highlights
- Multi-language support: Provides implementation examples for both Python and TypeScript.
- Cloud-native hosting: Enables MCP servers to run as serverless functions.
- Flexible authentication: Supports OAuth (via API Gateway/Bedrock) and AWS IAM.
- Detailed configuration: Includes guidance on packaging servers, managing secrets via AWS Secrets Manager, and passing AWS credentials to child processes.
Related
- Project
- Project
- Project
- Project