Skip to main content
Glama
severity1

terraform-cloud-mcp

cancel_run

Stop an in-progress Terraform Cloud run during planning or applying phases to halt resource consumption or terminate long-running operations.

Instructions

Cancel a run that is currently planning or applying

Gracefully stops an in-progress run during planning or applying phases. Use this when you need to stop a run that's taking too long, consuming too many resources, or needs to be stopped for any reason. The operation attempts to cleanly terminate the run by sending an interrupt signal.

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

Args: run_id: The ID of the run to cancel (format: "run-xxxxxxxx") comment: An optional explanation for why the run was canceled

Returns: Run status update with canceled state, timestamp of cancellation, and any provided comment in the response metadata

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
run_idYes
commentNo

Implementation Reference

  • The handler function that implements the cancel_run tool logic by making a POST request to Terraform Cloud's /runs/{run_id}/actions/cancel endpoint with an optional comment payload.
    async def cancel_run(run_id: str, comment: str = "") -> APIResponse:
        """Cancel a run that is currently planning or applying
    
        Gracefully stops an in-progress run during planning or applying phases. Use this
        when you need to stop a run that's taking too long, consuming too many resources,
        or needs to be stopped for any reason. The operation attempts to cleanly terminate
        the run by sending an interrupt signal.
    
        API endpoint: POST /runs/{run_id}/actions/cancel
    
        Args:
            run_id: The ID of the run to cancel (format: "run-xxxxxxxx")
            comment: An optional explanation for why the run was canceled
    
        Returns:
            Run status update with canceled state, timestamp of cancellation,
            and any provided comment in the response metadata
    
        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/cancel", method="POST", data=payload
        )
  • The line where the cancel_run tool is registered with FastMCP using the write_tool_config.
    mcp.tool(**write_tool_config)(runs.cancel_run)
  • Import of the runs module containing the cancel_run function, necessary for registration.
    from terraform_cloud_mcp.tools import runs
  • Configuration used for registering write tools like cancel_run, conditionally enabling based on read-only mode.
    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 indicate readOnlyHint=false, confirming this is a mutation. The description adds valuable behavioral context beyond annotations: it specifies the tool works during 'planning or applying phases,' attempts 'cleanly terminate the run by sending an interrupt signal,' and mentions the API endpoint. No contradiction with annotations.

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

Conciseness4/5

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

Well-structured with purpose, usage guidelines, behavioral details, parameters, returns, and reference. Most sentences are necessary, though the API endpoint line could be considered extraneous for an AI agent. Slightly verbose but efficiently organized.

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?

No output schema exists, but the description details return values: 'Run status update with canceled state, timestamp of cancellation, and any provided comment.' Given the tool's complexity (mutation with behavioral nuances) and lack of output schema, this provides good completeness, though could mention error cases.

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 full burden. It clearly explains both parameters: 'run_id' as 'The ID of the run to cancel' with format example, and 'comment' as 'optional explanation for why the run was canceled.' This compensates well for the lack of schema descriptions.

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 action ('Cancel a run') and specifies the target state ('currently planning or applying'). It distinguishes from sibling tools like 'force_cancel_run' by emphasizing 'gracefully stops' and 'cleanly terminate,' indicating a non-forced approach.

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: 'when you need to stop a run that's taking too long, consuming too many resources, or needs to be stopped for any reason.' It implicitly distinguishes from 'force_cancel_run' by not mentioning forceful termination, providing clear context for selection.

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