> This page is for Agent Handler.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.merge.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.merge.dev/_mcp/server.

# Spacelift

> **Ready to connect**
>
> No custom OAuth app setup required. Sign in or provide your credentials to connect.

**Authentication:** API key. Enter your Spacelift account host, API key ID, and secret. Create a Secret API key under **Organization settings > API keys**. Give it Read access for read-only tools or Write or Admin access for changes. Use the full account host for US accounts, such as `acme.app.us.spacelift.io`. See [Spacelift API authentication](https://docs.spacelift.io/integrations/api).

## Sample use cases

* Find stacks and inspect their runs, logs, and planned changes
* Manage contexts, policies, spaces, and stack dependencies
* Trigger runs and review infrastructure changes

## Available tools

#### add_dependency_reference

Pass an upstream stack output to the downstream stack as a variable on a dependency.

#### attach_context

Attach a context to a stack or module with a priority.

#### attach_policy

Attach a policy to a stack or module (LOGIN and ACCESS policies cannot be attached).

#### cancel_run

Cancel a run that has not started yet (QUEUED/READY/PENDING).

#### confirm_run

Confirm an UNCONFIRMED tracked run so it applies its plan.

#### create_blueprint

Create a blueprint (DRAFT, or PUBLISHED with a template).

#### create_context

Create a context. Call search_spaces first for a space ID; add variables with set_context_config and attach it with attach_context.

#### create_drift_detection

Turn on drift detection for a stack on a cron schedule.

#### create_module

Create a module tracking a repository branch.

#### create_module_version

Publish a new module version from a commit (default: tracked branch head) with an explicit semantic version or an automatic patch bump.

#### create_policy

Create a Rego policy of a given type. Destructive: an 'autoattach:' label attaches it to matching stacks at once, where TRIGGER/APPROVAL policies can start or approve runs.

#### create_run_comment

Post a comment on a run. Use list_stack_runs or search_runs to find run IDs.

#### create_scheduled_delete

Schedule deletion of a stack (cron or one-off Unix time).

#### create_scheduled_run

Schedule tracked runs on a stack by cron expression or a one-off Unix time (exactly one), with optional env vars.

#### create_scheduled_task

Schedule a command (task) on a stack by cron expression or a one-off Unix time (exactly one).

#### create_space

Create a space under a parent space. Call search_spaces first for the parent ID. Returns the new space ID.

#### create_stack

Create a stack tracking a repository branch.

#### create_stack_dependency

Make stack_id depend on depends_on_stack_id.

#### create_stack_from_blueprint

Create stack(s) from a PUBLISHED blueprint with template input values.

#### create_task

Create a task: run a one-off shell command (e.g. 'tofu state list') in a stack's workspace.

#### create_webhook

Create a named webhook that posts Spacelift events to an HTTPS endpoint, optionally signed with a secret (never echoed back).

#### cycle_worker_pool

Cycle a worker pool: tell every worker to finish its current run and restart (e.g. after rotating config).

#### delete_blueprint

Delete a blueprint. Stacks already created from it are kept. Use search_blueprints to find IDs.

#### delete_context

Delete a context. Fails while it is attached to stacks unless `force=true`, which detaches it everywhere first.

#### delete_context_config

Delete an environment variable or mounted file from a context. Use get_context to list config element IDs.

#### delete_dependency_reference

Remove an output-to-input reference from a dependency.

#### delete_drift_detection

Turn off drift detection for a stack. Inverse of create_drift_detection. Use search_stacks to find stack IDs.

#### delete_module

Permanently delete a module and its versions. Fails if deletion protection is on. Use search_modules to find module IDs.

#### delete_module_version

Delete a module version that no stack uses (yank_module_version hides a used one instead).

#### delete_policy

Delete a policy. Fails while it is attached to stacks unless `force=true`, which detaches it everywhere first.

#### delete_scheduled_delete

Cancel a scheduled stack deletion. Inverse of create_scheduled_delete. Use list_scheduled_deletes to find IDs.

#### delete_scheduled_run

Delete a scheduled run. Inverse of create_scheduled_run. Use list_scheduled_runs to find schedule IDs.

#### delete_scheduled_task

Delete a scheduled task. Inverse of create_scheduled_task. Use list_scheduled_tasks to find schedule IDs.

#### delete_space

Delete an empty space. Fails while it still has child spaces, stacks, contexts, policies, modules or worker pools.

#### delete_stack

Permanently delete a stack. DANGER: `destroy_resources=true` first destroys every cloud resource it manages.

#### delete_stack_config

Delete an environment variable or mounted file from a stack. Use list_stack_config to list config element IDs.

#### delete_stack_dependency

Remove a stack dependency and its references.

#### delete_webhook

Delete a named webhook. Inverse of create_webhook. Use search_webhooks to find IDs.

#### delete_worker_pool

Delete a worker pool. Fails while stacks or modules still use it. Use search_worker_pools to find IDs.

#### detach_context

Detach a context from a stack by attachment ID.

#### detach_policy

Detach a policy from a stack by attachment ID.

#### disable_module

Disable a module so no new versions can be created. Inverse of enable_module. Use search_modules to find module IDs.

#### disable_stack

Disable a stack so no runs can be created on it. Inverse of enable_stack. Use search_stacks to find stack IDs.

#### discard_run

Discard an UNCONFIRMED tracked run so its plan is never applied.

#### enable_module

Enable a disabled module so new versions can be created.

#### enable_stack

Enable a disabled stack so it can create runs again. Inverse of disable_stack. Use search_stacks to find stack IDs.

#### get_api_key

Get one API key's details and space access rules (the secret is never returned). Use list_api_keys to find IDs.

#### get_blueprint

Get one blueprint with its YAML template and the inputs it asks for. Use search_blueprints to find blueprint IDs.

#### get_context

Get one context with its config elements (secret values and file mount contents are null) and the stacks it is attached to, including attachment IDs for detach_context.

#### get_current_user

Get the identity this API key authenticates as (ID, name, admin flag, teams, token expiry).

#### get_module

Get one module with its source string and current and latest versions. Use search_modules to find module IDs.

#### get_module_version

Get one module version with its state, yank status, consumers count and commit.

#### get_policy

Get one policy with its Rego body and the stacks it is attached to (with attachment IDs for detach_policy).

#### get_policy_sample

Get a sampled policy evaluation: the input document, policy body, results and outcome.

#### get_role

Get one RBAC role with the actions it grants and its binding count. Use list_roles to find role IDs.

#### get_run

Get one run (tracked, proposed or task) by ID with its state history, which lists the states that have logs for get_run_logs.

#### get_run_changes

List a run's planned or applied resource changes (address, change type, result), filtered by phase and change type, capped at max_resources.

#### get_run_logs

Read a run's logs (ANSI-sanitized). With state null, returns every state that has logs; output is capped at max_lines.

#### get_space

Get one space with its parent, inheritance and this API key's access level. Use search_spaces to find space IDs.

#### get_stack

Get one stack by ID with its tracked commit, blocking run, attached contexts, policies and cloud integrations (with attachment IDs for detach tools) and drift detection.

#### get_user

Get one user with role, status, groups and space access rules. Use list_users to find user IDs.

#### get_webhook

Get one named webhook (endpoint, enabled, space, labels; the secret is never returned). Use search_webhooks to find IDs.

#### get_worker_pool

Get one worker pool with its workers (IDs, status, drained flag) and queue counts. Use search_worker_pools to find IDs.

#### list_api_keys

List the account's API keys with type, admin flag, space access rules and last use (secrets are never returned).

#### list_branches

List the branches of a repository. Use list_repositories for provider, namespace and repository first; pass a branch to create_stack.

#### list_module_versions

List a module's versions, newest first, filterable by state and text, with cursor pagination.

#### list_opentofu_versions

List OpenTofu versions Spacelift supports. Use for the OPENTOFU vendor version on create_stack/update_stack.

#### list_policy_evaluations

List a policy's recorded evaluations (key, outcome, time), newest first, filterable by outcome, with cursor pagination.

#### list_policy_input_captures

List policy inputs captured in a space for a policy type, newest first (login inputs live under root).

#### list_repositories

List repositories Spacelift can see through a VCS integration, optionally filtered by substring.

#### list_roles

List RBAC roles (built-in and custom) with the actions each grants. Use get_role for one role.

#### list_scheduled_deletes

List a stack's scheduled deletions (when the stack itself will be deleted). Use search_stacks to find stack IDs.

#### list_scheduled_runs

List a stack's scheduled tracked runs (cron or one-off). Use search_stacks to find stack IDs.

#### list_scheduled_tasks

List a stack's scheduled tasks (commands on a cron or one-off schedule). Use search_stacks to find stack IDs.

#### list_stack_config

List a stack's own environment variables and mounted files (not those from attached contexts).

#### list_stack_dependencies

List the stacks a stack depends on, with dependency IDs and their output-to-input references.

#### list_stack_outputs

List a stack's outputs (name, value, sensitive flag).

#### list_stack_proposed_runs

List a stack's proposed (PR / plan-only) runs, newest first, 10 per page (pass page_info.cursor for older ones).

#### list_stack_runs

List a stack's tracked runs, newest first, 10 per page (pass page_info.cursor for older runs).

#### list_stack_tasks

List a stack's tasks (one-off commands from create_task), newest first, 10 per page (pass page_info.cursor for older ones).

#### list_terraform_versions

List Terraform versions Spacelift supports. Use for terraform_version on create_stack/update_stack.

#### list_user_groups

List identity-provider user groups mapped to space access, with members and access rules. Admin only.

#### list_users

List the account's users with role, status, login method and space access rules. Admin only. Use get_user for one user.

#### lock_stack

Lock a stack for exclusive use by this API key, with an optional note.

#### promote_run

Promote a finished proposed run to a tracked run on the same commit.

#### replan_run

Re-plan an UNCONFIRMED run limited to specific resource addresses (targeted replan).

#### retry_run

Retry a FAILED or STOPPED run as a new run on the same commit.

#### review_run

Add an APPROVE or REJECT review to a run (used by approval policies).

#### search_audit_trail

Search the account audit trail, newest first, by action (wildcards), a created_at window (Unix seconds) and free text, with cursor pagination.

#### search_blueprints

Search blueprints (templated stack definitions) by state, labels and free text, with cursor pagination.

#### search_contexts

Search contexts (reusable env vars, files and hooks) by space, labels and free text, with cursor pagination.

#### search_modules

Search modules in the private registry by provider, space, labels, public flag and free text, with cursor pagination.

#### search_policies

Search policies by type, space, labels and free text, with cursor pagination.

#### search_policy_templates

Search the policy template library by type and free text, with cursor pagination.

#### search_resources

Search resources managed by stacks across the account, filtered by stack ID and free text (e.g. a resource type), with cursor pagination.

#### search_runs

Search runs across all stacks, newest first, with filters for state, run type, triggering user and a created_at window (Unix seconds), full-text search, ordering, and cursor or offset paging.

#### search_spaces

Search spaces (the access-control tree holding stacks, contexts and policies) by parent, labels and free text, with cursor pagination.

#### search_stacks

Search stacks with server-side filters (space, labels, repository, branch, project root, state), full-text search and cursor pagination.

#### search_vcs_integrations

Search VCS integrations by provider and free text, with cursor pagination.

#### search_webhooks

Search named webhook integrations by labels and free text, with cursor pagination.

#### search_worker_pools

Search private worker pools by space, labels and free text, with cursor pagination.

#### set_context_config

Add or overwrite an environment variable or mounted file on a context.

#### set_run_priority

Set the queue priority (high, normal, low) of a run that has not finished.

#### set_stack_commit

Set the commit a stack tracks to a specific SHA (the next tracked run uses it).

#### set_stack_config

Add or overwrite an environment variable or mounted file on a stack.

#### set_stack_star

Star (`star=true)` or unstar (`star=false)` a stack. Use search_stacks to find stack IDs.

#### set_worker_drain

Drain (`drain=true)` a worker so it takes no new runs, or undrain it (`drain=false).`

#### simulate_policy

Evaluate a Rego policy body against a JSON input without saving anything, returning the result JSON.

#### stop_run

Stop a run that is in progress (planning, applying, performing).

#### sync_stack_commit

Move a stack's tracked commit to the current head of its tracked branch.

#### trigger_run

Trigger a run on a stack: TRACKED (plan, then apply after confirm_run; applies immediately with autodeploy) or PROPOSED (plan only).

#### unlock_stack

Release a stack lock held by this API key.

#### update_blueprint

Update a blueprint's name, space, state (DRAFT to PUBLISHED only), template, description or labels; unset fields keep their current values.

#### update_context

Update a context's name, description, labels, space or hooks; unset fields keep their current values and config elements are never touched (use set_context_config).

#### update_drift_detection

Change a stack's drift detection schedule or settings; unset fields keep their current values.

#### update_module

Update a module's source, branch, labels, space and settings; unset fields keep their current values.

#### update_policy

Update a policy's name, body, labels, space, description or engine; unset fields keep their current values.

#### update_scheduled_delete

Replace a scheduled stack deletion's timing and resource-destruction flag. Use list_scheduled_deletes to find IDs.

#### update_scheduled_run

Replace a scheduled run's name and timing; env vars and runtime settings are kept unless environment is set.

#### update_scheduled_task

Replace a scheduled task's command and timing. Use list_scheduled_tasks to find schedule IDs.

#### update_space

Update a space's name, description, parent (moves it), inheritance or labels; unset fields keep their current values.

#### update_stack

Update a stack's settings; unset fields keep their current values (the tool reads the stack first because the API replaces the whole input).

#### update_webhook

Update a named webhook's name, endpoint, space, enabled flag, labels, retry or secret; unset fields keep their current values.

#### update_worker_pool

Update a worker pool's name, description, labels, space and limits; unset fields keep their current values.

#### yank_module_version

Yank a module version (mark it bad so consumers stop using it), with a note.