Skip to main content
Stateless mode allows FastMCP to operate without maintaining persistent sessions, making it ideal for serverless deployments, load-balanced environments, or when session state isn’t required.

Overview

In stateless mode:
  • No sessions are tracked on the server
  • Each request creates a temporary session that’s discarded after the response
  • Reduced memory usage and better scalability
  • Perfect for serverless deployment environments (AWS Lambda, Cloud Functions, etc.)
Stateless mode is only available with HTTP streaming transport. Features that depend on persistent sessions (like session-specific state) will not be available.

Enabling stateless mode

Enable stateless mode in your server configuration:

Via CLI

You can also enable stateless mode using CLI arguments:

Health checks

The /ready health check endpoint indicates when the server is running in stateless mode:

Use cases

Serverless Functions

AWS Lambda, Google Cloud Functions, Azure Functions

Load Balanced

Multiple server instances behind a load balancer

Auto-scaling

Environments that scale based on traffic

Ephemeral Containers

Docker containers that start and stop frequently

Differences from stateful mode

Example: Serverless deployment

Here’s a complete example for AWS Lambda:

Authentication in stateless mode

Authentication works the same way in stateless mode, but the session is recreated for each request:

Performance considerations

1

Optimize cold starts

Keep your server initialization code lean to minimize cold start time.
2

Use external storage

For data that persists across requests, use external storage (S3, DynamoDB, etc.).
3

Implement caching wisely

Use external caching services (Redis, Memcached) for frequently accessed data.

Environment variables

Common environment variables for stateless deployments:

Monitoring and debugging

Use structured logging for better observability:

Next steps

Serverless Deployment

Learn about deploying to serverless platforms

Transports

Learn about other transport options