mcpField
S
Sample Serverless MCP Servers

Sample Serverless MCP Servers

Local
github.com/aws-samplesCloud & Infra245Updated 54w ago

About Sample Serverless MCP Servers

Sample Serverless MCP Servers is a collection of example implementations of AI agents and MCP servers running on AWS serverless compute. It is intended for developers who want reference deployments of remote MCP servers on AWS. The repository also explains trade-offs between stateful and stateless servers under Streamable HTTP.

Key features

  1. 01Stateless remote MCP server samples on AWS Lambda
  2. 02Stateful and stateless samples on Amazon ECS
  3. 03AI agent sample built with Strands Agents SDK
  4. 04Python and Node.js runtime examples
  5. 05Terraform, CDK and SAM deployment options

Use cases

  1. 01Referencing how to deploy a remote MCP server on AWS Lambda
  2. 02Deploying a session-based MCP server on Amazon ECS
  3. 03Comparing stateful and stateless modes for Streamable HTTP

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

Sample Serverless MCP Servers

README image

This repo contains a collection of sample implementations of MCP Servers.

DirectoryRuntimeIaCDescription
strands-agent-on-lambdaPython(Agent)
Node.js(MCP)
Terraform, CDKA 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-pythonPythonSAMA sample implementation of AI Agent using Strands Agents SDK running on AWS Lambda
stateless-mcp-on-lambda-nodejsNode.jsTerraformA sample implementation of a remote stateless MCP Server running natively on AWS Lambda and Amazon API Gateway
stateless-mcp-on-lambda-pythonPythonSAMA sample implementation of a remote stateless MCP Server running natively on AWS Lambda and Amazon API Gateway
stateless-mcp-on-ecs-nodejsNode.jsTerraformA sample implementation of a remote stateless MCP Server running natively on Amazon ECS with Application Load Balancer
stateful-mcp-on-ecs-nodejsNode.jsTerraformA sample implementation of a remote stateful MCP Server running natively on Amazon ECS with Application Load Balancer
stateful-mcp-on-ecs-pythonPythonSAMA sample implementation of a remote stateful MCP Server running natively on Amazon ECS with Application Load Balancer
lambda-ops-mcp-serverNode.jsTerraformA 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.

README image

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.

README image

README image

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.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.