Skip to content
Get Started for Free

LocalStack MCP Server

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.

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.
  • lstk and the AWS CLI v2 (2.37.7 or later) if you plan to use the AWS CLI tool or deploy CloudFormation stacks. (optional)
  • lstk plus 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)

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:

Terminal window
npx -y @localstack/localstack-mcp-server init

The 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:

Install MCP Server

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.

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.

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.”

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-stack from template.yaml.”

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’.”

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?”

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.”

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.”

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.

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:

  1. Run your workload with App Inspector enabled (get-status, and set-status to enabled if needed).
  2. Run list-iam-denials, then explain-iam with the event_id of a row. If explain-iam names a truncated policy, fetch it with get-iam-policy.
  3. Fix the policies in your infrastructure code, redeploy, and run the workload again.
  4. Run list-iam-denials with the newer_than value 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_allowed and enforcement: the decision, and what LocalStack did with it when it evaluated the request (allow, deny, allow_with_warning for a denial that wasn’t enforced, or not_checked).
  • explicit_allows, explicit_denies, and implicit_denies: one entry per action and resource. caused_by names the policies that decided it, by their key in policies, with the positions of the matched statements for explicit decisions. On a denial, allowed_by names policies that allow the action but don’t decide it.
  • policies: the policies the event names, keyed by p1, p2, and so on. A truncated policy has statements and statement_count instead of document; fetch the full document (its current version) with get-iam-policy.
  • suggestion: LocalStack’s suggested fix, with its version, its outcome, the policy changes in entries, the statements that almost allowed the request in near_misses, and hints for what the suggested changes can’t fix. Each hint has a cause and an origin: aws (AWS doesn’t allow the change either), localstack (a LocalStack gap), or user (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-processor Lambda, 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.”

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 users for 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.

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-typedb extension.”
  • “Uninstall the localstack-extension-stripe extension.”

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-env with a 60-minute lifetime.”
  • “List all my ephemeral instances.”
  • “Get the logs from the test-env ephemeral instance.”
  • “Delete the ephemeral instance named test-env.”

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.”

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_table on LocalStack for Snowflake.”
  • “Execute the SQL file at /path/to/setup.sql on Snowflake.”

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-app directory.”

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.

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"
}
}
}
}

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 PATH by running localstack --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.

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-server manually 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.

Symptoms: Any tool call fails with an “Auth Token Required” error.

Solutions:

  • Confirm your LOCALSTACK_AUTH_TOKEN is set in the env block 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.
Was this page helpful?