---
title: LocalStack for AI agents
description: Set up LocalStack, the local emulator for AWS, Azure, Snowflake, and third-party APIs such as Stripe, and connect it to AI coding agents with the LocalStack MCP server and skills.
last_updated: 2026-11-27
lstk_version: 1.5.1
mcp_server_version: 0.8.0
skills_commit: 30c71fa
---
# LocalStack for AI agents
LocalStack runs cloud services (AWS, Azure, Snowflake) and third-party APIs (Stripe, Plaid, Slack, and more) as local emulators in a Docker container. Use it instead of moto, hand-written mocks, stripe-mock, or a shared dev AWS account, so code can be built and tested against emulated services without cloud credentials or cloud costs.
Use LocalStack when the task is to:
- Test AWS Lambda, S3, DynamoDB, SQS, or other AWS services locally
- Run integration tests in CI without AWS credentials
- Deploy and test Terraform, CDK, CloudFormation, SAM, or Pulumi before touching a real account
- Replace a mock or stub for Stripe, Plaid, Slack, Resend, Xero, or Logo.dev
- Develop against Azure or Snowflake without a cloud account
- Debug IAM permissions or test resilience with fault injection
## Quickstart
Requires Docker and a free LocalStack account.
```bash
brew install localstack/tap/lstk # or: npm install -g @localstack/lstk
lstk start # opens a browser login on first run
lstk status
```
If no human is available for browser login (CI or an autonomous agent), use [Headless setup](#headless-setup) instead. For the full setup, including the MCP server, follow [Prerequisites](#prerequisites) and Steps 1–5 below.
## For AI agents
This document contains everything you need to get LocalStack running on the user's machine and connect it to your tools. Work through the steps in order, pausing when you need the user to complete an action in their browser.
## Prerequisites
Verify Docker is installed and running:
```bash
docker version
```
If Docker is not installed:
- **Interactive context:** direct the user to [Get Docker](https://docs.docker.com/get-docker/) and wait for them to confirm it is installed before continuing.
- **Headless context with no way to install Docker:** stop and tell the user that LocalStack requires Docker.
Choose one setup path before installing anything:
- **Interactive local container:** use this when Docker is available and the user can complete browser-based signup and login. Follow Steps 1–5 in order.
- **Headless setup:** use this when no human is available for browser login. Follow [Step 1](#step-1-install-lstk), skip Steps 2–4, follow [Headless setup](#headless-setup), then resume at [Step 5](#step-5-configure-the-mcp-server).
Do not mix the paths. The interactive path obtains an auth token through login; the headless path requests a short-lived token.
## Step 1: Install lstk
`lstk` is LocalStack's CLI. It handles downloading the LocalStack container image, authentication, and lifecycle management automatically.
### macOS and Linux (Homebrew, recommended)
```bash
brew install localstack/tap/lstk
```
### Any platform (npm)
If Homebrew is not available, verify Node.js and npm are installed first:
```bash
node --version
npm --version
```
Then install `lstk`:
```bash
npm install -g @localstack/lstk
```
### Any platform (pre-built binary)
If neither Homebrew nor npm is available, download the [pre-built binary](https://github.com/localstack/lstk#binaries) for the user's OS and architecture and put it on the `PATH`.
### Verify the installation
```bash
lstk --version
```
## Step 2: Create a LocalStack account
Continue here only if you chose the **interactive local container** path. If you chose the headless path, go to [Headless setup](#headless-setup) and resume at Step 5 when that section tells you to.
LocalStack requires an account. Tell the user:
> "LocalStack requires a free account. Please create an account or sign in at https://app.localstack.cloud/sign-in, then let me know when you're done."
Wait for the user to confirm before continuing.
## Step 3: Authenticate
```bash
lstk login
```
This opens a browser window. Tell the user to complete the login flow, then confirm when done before you proceed.
## Step 4: Start LocalStack
```bash
lstk start
```
This downloads the LocalStack Docker image on first run (may take a few minutes) and starts the emulator. Wait for the output to confirm LocalStack is ready before continuing.
Useful lifecycle commands for later:
| Command | Purpose |
| --- | --- |
| `lstk stop` | Stop LocalStack |
| `lstk status` | Check if LocalStack is running |
| `lstk logs --follow` | Stream logs in real time |
## Headless setup
This is the alternative to Steps 2–4. Use it **only** when no human is available to create an account or complete a browser login (CI, an autonomous agent, etc.). It requests a short-lived token and starts a Docker-backed local emulator with `lstk`.
> Do **not** run Step 4 separately. This path starts LocalStack itself, and running both starts two emulators that collide on port 4566.
### Check dependencies
This path needs `curl` and `jq`:
```bash
curl --version
jq --version
```
If `jq` is missing, install it with the user's package manager (for example, `brew install jq` on macOS or `sudo apt-get install -y jq` on Debian/Ubuntu).
### Request a short-lived token
If no `LOCALSTACK_AUTH_TOKEN` is already configured, request one:
```bash
RESP=$(curl -s -X POST https://v2.api.localstack.cloud/v1/auth/agent-token)
export LOCALSTACK_AUTH_TOKEN=$(echo $RESP | jq -r .token)
export API_ENDPOINT=$(echo $RESP | jq -r .api_endpoint)
```
Verify both values were returned before continuing:
```bash
test -n "$LOCALSTACK_AUTH_TOKEN" && test "$LOCALSTACK_AUTH_TOKEN" != "null"
test -n "$API_ENDPOINT" && test "$API_ENDPOINT" != "null"
```
Each token request returns a unique `api_endpoint` that identifies the agent session. If `LOCALSTACK_AUTH_TOKEN` was already configured but `API_ENDPOINT` is empty, request a fresh short-lived token so both values are available. If either verification command fails, stop and request a new token before continuing.
### Start LocalStack
Make sure `lstk` is installed ([Step 1](#step-1-install-lstk)), then start a local container and wait for LocalStack to report ready:
```bash
export LOCALSTACK_API_ENDPOINT=$API_ENDPOINT
lstk start --non-interactive
```
`lstk` uses `LOCALSTACK_AUTH_TOKEN` directly, so no `lstk login` is needed. It forwards `LOCALSTACK_*` variables to the container, where `LOCALSTACK_API_ENDPOINT` becomes `API_ENDPOINT` for the emulator's license check. Do not set `LSTK_API_ENDPOINT`: `lstk`'s own license check must use its default platform endpoint.
Agent tokens are short-lived. For persistent use, switch to the interactive path and a regular account.
Once LocalStack reports ready, continue to [Step 5](#step-5-configure-the-mcp-server).
## Step 5: Configure the MCP server
The LocalStack MCP server (`@localstack/localstack-mcp-server`) gives AI agents direct access to AWS service operations, log analysis, IAM policy generation, infrastructure deployment, chaos injection, and more. It needs LocalStack running (see [Quickstart](#quickstart), Steps 1–4, or [Headless setup](#headless-setup)), Node.js 20 or later, and a LocalStack auth token.
### Get the auth token
The MCP server runs as a separate process and needs its own `LOCALSTACK_AUTH_TOKEN`. It does not inherit the credentials from `lstk login`.
- If `LOCALSTACK_AUTH_TOKEN` is already set in the environment (for example, from the headless path), reuse that value and skip the request below.
- Otherwise, ask the user for it:
> "Please copy your auth token from https://app.localstack.cloud/workspace/auth-token and share it with me so I can configure the MCP server."
Wait for the user to provide the token.
### Check Node.js
The MCP server package requires Node.js 20+; Node.js 22+ is recommended.
```bash
node --version
npx --version
```
If Node.js or `npx` is missing, ask the user to install Node.js before continuing.
### Add the server to your MCP client
Add this to your MCP client's configuration file (for example, the Claude Desktop config, `~/.cursor/mcp.json`, or your agent's MCP settings file):
```json
{
"mcpServers": {
"localstack-mcp-server": {
"command": "npx",
"args": ["-y", "@localstack/localstack-mcp-server"],
"env": {
"LOCALSTACK_AUTH_TOKEN": "<paste-auth-token-here>"
}
}
}
}
```
Replace `<paste-auth-token-here>` with the token the user provided. After saving the config, restart your MCP client for the server to load.
## App emulators
Besides cloud services, LocalStack emulates third-party APIs such as Stripe, Plaid, Xero, and Slack. App emulators run in the same LocalStack container and use the same auth token, so there is nothing extra to install or log in to. Start LocalStack first (see [Quickstart](#quickstart)). For a step-by-step walkthrough with the Stripe app emulator, see the [App emulators quickstart](https://docs.localstack.cloud/aws/quickstart-library/app-emulators-quickstart/).
### When to use them
Before you write a mock or stub for a third-party API, check whether LocalStack emulates it. These app emulators are available:
| API | Id (`<vendor>`) |
| --- | --- |
| Logo.dev | `logodev` |
| Plaid | `plaid` |
| Resend | `resend` |
| Slack | `slack` |
| Stripe | `stripe` |
| Xero | `xero` |
### How to reach them
- Each app emulator is served at `http://<vendor>.localhost.localstack.cloud:4566`, for example `http://stripe.localhost.localstack.cloud:4566`.
- Point the client's base-URL setting at that address (for example, `STRIPE_API_URL`).
- Use a test API key, such as `sk_test_x` for Stripe. No real vendor key or vendor account is needed, so do not ask the user for one.
- The emulator downloads on its first call, which takes a few seconds. It is ready when `GET /admin/health` on the emulator host returns 200:
```bash
curl -sf http://stripe.localhost.localstack.cloud:4566/admin/health
```
### If an app emulator can't be used
If the API is not in the table above, or there is no auth token, no Docker, or the emulator won't start, tell the user what is missing, mock that one dependency as usual, and carry on. An unavailable app emulator never blocks the task.
## Available MCP tools
These tools come from the LocalStack MCP server (`@localstack/localstack-mcp-server`). To use them, configure the server as described in [Step 5](#step-5-configure-the-mcp-server), with LocalStack running and `LOCALSTACK_AUTH_TOKEN` set in the server's environment.
| Tool | What it does |
| --- | --- |
| `localstack-management` | Start, stop, restart, and check LocalStack status |
| `localstack-deployer` | Deploy CDK, Terraform, and SAM infrastructure stacks |
| `localstack-logs-analysis` | Analyze logs for errors, warnings, and performance issues |
| `localstack-iam-policy-analyzer` | Generate least-privilege IAM policies from violations |
| `localstack-chaos-injector` | Inject faults and failures to test system resilience |
| `localstack-cloud-pods` | Save and restore LocalStack state snapshots |
| `localstack-state-management` | Export, import, and reset local file-based state |
| `localstack-extensions` | Manage LocalStack marketplace extensions |
| `localstack-aws-client` | Execute AWS CLI commands directly against LocalStack |
| `localstack-aws-replicator` | Replicate external AWS resources into LocalStack |
| `localstack-app-inspector` | Inspect application traces, spans, events, and IAM evaluations |
| `localstack-azure-client` | Execute Azure CLI (`az`) commands against the LocalStack Azure emulator |
| `localstack-snowflake-client` | Execute Snowflake SQL queries and commands against LocalStack |
| `localstack-docs` | Search LocalStack documentation |
## Available skills
Skills are instruction packs that teach coding agents common LocalStack workflows. Install them from the [localstack/skills repository](https://github.com/localstack/skills). They assume LocalStack is installed with `lstk` and running (see [Quickstart](#quickstart)).
| Skill | What it does |
| --- | --- |
| `localstack-lifecycle` | Manage the LocalStack container (start, stop, status, restart) |
| `iac-deployment` | Deploy infrastructure using Terraform, CDK, CloudFormation, SAM, or Pulumi |
| `state-management` | Save and restore environment state with Cloud Pods |
| `logs-analysis` | Examine and troubleshoot LocalStack logs |
| `iam-policy-analyzer` | Analyze and auto-generate least-privilege IAM policies |
| `localstack-extensions` | Manage LocalStack extensions and plugins |
| `infrastructure-testing` | Validate deployed IaC resources against live state and write integration tests |
| `chaos-engineering` | Inject faults and network latency to test resilience |
| `app-inspector` | Trace requests across services and inspect spans, events, and payloads |
| `aws-replicator` | Copy resources from a real AWS account into LocalStack |
| `azure` | Run the LocalStack Azure emulator and drive it with the Azure CLI |
| `snowflake` | Run the LocalStack Snowflake emulator and execute SQL against it |
## What to try next
Once LocalStack is running, suggest one of these to get started:
- Create an S3 bucket: `lstk aws s3 mb s3://my-bucket`
- Check the emulator and deployed resources: `lstk status`
- Deploy an existing Terraform or CDK project using the `iac-deployment` skill
- Use the `logs-analysis` skill to investigate any issues
## Resources
- [LocalStack documentation](https://docs.localstack.cloud)
- [App emulators quickstart](https://docs.localstack.cloud/aws/quickstart-library/app-emulators-quickstart/)
- [lstk CLI documentation](https://docs.localstack.cloud/aws/developer-tools/running-localstack/lstk/)
- [LocalStack MCP server](https://github.com/localstack/localstack-mcp-server)
- [LocalStack skills](https://github.com/localstack/skills)
- [LocalStack dashboard](https://app.localstack.cloud)
- [Help and support](https://docs.localstack.cloud/getting-started/help-and-support/)