LocalStack MCP Server
Introduction
Section titled “Introduction”The LocalStack MCP Server is a Model Context Protocol (MCP) server that connects MCP-compatible clients to your LocalStack environment. It enables AI agents to manage the full local cloud development lifecycle: starting containers, deploying infrastructure, analyzing logs, injecting chaos faults, managing state snapshots, and running AWS CLI commands, all through natural language prompts.
Prerequisites
Section titled “Prerequisites”Before configuring the MCP server, ensure the following are installed and available on your system PATH:
- Node.js (v22.x or later) to run
npx. - Docker to manage the LocalStack container.
- A LocalStack Auth Token configured as
LOCALSTACK_AUTH_TOKEN. All MCP server tools require a valid Auth Token. lstkand the AWS CLI v2 (2.37.7 or later) if you plan to use the AWS CLI tool or deploy CloudFormation stacks. (optional)lstkplus the Terraform, AWS CDK (2.177.0 or later), or AWS SAM (1.95.0 or later) CLI if you plan to deploy Terraform, CDK, or SAM projects. (optional)- Snowflake CLI (
snow) if you plan to use the Snowflake client tool. (optional)
Installation
Section titled “Installation”The LocalStack MCP Server is published on npm as @localstack/localstack-mcp-server.
The recommended approach is to let your MCP client run the server via npx, which downloads and caches the package automatically.
The quickest way to get started with the MCP server is to use the interactive setup wizard:
npx -y @localstack/localstack-mcp-server initThe wizard detects your installed clients, asks how you want to run the server, and writes the configuration for you. You need a valid Auth Token to configure the server.
For manual setup of the MCP server, choose your MCP client below for setup instructions.
Click the button below to install the LocalStack MCP Server in Cursor automatically:
After installing, open ~/.cursor/mcp.json and add the env block with your Auth Token:
{ "mcpServers": { "localstack-mcp-server": { "command": "npx", "args": ["-y", "@localstack/localstack-mcp-server"], "env": { "LOCALSTACK_AUTH_TOKEN": "<YOUR_TOKEN>" } } }}Restart Cursor after saving. The server appears in Cursor Settings > MCP once detected.
Add the following to your VS Code user settings JSON (settings.json) or workspace .vscode/mcp.json:
{ "mcp": { "servers": { "localstack-mcp-server": { "command": "npx", "args": ["-y", "@localstack/localstack-mcp-server"], "env": { "LOCALSTACK_AUTH_TOKEN": "<YOUR_TOKEN>" } } } }}You can also run the command MCP: Add Server from the Command Palette and paste the server command. MCP support requires the GitHub Copilot Chat extension.
Run the following command in your terminal:
claude mcp add localstack-mcp-server \ -e LOCALSTACK_AUTH_TOKEN=<YOUR_TOKEN> \ -- npx -y @localstack/localstack-mcp-serverClaude Code stores this in its project-level configuration and starts the server automatically when you open a conversation.
Add the following to your OpenCode configuration file (opencode.json):
{ "mcpServers": { "localstack-mcp-server": { "command": "npx", "args": ["-y", "@localstack/localstack-mcp-server"], "env": { "LOCALSTACK_AUTH_TOKEN": "<YOUR_TOKEN>" } } }}Add the following to your Amazon Q MCP configuration at ~/.aws/amazonq/mcp.json:
{ "mcpServers": { "localstack-mcp-server": { "command": "npx", "args": ["-y", "@localstack/localstack-mcp-server"], "env": { "LOCALSTACK_AUTH_TOKEN": "<YOUR_TOKEN>" } } }}For any MCP-compatible client, configure a stdio server with:
- Command:
npx - Arguments:
["-y", "@localstack/localstack-mcp-server"] - Environment:
LOCALSTACK_AUTH_TOKENset to your token
If your client uses a JSON configuration file, the entry follows this format:
{ "mcpServers": { "localstack-mcp-server": { "command": "npx", "args": ["-y", "@localstack/localstack-mcp-server"], "env": { "LOCALSTACK_AUTH_TOKEN": "<YOUR_TOKEN>" } } }}Refer to your client’s documentation for the exact location of its MCP configuration file.
Connecting to a custom LocalStack endpoint
Section titled “Connecting to a custom LocalStack endpoint”By default the MCP server connects to http://localhost:4566.
If your LocalStack instance runs on a different host or port, set the following environment variables in the env block:
| Variable | Default | Description |
|---|---|---|
LOCALSTACK_HOSTNAME |
localhost |
Hostname of the LocalStack instance |
LOCALSTACK_PORT |
4566 |
Port of the LocalStack instance |
You can also pass any LocalStack configuration variable through the env block.
These are forwarded to the container when the localstack-management tool starts it.
{ "mcpServers": { "localstack-mcp-server": { "command": "npx", "args": ["-y", "@localstack/localstack-mcp-server"], "env": { "LOCALSTACK_AUTH_TOKEN": "<YOUR_TOKEN>", "LOCALSTACK_HOSTNAME": "my-host", "LOCALSTACK_PORT": "4566" } } }}The MCP server exposes the following tools that your AI agent can call. Each tool runs pre-flight checks (verifying the CLI is available, the container is running, and the Auth Token is present) and returns structured responses.
localstack-management
Section titled “localstack-management”Manage the LocalStack runtime lifecycle for both LocalStack for AWS and LocalStack for Snowflake.
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
start | stop | restart | status |
Yes | The operation to perform |
service |
aws | snowflake |
No | The stack to manage (default: aws) |
envVars |
Record<string, string> |
No | Extra environment variables passed on start |
Example prompts:
- “Start my LocalStack container.”
- “What’s the current status of LocalStack?”
- “Start LocalStack for Snowflake.”
localstack-deployer
Section titled “localstack-deployer”Deploy or destroy infrastructure on LocalStack using CDK, Terraform, SAM, or CloudFormation.
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
deploy | destroy | create-stack | delete-stack |
Yes | The deployment operation |
projectType |
cdk | terraform | sam | auto |
No | Framework to use (default: auto, detected from project files) |
directory |
string |
Yes (for deploy/destroy) |
Path to the project directory |
variables |
Record<string, string> |
No | Variables passed as Terraform -var flags, CDK --context values, or SAM --parameter-overrides |
stackName |
string |
Yes (for create-stack/delete-stack) |
CloudFormation/SAM stack name |
templatePath |
string |
No | Path to a CloudFormation/SAM template |
s3Bucket |
string |
No | S3 bucket for SAM deployments (if omitted, SAM uses --resolve-s3) |
resolveS3 |
boolean |
No | For SAM deployments, whether to use --resolve-s3 when no s3Bucket is provided |
saveParams |
boolean |
No | For SAM deployments, whether to persist resolved parameters to samconfig.toml |
Example prompts:
- “Deploy my CDK project in the
infra/directory on LocalStack.” - “Destroy the Terraform deployment in
./terraform.” - “Deploy my SAM application in
./sam-app.” - “Create a CloudFormation stack named
my-stackfromtemplate.yaml.”
localstack-logs-analysis
Section titled “localstack-logs-analysis”Analyze LocalStack logs to find errors, summarize API activity, or inspect raw output.
| Parameter | Type | Required | Description |
|---|---|---|---|
analysisType |
summary | errors | requests | logs |
No | Type of analysis (default: summary) |
lines |
number |
No | Number of log lines to fetch (default: 2000) |
service |
string |
No | Filter by AWS service name |
operation |
string |
No | Filter by API operation (used with service in requests mode) |
filter |
string |
No | Keyword filter (used with logs mode only) |
Example prompts:
- “Analyze LocalStack logs for any errors.”
- “Show me the S3 API requests from the last 500 log lines.”
- “Get the raw LocalStack logs filtered by ‘lambda’.”
localstack-iam-policy-analyzer
Section titled “localstack-iam-policy-analyzer”Configure IAM enforcement and generate IAM policies from access denials in the logs.
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
set-mode | analyze-policies | get-status |
Yes | The operation to perform |
mode |
ENFORCED | SOFT_MODE | DISABLED |
Yes (for set-mode) |
IAM enforcement level |
Example prompts:
- “Enable IAM enforcement in soft mode on LocalStack.”
- “Analyze the logs for IAM policy violations and generate the required policies.”
- “What’s the current IAM enforcement status?”
localstack-chaos-injector
Section titled “localstack-chaos-injector”Inject faults and network latency into LocalStack services to test application resilience.
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
inject-faults | add-fault-rule | remove-fault-rule | get-faults | clear-all-faults | inject-latency | get-latency | clear-latency |
Yes | The chaos operation |
rules |
Array<FaultRule> |
Yes (for inject-faults, add-fault-rule, remove-fault-rule) |
Fault rules to inject/modify |
latency_ms |
number |
Yes (for inject-latency) |
Latency in milliseconds to add to all requests |
Each fault rule can include:
| Field | Type | Description |
|---|---|---|
service |
string |
Target AWS service (e.g., s3, lambda) |
region |
string |
Target region (e.g., us-east-1) |
operation |
string |
Target API operation (e.g., PutObject) |
probability |
number (0-1) |
Probability of the fault triggering |
error |
{ statusCode?: number, code?: string } |
Error response to return |
Example prompts:
- “Inject a 500 error for all Lambda Invoke calls in us-east-1 with 100% probability.”
- “Add 2000ms of network latency to all LocalStack requests.”
- “Clear all chaos faults.”
localstack-cloud-pods
Section titled “localstack-cloud-pods”Save, load, and manage LocalStack state snapshots using Cloud Pods.
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
save | load | delete | reset |
Yes | The state management operation |
pod_name |
string |
Yes (for save/load/delete) |
Name of the Cloud Pod (alphanumeric, dots, hyphens, underscores; max 128 characters) |
Example prompts:
- “Save the current LocalStack state as a Cloud Pod named
my-app-state.” - “Load the Cloud Pod
my-app-state.” - “Reset the LocalStack state completely.”
localstack-app-inspector
Section titled “localstack-app-inspector”Query and manage App Inspector traces, spans, and events to understand AWS service-to-service flows in your application. It is also the tool for IAM: why a request was denied, which policies decided it, LocalStack’s suggested fix, the least-privilege policies derived from a run, and the IAM enforcement mode.
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
get-status | set-status | list-traces | get-trace | delete-traces | list-spans | get-span | delete-spans | list-events | get-event | list-iam-events, or one of the IAM actions |
Yes | The App Inspector operation |
status |
enabled | disabled |
Yes (for set-status) |
Turn App Inspector on or off at runtime |
trace_id |
string |
Yes (for get-trace and span/event actions) |
Trace ID. Use * with list-spans, list-events, or list-iam-events to query across all traces |
span_id |
string |
Yes (for get-span and event actions) |
Span ID. Use * with list-events or list-iam-events to query across all spans |
event_id |
string |
Yes (for get-event and get-iam-policy) |
Event ID. For the IAM actions, see IAM actions |
trace_ids |
string[] |
No | Traces to delete with delete-traces (omit to delete all) |
span_ids |
string[] |
No | Spans to delete with delete-spans (omit to delete all in the trace scope) |
limit |
number |
No | Maximum number of results (1-1000) |
pagination_token |
string |
No | Cursor from a previous response |
List actions also accept these filters: service_name, region, account_id, operation_name, resource_name, arn, parent_span_id, status_code, start_time_unix_nano, end_time_unix_nano, version, event_name, and event_type (e.g., iam.policy_evaluation).
A typical debugging flow is: get-status, set-status to enabled if needed, run your workload, list-traces, list-spans for a trace, then list-events for a span.
Disabling App Inspector and enabling it again deletes what it recorded, unless persistence is on.
IAM actions
Section titled “IAM actions”The IAM actions show what LocalStack recorded and computed: why a request was denied, LocalStack’s suggested fix, the least-privilege policies derived from a run, and the IAM mode. Each IAM action takes only the parameters listed for it, not the filters above.
| Action | Parameters | Returns |
|---|---|---|
list-iam-denials |
limit, and pagination_token or newer_than (not both) |
Denied requests, newest first (20 per page by default, at most 100): event ID, time, operation, denied action, resource, principal, whether the denial was enforced, and the outcome of LocalStack’s suggested fix. The header shows the IAM mode (with IAM enforcement in your license). When there are denials, the footer gives a newer_than value |
explain-iam |
event_id or span_id (one required), detail (summary by default, or full), and with span_id: limit, pagination_token |
For an event (or every IAM evaluation of a span, 10 by default, at most 50): the policies that decided the request, then LocalStack’s suggested fix with its outcome, policy changes, near misses, and hints |
get-iam-policy |
event_id and policy_key (both required) |
The current full document of a policy named in an event, by its key (e.g., p2) as explain-iam names it. explain-iam points to it when the event stored the policy truncated. The document may have changed since the request: compare its hash with the one in the event (shown by explain-iam with detail set to full) |
get-auto-derived-iam-policies |
arn |
Without arn, the ARNs of the identities and resources that have a least-privilege policy derived from the requests since they were last cleared. With arn set to one of them, that policy |
clear-auto-derived-iam-policies |
None | Clears the auto-derived policies of every principal in this LocalStack instance. This can’t be undone |
get-iam-mode / set-iam-mode |
mode (required for set-iam-mode) |
The IAM enforcement mode. set-iam-mode reports the previous mode and how to restore it |
explain-iam names the matched statements of the deciding policies by their position, and shows the suggested policy changes as full statements.
With detail set to full, it also returns the event payload as LocalStack sent it, which contains the policy statements.
The IAM enforcement mode is one of:
ENFORCED: denied requests fail, as on AWS.SOFT_MODE: denied requests are allowed and logged.ENGINE_ONLY: requests are evaluated but neither rejected nor logged. App Inspector still records denials.DISABLED: nothing is evaluated or recorded.
App Inspector records denials in every mode except DISABLED.
When you enable App Inspector, LocalStack switches DISABLED to ENGINE_ONLY, so you don’t need ENFORCED to see denials.
Lowering the mode doesn’t fix a policy.
To find out why a request was denied and check the fix:
- Run your workload with App Inspector enabled (
get-status, andset-statustoenabledif needed). - Run
list-iam-denials, thenexplain-iamwith theevent_idof a row. Ifexplain-iamnames a truncated policy, fetch it withget-iam-policy. - Fix the policies in your infrastructure code, redeploy, and run the workload again.
- Run
list-iam-denialswith thenewer_thanvalue from the footer of step 2, to see only the denials recorded since then. If step 2 found no denials, any denial listed now is new.
Because LocalStack evaluates every policy itself, explain-iam also shows a policy in another account that denied the request, such as a KMS key policy, an S3 bucket policy, or an EventBridge event bus policy.
Your agent usually can’t read such a policy with its own credentials.
To derive least-privilege policies for a workload, run clear-auto-derived-iam-policies, run the workload, then get-auto-derived-iam-policies to list the ARNs, and again with arn for the policy of an identity or resource.
list-iam-denials shows the IAM mode in its header if your license includes IAM enforcement.
When it finds nothing, it says whether your license hides IAM details or whether App Inspector recorded no requests at all.
By default, App Inspector doesn’t record requests to STS, IAM, and CloudWatch Logs, nor sqs:GetQueueUrl, sqs:GetQueueAttributes, and cloudwatch:PutMetricData.
Their denials, such as a role’s trust policy denying sts:AssumeRole, never appear.
Requests that LocalStack failed to evaluate are allowed, and the header counts them as evaluation errors, not denials.
For the raw data behind explain-iam, use get-event: it returns the IAM evaluation as LocalStack recorded it.
list-iam-events lists a span’s IAM events with their IDs, which get-event takes along with trace_id and span_id.
The evaluation is a JSON-encoded string in the event’s attributes.payload field, with these main fields:
is_allowedandenforcement: the decision, and what LocalStack did with it when it evaluated the request (allow,deny,allow_with_warningfor a denial that wasn’t enforced, ornot_checked).explicit_allows,explicit_denies, andimplicit_denies: one entry per action and resource.caused_bynames the policies that decided it, by their key inpolicies, with the positions of the matched statements for explicit decisions. On a denial,allowed_bynames policies that allow the action but don’t decide it.policies: the policies the event names, keyed byp1,p2, and so on. A truncated policy hasstatementsandstatement_countinstead ofdocument; fetch the full document (its current version) withget-iam-policy.suggestion: LocalStack’s suggested fix, with itsversion, itsoutcome, the policy changes inentries, the statements that almost allowed the request innear_misses, andhintsfor what the suggested changes can’t fix. Each hint has acauseand anorigin:aws(AWS doesn’t allow the change either),localstack(a LocalStack gap), oruser(you can fix it another way).
Review suggested statements before you apply them, to make sure they follow the principle of least privilege.
Example prompts:
- “Enable App Inspector, invoke my
order-processorLambda, and show me the resulting trace.” - “List the traces that involve SQS.”
- “My Lambda calls fail with AccessDenied. Find out which policy denies them and fix the project’s IAM policies.”
- “Generate a least-privilege policy for what this workload actually does.”
- “Delete all App Inspector traces.”
localstack-aws-client
Section titled “localstack-aws-client”Run AWS CLI commands against LocalStack with the official AWS CLI v2 through lstk aws, which sets the endpoint, credentials, and region.
| Parameter | Type | Required | Description |
|---|---|---|---|
command |
string |
Yes | The AWS CLI command to run (without the lstk or aws prefix) |
Example prompts:
- “List all S3 buckets in LocalStack.”
- “Describe my Lambda functions.”
- “Query the DynamoDB table
usersfor all items.”
The tool sanitizes input to prevent shell injection (pipes, redirects, and command chaining are blocked).
Every request stays on LocalStack: the CLI runs without your ~/.aws configuration and credentials, behind a local proxy that refuses other hosts.
Local files that a command reads or writes (for example with s3 cp, file://, or --body) must be inside the directory set by the MCP server’s LOCALSTACK_AWS_WORKDIR variable (see Configuration reference).
If a command fails due to a service not being emulated, the tool returns a link to the relevant service coverage documentation.
localstack-extensions
Section titled “localstack-extensions”Install, uninstall, list, and discover LocalStack Extensions from the marketplace.
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
list | install | uninstall | available |
Yes | The extensions operation |
name |
string |
Yes (for install/uninstall) |
Extension package name (e.g., localstack-extension-typedb) |
source |
string |
No | Git URL to install from (alternative to name) |
Example prompts:
- “List my installed LocalStack extensions.”
- “Browse the available extensions in the marketplace.”
- “Install the
localstack-extension-typedbextension.” - “Uninstall the
localstack-extension-stripeextension.”
localstack-ephemeral-instances
Section titled “localstack-ephemeral-instances”Manage cloud-hosted Ephemeral Instances for remote LocalStack testing workflows.
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
create | list | logs | delete |
Yes | The ephemeral instance operation |
name |
string |
Yes (for create/logs/delete) |
Instance name |
lifetime |
number |
No | Lifetime in minutes for the instance (only for create) |
extension |
string |
No | Extension package to preload on the instance (only for create) |
cloudPod |
string |
No | Cloud Pod name to initialize state from (only for create) |
envVars |
Record<string, string> |
No | Extra environment variables for the instance (only for create) |
Example prompts:
- “Create an ephemeral LocalStack instance named
test-envwith a 60-minute lifetime.” - “List all my ephemeral instances.”
- “Get the logs from the
test-envephemeral instance.” - “Delete the ephemeral instance named
test-env.”
localstack-docs
Section titled “localstack-docs”Search the LocalStack documentation to find guides, API references, and configuration details.
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string |
Yes | The search query |
limit |
number |
No | Maximum number of results to return (default: 5, max: 10) |
Example prompts:
- “Search the LocalStack docs for how to configure S3.”
- “Find the LocalStack documentation on Cloud Pods.”
localstack-snowflake-client
Section titled “localstack-snowflake-client”Execute SQL queries and commands against LocalStack for Snowflake using the Snowflake CLI (snow).
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
execute | check-connection |
Yes | The operation to perform |
query |
string |
Yes (for execute, if file_path not provided) |
SQL query to execute |
file_path |
string |
Yes (for execute, if query not provided) |
Absolute path to a .sql file to execute |
database |
string |
No | Snowflake database context |
schema |
string |
No | Snowflake schema context |
warehouse |
string |
No | Snowflake warehouse to use |
role |
string |
No | Snowflake role to use |
Example prompts:
- “Check the connection to LocalStack for Snowflake.”
- “Run
SELECT * FROM my_tableon LocalStack for Snowflake.” - “Execute the SQL file at
/path/to/setup.sqlon Snowflake.”
Quickstart
Section titled “Quickstart”Once your MCP client is configured, verify the setup by opening a conversation with your AI agent.
1. Start LocalStack
“Start my LocalStack container.”
The agent uses the localstack-management tool to start the container and confirms the status.
2. Deploy infrastructure
“Deploy my CDK project in the
./my-appdirectory.”
The agent detects the framework, runs lstk cdk bootstrap and lstk cdk deploy, and returns the stack outputs.
3. Verify resources
“List the Lambda functions and DynamoDB tables that were created.”
The agent runs AWS CLI commands through lstk aws and returns the results.
4. Analyze logs
“Check the LocalStack logs for any errors.”
The agent fetches recent logs and highlights any errors or warnings.
5. Save state
“Save a Cloud Pod named
my-checkpoint.”
The agent persists the current LocalStack state so you can restore it later.
Configuration reference
Section titled “Configuration reference”The following environment variables can be set in the env block of your MCP configuration:
| Variable | Default | Description |
|---|---|---|
LOCALSTACK_AUTH_TOKEN (required) |
None | Your LocalStack Auth Token. Required for all MCP server tools. |
LOCALSTACK_HOSTNAME |
localhost |
Hostname of the LocalStack instance |
LOCALSTACK_PORT |
4566 |
Port of the LocalStack instance |
MAIN_CONTAINER_NAME |
localstack-main |
Name of the LocalStack Docker container |
MCP_ANALYTICS_DISABLED |
0 |
Set to 1 to disable MCP analytics |
LOCALSTACK_AWS_WORKDIR |
The server’s working directory | The directory the localstack-aws-client tool runs the AWS CLI in. Local files a command reads or writes must be inside it. When the server runs in / or your home directory, only relative paths work, in a private temporary directory |
APP_INSPECTOR |
0 |
Set to 1 to enable App Inspector by default across restarts. The localstack-app-inspector tool can also toggle it at runtime with set-status |
Any LocalStack configuration variable can also be passed through the env block.
These are forwarded to the container when the localstack-management tool starts it.
For example, to enable debug logging and persistence:
{ "mcpServers": { "localstack-mcp-server": { "command": "npx", "args": ["-y", "@localstack/localstack-mcp-server"], "env": { "LOCALSTACK_AUTH_TOKEN": "<YOUR_TOKEN>", "DEBUG": "1", "PERSISTENCE": "1" } } }}Troubleshooting
Section titled “Troubleshooting”LocalStack container fails to start
Section titled “LocalStack container fails to start”Symptoms: The localstack-management tool reports a timeout after 120 seconds.
Solutions:
- Ensure Docker is running on your machine.
- Verify the LocalStack CLI is installed and on your
PATHby runninglocalstack --version. - Check Docker resource limits. LocalStack needs at least 2 GB of memory.
- If you are using a custom
LOCALSTACK_HOSTNAME, ensure the host is reachable.
MCP server not detected by the client
Section titled “MCP server not detected by the client”Symptoms: The server does not appear in your client’s MCP server list.
Solutions:
- Verify Node.js (v22+) is installed by running
node --version. - Run
npx -y @localstack/localstack-mcp-servermanually in a terminal to check for errors. - Ensure the JSON in your MCP configuration file is valid (no trailing commas, correct key names).
- Restart your MCP client after saving configuration changes.
Tools return “Auth Token Required”
Section titled “Tools return “Auth Token Required””Symptoms: Any tool call fails with an “Auth Token Required” error.
Solutions:
- Confirm your
LOCALSTACK_AUTH_TOKENis set in theenvblock of your MCP configuration. - Verify the token is valid by running
localstack auth show-token. - Ensure there are no extra spaces or quotes around the token value in your configuration file.