get_run_plan_json_output
Retrieve the JSON execution plan for a Terraform run, providing a detailed, machine-readable format of planned resource changes and actions. Use the run ID to access the plan via API.
Instructions
Retrieve the JSON execution plan from a run.
Gets the JSON representation of a run's current plan execution details, providing a machine-readable format of the planned resource changes.
API endpoint: GET /runs/{run_id}/plan/json-output
Args: run_id: The ID of the run to retrieve plan JSON output for (format: "run-xxxxxxxx")
Returns: The complete JSON formatted plan with resource changes, metadata, and planned actions. The redirect is automatically followed.
See: docs/tools/plan.md for reference documentation
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| run_id | Yes |
Implementation Reference
- terraform_cloud_mcp/tools/plans.py:70-93 (handler)The main handler function that executes the tool: validates the run_id input and calls the Terraform Cloud API to retrieve the JSON plan output from the specified run.@handle_api_errors async def get_run_plan_json_output(run_id: str) -> APIResponse: """Retrieve the JSON execution plan from a run. Gets the JSON representation of a run's current plan execution details, providing a machine-readable format of the planned resource changes. API endpoint: GET /runs/{run_id}/plan/json-output Args: run_id: The ID of the run to retrieve plan JSON output for (format: "run-xxxxxxxx") Returns: The complete JSON formatted plan with resource changes, metadata, and planned actions. The redirect is automatically followed. See: docs/tools/plan.md for reference documentation """ # Validate parameters params = RunPlanJsonOutputRequest(run_id=run_id) # Make API request return await api_request(f"runs/{params.run_id}/plan/json-output")
- Pydantic input schema model used for validating the run_id parameter with regex pattern matching standard Terraform Cloud run ID format.class RunPlanJsonOutputRequest(APIRequest): """Request model for retrieving a run's plan JSON output. Used to validate the run ID parameter for JSON output API requests. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/plans#retrieve-the-json-execution-plan-from-a-run See: docs/models/plan.md for reference """ run_id: str = Field( ..., # No alias needed as field name matches API parameter description="The ID of the run to retrieve plan JSON output for", pattern=r"^run-[a-zA-Z0-9]{16}$", # Standard run ID pattern )
- terraform_cloud_mcp/server.py:85-85 (registration)Registers the get_run_plan_json_output function as an MCP tool using the FastMCP mcp.tool() decorator.mcp.tool()(plans.get_run_plan_json_output)