Skip to main content
Glama

cancel_run

Stop an in-progress Terraform Cloud run during planning or applying phases to halt resource consumption or terminate long-running operations.

Instructions

Cancel a run that is currently planning or applying

Gracefully stops an in-progress run during planning or applying phases. Use this when you need to stop a run that's taking too long, consuming too many resources, or needs to be stopped for any reason. The operation attempts to cleanly terminate the run by sending an interrupt signal.

API endpoint: POST /runs/{run_id}/actions/cancel

Args: run_id: The ID of the run to cancel (format: "run-xxxxxxxx") comment: An optional explanation for why the run was canceled

Returns: Run status update with canceled state, timestamp of cancellation, and any provided comment in the response metadata

See: docs/tools/run.md for reference documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
run_idYes
commentNo

Implementation Reference

  • The handler function that implements the cancel_run tool logic by making a POST request to Terraform Cloud's /runs/{run_id}/actions/cancel endpoint with an optional comment payload.
    async def cancel_run(run_id: str, comment: str = "") -> APIResponse: """Cancel a run that is currently planning or applying Gracefully stops an in-progress run during planning or applying phases. Use this when you need to stop a run that's taking too long, consuming too many resources, or needs to be stopped for any reason. The operation attempts to cleanly terminate the run by sending an interrupt signal. API endpoint: POST /runs/{run_id}/actions/cancel Args: run_id: The ID of the run to cancel (format: "run-xxxxxxxx") comment: An optional explanation for why the run was canceled Returns: Run status update with canceled state, timestamp of cancellation, and any provided comment in the response metadata See: docs/tools/run.md for reference documentation """ request = RunActionRequest(run_id=run_id, comment=comment) # Create payload if comment is provided payload = {} if request.comment: payload = {"comment": request.comment} # Make API request return await api_request( f"runs/{run_id}/actions/cancel", method="POST", data=payload )
  • The line where the cancel_run tool is registered with FastMCP using the write_tool_config.
    mcp.tool(**write_tool_config)(runs.cancel_run)
  • Import of the runs module containing the cancel_run function, necessary for registration.
    from terraform_cloud_mcp.tools import runs
  • Configuration used for registering write tools like cancel_run, conditionally enabling based on read-only mode.
    write_tool_config = { "enabled": not read_only_mode, "annotations": {"readOnlyHint": False} }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/severity1/terraform-cloud-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server