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)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses that the tool retrieves data (implying read-only behavior) and mentions automatic redirect following, which adds useful context. However, it lacks details on authentication needs, rate limits, error handling, or response format beyond 'complete JSON formatted plan', leaving behavioral gaps for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose in the first sentence. Each subsequent sentence adds value: clarifying the output format, noting automatic redirect following, and providing references. There is no wasted text, and the structure with clear sections (Args, Returns, See) enhances readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (single parameter, no output schema, no annotations), the description is fairly complete. It covers purpose, parameter semantics, and return value details, and includes a reference link. However, it lacks explicit error handling or usage boundaries, which could improve completeness for a tool with no structured output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'run_id' is for retrieving plan JSON output, specifies the format ('run-xxxxxxxx'), and clarifies its purpose. With only one parameter, this compensates well for the schema's lack of descriptions, though it could detail parameter constraints more.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Retrieve', 'Gets') and resource ('JSON execution plan from a run', 'JSON representation of a run's current plan execution details'), distinguishing it from siblings like get_plan_details or get_plan_json_output by focusing on the JSON output format for a specific run's plan. It explicitly mentions 'machine-readable format of the planned resource changes' which adds specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying it retrieves JSON output for a run's plan, suggesting it's for accessing structured plan data rather than logs or details. However, it does not explicitly state when to use this tool versus alternatives like get_plan_details or get_plan_json_output, nor does it mention prerequisites or exclusions, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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