Provides sample implementations of AI agents and MCP servers running on AWS Lambda and Amazon ECS using Python and Node.js.
Also known as aws-samples/sample-serverless-mcp-servers
- Stars
- 245
- Tools
- —
- Downloads, 30 days
- —
- Latest version
- —
- Last commit
- Nov 13, 2026
- License
- MIT-0
What is Sample Serverless MCP Servers MCP?
Sample Serverless MCP Servers provides sample implementations of AI agents and MCP servers running on AWS Lambda and Amazon ECS using Python and Node.js.
Summary generated from the project's README
About Sample Serverless MCP Servers MCP server
Developers looking to deploy Model Context Protocol implementations on cloud infrastructure can use these sample implementations to understand various deployment patterns. The repository provides code for both local and remote servers using Python and Node.js runtimes. It covers a range of architectures including stateless servers running on AWS Lambda with Amazon API Gateway and stateful servers hosted on Amazon ECS using an Application Load Balancer.
These samples demonstrate how to handle different session requirements, such as using sticky sessions for stateful ECS deployments or utilizing the Strands Agents SDK for AI agent implementations. You can find specific examples for managing user authentication via Cognito or performing local operations like discovering and upgrading functions on deprecated runtimes through the lambda-ops-mcp-server. The projects use Infrastructure as Code tools like Terraform, AWS CDK, and SAM to manage the underlying AWS resources.
What you can do with it
- 1Deploy stateless remote serversSet up a remote MCP server that scales horizontally using AWS Lambda and API Gateway.
- 2Implement stateful ECS serversBuild a stateful MCP server on Amazon ECS that uses an Application Load Balancer and manual cookie handling for session affinity.
- 3Create authenticated AI agentsDevelop an AI agent using the Strands Agents SDK that integrates with Cognito for user authentication.
- 4Manage deprecated Lambda runtimesUse a local MCP server to find and upgrade functions that are running on outdated runtimes.
Written from the project's README. Every use case is checked against a quote from it.
Automated checks
Ran Nov 14, 2026Full report →Not verified yet. A server needs a score of 80, no serious finding, and enough data for us to check. How checks work · What to fix for more points
- Source repository linked and reachableaws-samples/sample-serverless-mcp-servers is public and reachablegithub.com/aws-samples/sample-serverless-mcp-servers ↗Pass
- Package names this repository as its sourceNot checked
- Build provenance (Sigstore attestation)Not checked
- Open source license (OSI)MIT-0spdx.org/licenses/MIT-0.html ↗Pass
- Commit or release in the last yearLast commit or release 2026-11-06github.com/aws-samples/sample-serverless-mcp-servers ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNot checked
- No critical advisory in the package or its dependenciesNot checked
- No hidden instructions to the model0 tool descriptions and the README read; no override phrases, credential paths or hidden charactersPass
- Destructive tools are labelledNot checked
- Remote endpoint answers the MCP handshakeNot checked
README
View on GitHubSample Serverless MCP Servers

This repo contains a collection of sample implementations of MCP Servers.
| Directory | Runtime | IaC | Description |
|---|---|---|---|
| strands-agent-on-lambda | Python(Agent) Node.js(MCP) | Terraform, CDK | A sample implementation of AI Agent using Strands Agents SDK and connected MCP Server running on AWS Lambda, includes integration with Cognito for user authentication |
| strands-agent-on-lambda-python | Python | SAM | A sample implementation of AI Agent using Strands Agents SDK running on AWS Lambda |
| stateless-mcp-on-lambda-nodejs | Node.js | Terraform | A sample implementation of a remote stateless MCP Server running natively on AWS Lambda and Amazon API Gateway |
| stateless-mcp-on-lambda-python | Python | SAM | A sample implementation of a remote stateless MCP Server running natively on AWS Lambda and Amazon API Gateway |
| stateless-mcp-on-ecs-nodejs | Node.js | Terraform | A sample implementation of a remote stateless MCP Server running natively on Amazon ECS with Application Load Balancer |
| stateful-mcp-on-ecs-nodejs | Node.js | Terraform | A sample implementation of a remote stateful MCP Server running natively on Amazon ECS with Application Load Balancer |
| stateful-mcp-on-ecs-python | Python | SAM | A sample implementation of a remote stateful MCP Server running natively on Amazon ECS with Application Load Balancer |
| lambda-ops-mcp-server | Node.js | Terraform | A demo PoC of a local MCP Server that can be used for discovering and upgrading functions on deprecated runtimes |
Stateful VS Stateless MCP Servers
When using Streamable HTTP Transport with MCP Servers/Clients, it’s important to understand the difference and trade-offs between stateful and stateless MCP server implementations. Each model has implications for scalability, connection handling, and session management.
Key Aspects
The Streamable HTTP Transport specification outlines two important capabilities. First, a client may initiate a long-lived HTTP GET request to establish a persistent SSE (Server-Sent Events) connection, allowing the server to push data even when the client hasn’t sent a POST request. Second, if the connection is interrupted, the client should be able to resume communication by reconnecting through another GET request. Both features imply that the server must be able to maintain a persistent session context and support long-lived connections. Read more about Streamable HTTP Transport session management here.
Stateful model challenges
In a stateful MCP server, this means maintaining session state in memory and keeping SSE connections alive over time. However, as of early May 2025, none of the official MCP SDKs support external session persistence (e.g. in Redis or DynamoDB). This limitation makes it difficult to scale stateful servers horizontally. For example, a client might establish a session with one server instance, but if subsequent requests are routed to a different instance, the session context will be lost and the connection will fail.
That said, it is still possible to scale stateful MCP servers if you're willing to configure session affinity, also known as sticky sessions, at the load balancer level. For example, cookie-based sticky sessions can ensure that a client is routed to the same server instance for the duration of a session. However, the TypeScript MCP Client SDK currently relies on the fetch API, which doesn’t natively support cookies. To work around this limitation, you'll need to implement manual cookie handling, as shown in the stateful-mcp-on-ecs example.

Stateless to the rescue
The MCP specification also allows for a stateless server mode. In this mode, the server doesn’t maintain session context between requests, and clients are not expected to resume dropped connections. Stateless mode enables seamless horizontal scaling and works well in environments where elasticity and load distribution are critical. This model is demonstrated in the stateless-mcp-on-lambda, stateless-mcp-on-ecs, and stateless-mcp-on-lambda-python samples included in this repository.


Refer to each folder separately for further instructions and deployment steps.
License
This library is licensed under the MIT-0 License. See the LICENSE file.
Sample Serverless MCP Servers MCP questions
What is the difference between stateful and stateless MCP servers?
Stateful servers maintain session state in memory and require persistent SSE connections, while stateless servers do not maintain session context between requests, allowing for easier horizontal scaling.
How can I scale stateful MCP servers horizontally?
You can scale stateful servers by configuring session affinity, or sticky sessions, at the load balancer level, such as using cookie-based sticky sessions.
Which AWS services are used in these implementations?
The samples utilize AWS Lambda, Amazon ECS, Amazon API Gateway, and Amazon Cognito for user authentication.