Skip to main content
Glama
severity1

terraform-cloud-mcp

apply_run

Execute approved infrastructure changes in Terraform Cloud by confirming and applying a paused run after reviewing the plan output.

Instructions

Apply a run that is paused waiting for confirmation after a plan

Confirms and executes the apply phase for a run that has completed planning and is waiting for approval. Use this when you've reviewed the plan output and want to apply the proposed changes to your infrastructure.

API endpoint: POST /runs/{run_id}/actions/apply

Args: run_id: The ID of the run to apply (format: "run-xxxxxxxx") comment: An optional comment explaining the reason for applying the run

Returns: Run details with updated status information and confirmation of the apply action including timestamp information and any comment provided

See: docs/tools/run.md for reference documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
run_idYes
commentNo

Implementation Reference

  • The handler function that executes the core logic of the 'apply_run' tool: validates inputs using RunActionRequest, constructs payload with optional comment, and performs POST to /runs/{run_id}/actions/apply via api_request.
    @handle_api_errors
    async def apply_run(run_id: str, comment: str = "") -> APIResponse:
        """Apply a run that is paused waiting for confirmation after a plan
    
        Confirms and executes the apply phase for a run that has completed planning and is
        waiting for approval. Use this when you've reviewed the plan output and want to
        apply the proposed changes to your infrastructure.
    
        API endpoint: POST /runs/{run_id}/actions/apply
    
        Args:
            run_id: The ID of the run to apply (format: "run-xxxxxxxx")
            comment: An optional comment explaining the reason for applying the run
    
        Returns:
            Run details with updated status information and confirmation of the apply action
            including timestamp information and any comment provided
    
        See:
            docs/tools/run.md for reference documentation
        """
        request = RunActionRequest(run_id=run_id, comment=comment)
    
        # Create payload if comment is provided
        payload = {}
        if request.comment:
            payload = {"comment": request.comment}
    
        # Make API request
        return await api_request(
            f"runs/{run_id}/actions/apply", method="POST", data=payload
        )
  • Pydantic model RunActionRequest providing input schema validation for apply_run tool parameters: required run_id (run-XXXX) and optional comment.
    class RunActionRequest(APIRequest):
        """Base request model for run actions like apply, discard, cancel, etc.
    
        This model provides common fields used in run action requests such as
        applying, discarding, or canceling runs. It includes the run ID and
        an optional comment field that can be included with the action.
    
        Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/run#apply-a-run
    
        Note:
            This model is used for multiple run action endpoints that share the
            same basic structure but perform different operations on the run.
    
        See:
            docs/models/run.md for reference
        """
    
        run_id: str = Field(
            ...,
            # No alias needed as field name matches API field name
            description="The ID of the run to perform an action on",
            pattern=r"^run-[a-zA-Z0-9]{16}$",
        )
        comment: Optional[str] = Field(
            None,
            # No alias needed as field name matches API field name
            description="An optional comment about the run",
        )
  • FastMCP tool registration for 'apply_run' using write_tool_config to enable the tool with appropriate permissions and annotations.
    mcp.tool(**write_tool_config)(runs.apply_run)
  • Import of the runs module containing the apply_run handler, required for registration.
    from terraform_cloud_mcp.tools import runs
  • Configuration dictionary used in registration to control tool enablement and set readOnlyHint annotation to False for write-enabled tools like apply_run.
    write_tool_config = {
        "enabled": not read_only_mode,
        "annotations": {"readOnlyHint": False}
    }
Behavior4/5

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

Annotations provide readOnlyHint=false, indicating a write operation, which aligns with the description's 'apply' and 'executes' language. The description adds valuable context beyond annotations: it specifies the tool applies to runs in a specific state ('paused waiting for confirmation after a plan'), mentions the API endpoint, and notes it returns updated status information, enhancing behavioral understanding without contradictions.

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 front-loaded with the core purpose, followed by usage guidelines, API details, parameter explanations, return info, and a reference. Each sentence adds value without redundancy, and the structure is logical and efficient for quick understanding.

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 complexity (a write operation with state dependencies), no output schema, and 0% schema description coverage, the description is largely complete. It covers purpose, usage, parameters, returns, and API endpoint. However, it could mention error cases or prerequisites more explicitly, leaving minor gaps.

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?

Schema description coverage is 0%, so the description carries the burden. It adds meaning for both parameters: 'run_id' is explained as 'The ID of the run to apply' with format details, and 'comment' as 'An optional comment explaining the reason for applying the run'. This compensates well for the lack of schema descriptions, though it doesn't detail all possible constraints.

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 ('Apply a run'), the resource ('a run that is paused waiting for confirmation after a plan'), and distinguishes it from siblings like 'cancel_run' or 'force_execute_run' by specifying it's for runs in a paused post-plan state. It uses precise verbs like 'confirms and executes the apply phase'.

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

Usage Guidelines5/5

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

Explicitly states when to use this tool: 'Use this when you've reviewed the plan output and want to apply the proposed changes to your infrastructure.' It also implies when not to use it (e.g., for runs not in a paused post-plan state) and distinguishes from alternatives like 'cancel_run' or 'force_execute_run' by context.

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