get_errored_state
Retrieve failed Terraform state files from Terraform Cloud to recover data after apply errors. Access state information when uploads fail during infrastructure deployment.
Instructions
Retrieve the errored state from a failed apply.
Gets information about a state file that failed to upload during an apply, providing access to the state data for recovery purposes.
API endpoint: GET /applies/{apply_id}/errored-state
Args: apply_id: The ID of the apply with a failed state upload (format: "apply-xxxxxxxx")
Returns: Information about the errored state including access details. The redirect to the state file is automatically followed.
See: docs/tools/apply.md for reference documentation
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apply_id | Yes |
Implementation Reference
- The main handler function that implements the tool logic: retrieves errored state from a failed Terraform Cloud apply by calling the API endpoint /applies/{apply_id}/errored-state, with input validation using ApplyErroredStateRequest model.@handle_api_errors async def get_errored_state(apply_id: str) -> APIResponse: """Retrieve the errored state from a failed apply. Gets information about a state file that failed to upload during an apply, providing access to the state data for recovery purposes. API endpoint: GET /applies/{apply_id}/errored-state Args: apply_id: The ID of the apply with a failed state upload (format: "apply-xxxxxxxx") Returns: Information about the errored state including access details. The redirect to the state file is automatically followed. See: docs/tools/apply.md for reference documentation """ # Validate parameters params = ApplyErroredStateRequest(apply_id=apply_id) # Make API request - redirect handling happens automatically in the API client return await api_request(f"applies/{params.apply_id}/errored-state")
- terraform_cloud_mcp/server.py:90-90 (registration)The tool registration line in the MCP server, applying the mcp.tool() decorator to the imported get_errored_state function from the applies module.mcp.tool()(applies.get_errored_state)