force_cancel_run
Forcefully cancel a Terraform Cloud run that is stuck and not responding to normal cancellation, bypassing graceful shutdown to unlock the workspace immediately.
Instructions
Forcefully cancel a run immediately
Immediately terminates a run that hasn't responded to a normal cancel request. Use this as a last resort when a run is stuck and not responding to regular cancellation. This action bypasses the graceful shutdown process and forces the workspace to be unlocked.
API endpoint: POST /runs/{run_id}/actions/force-cancel
Args: run_id: The ID of the run to force cancel (format: "run-xxxxxxxx") comment: An optional explanation for why the run was force canceled
Returns: Run status update confirming forced cancellation with timestamp, user information, and workspace unlock status
See: docs/tools/run.md for reference documentation
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| run_id | Yes | ||
| comment | No |
Implementation Reference
- The main execution handler for the 'force_cancel_run' tool. It creates a RunActionRequest, optionally adds a comment to the payload, and performs a POST request to the Terraform Cloud API endpoint '/runs/{run_id}/actions/force-cancel' to forcefully cancel the specified run.@handle_api_errors async def force_cancel_run(run_id: str, comment: str = "") -> APIResponse: """Forcefully cancel a run immediately Immediately terminates a run that hasn't responded to a normal cancel request. Use this as a last resort when a run is stuck and not responding to regular cancellation. This action bypasses the graceful shutdown process and forces the workspace to be unlocked. API endpoint: POST /runs/{run_id}/actions/force-cancel Args: run_id: The ID of the run to force cancel (format: "run-xxxxxxxx") comment: An optional explanation for why the run was force canceled Returns: Run status update confirming forced cancellation with timestamp, user information, and workspace unlock status 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/force-cancel", method="POST", data=payload )
- terraform_cloud_mcp/server.py:71-71 (registration)The registration of the 'force_cancel_run' tool in the MCP server using FastMCP's mcp.tool decorator with write permissions configuration.mcp.tool(**write_tool_config)(runs.force_cancel_run)