Skip to main content
Glama
severity1

terraform-cloud-mcp

get_plan_json_output

Retrieve the JSON execution plan from Terraform Cloud to view machine-readable resource changes and planned actions for infrastructure management.

Instructions

Retrieve the JSON execution plan.

Gets the JSON representation of a plan's execution details, providing a machine-readable format of the planned resource changes.

API endpoint: GET /plans/{plan_id}/json-output

Args: plan_id: The ID of the plan to retrieve JSON output for (format: "plan-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
plan_idYes

Implementation Reference

  • The handler function that executes the tool logic: validates the plan_id using PlanJsonOutputRequest model and fetches the JSON plan output from the Terraform Cloud API endpoint /plans/{plan_id}/json-output.
    @handle_api_errors
    async def get_plan_json_output(plan_id: str) -> APIResponse:
        """Retrieve the JSON execution plan.
    
        Gets the JSON representation of a plan's execution details, providing a
        machine-readable format of the planned resource changes.
    
        API endpoint: GET /plans/{plan_id}/json-output
    
        Args:
            plan_id: The ID of the plan to retrieve JSON output for (format: "plan-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 = PlanJsonOutputRequest(plan_id=plan_id)
    
        # Make API request
        return await api_request(f"plans/{params.plan_id}/json-output")
  • Pydantic-based input schema model (PlanJsonOutputRequest) for validating the plan_id parameter with regex pattern matching Terraform Cloud plan ID format.
    class PlanJsonOutputRequest(APIRequest):
        """Request model for retrieving a plan's JSON output.
    
        Used to validate the plan ID parameter for JSON output API requests.
    
        Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/plans#retrieve-the-json-execution-plan
    
        See:
            docs/models/plan.md for reference
        """
    
        plan_id: str = Field(
            ...,
            # No alias needed as field name matches API parameter
            description="The ID of the plan to retrieve JSON output for",
            pattern=r"^plan-[a-zA-Z0-9]{16}$",  # Standard plan ID pattern
        )
  • Tool registration in the MCP server using FastMCP's mcp.tool() decorator, binding the handler function.
    mcp.tool()(plans.get_plan_json_output)
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: it's a retrieval operation (implied read-only), specifies the API endpoint and HTTP method (GET), mentions automatic redirect following, and outlines the return content (JSON with resource changes, metadata, actions). This covers most behavioral aspects, though it lacks details on error handling or rate limits.

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 a clear purpose statement, followed by detailed sections (Args, Returns, See) that add value without redundancy. Each sentence earns its place by providing essential information like API endpoint, parameter details, and return format, with no wasted text.

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 largely complete: it covers purpose, usage, parameter semantics, and behavioral traits. However, it lacks explicit mention of prerequisites (e.g., authentication) or error cases, and the absence of an output schema means the return structure is only vaguely described as 'complete JSON formatted plan'.

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 input schema has 0% description coverage, but the description compensates well by explaining the single parameter 'plan_id' in the Args section, including its purpose and format ('plan-xxxxxxxx'). This adds meaningful semantics beyond the bare schema, though it could benefit from more context on where to obtain the plan_id or validation rules.

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 the JSON execution plan') and resource ('plan's execution details'), distinguishing it from siblings like get_plan_details or get_plan_logs by focusing on the JSON representation of planned resource changes. It explicitly mentions the machine-readable format and planned actions, making the purpose distinct and well-defined.

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 provides clear context for usage by specifying that it retrieves JSON output for a plan's execution details, implying it should be used when machine-readable plan data is needed. However, it does not explicitly state when not to use it or name alternatives (e.g., get_plan_details for non-JSON format), leaving some guidance gaps compared to explicit sibling differentiation.

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