Skip to main content
Glama
severity1

terraform-cloud-mcp

get_run_plan_json_output

Retrieve JSON execution plans from Terraform Cloud runs to analyze planned resource changes in machine-readable format for infrastructure management.

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

TableJSON Schema
NameRequiredDescriptionDefault
run_idYes

Implementation Reference

  • The core handler function for the 'get_run_plan_json_output' tool. It validates the input run_id using a Pydantic model and fetches the JSON plan output via the Terraform Cloud API endpoint /runs/{run_id}/plan/json-output.
    @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 validation model for the tool's run_id parameter, enforcing the standard Terraform Cloud run ID format (run-[a-zA-Z0-9]{16}).
    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
        )
  • Registers the get_run_plan_json_output handler as an MCP tool using FastMCP's mcp.tool() decorator.
    mcp.tool()(plans.get_run_plan_json_output)

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