Skip to main content
Glama
severity1

terraform-cloud-mcp

update_variable_in_variable_set

Modify an existing variable's configuration within a Terraform Cloud variable set. Update attributes like name, value, description, category, HCL status, or sensitivity while keeping unspecified settings unchanged.

Instructions

Update an existing variable in a variable set.

Modifies the configuration of an existing variable within a variable set. Only specified attributes will be updated; unspecified attributes remain unchanged.

API endpoint: PATCH /varsets/{varset_id}/relationships/vars/{var_id}

Args: varset_id: The ID of the variable set (format: "varset-xxxxxxxx") var_id: The ID of the variable (format: "var-xxxxxxxx")

params: Variable parameters to update (optional):
    - key: New variable name/key
    - value: New variable value
    - description: New description of the variable
    - category: New variable category ("terraform" or "env")
    - hcl: Whether the value is HCL code (terraform variables only)
    - sensitive: Whether the variable value is sensitive

Returns: The updated variable with all current settings and configuration

See: docs/tools/variables.md#update-variable-in-variable-set for reference documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
varset_idYes
var_idYes
paramsNo

Implementation Reference

  • The core handler function that executes the tool by sending a PATCH request to the Terraform Cloud API to update the specified variable in the variable set.
    async def update_variable_in_variable_set(
        varset_id: str,
        var_id: str,
        params: Optional[VariableSetVariableParams] = None,
    ) -> APIResponse:
        """Update an existing variable in a variable set.
    
        Modifies the configuration of an existing variable within a variable set. Only
        specified attributes will be updated; unspecified attributes remain unchanged.
    
        API endpoint: PATCH /varsets/{varset_id}/relationships/vars/{var_id}
    
        Args:
            varset_id: The ID of the variable set (format: "varset-xxxxxxxx")
            var_id: The ID of the variable (format: "var-xxxxxxxx")
    
            params: Variable parameters to update (optional):
                - key: New variable name/key
                - value: New variable value
                - description: New description of the variable
                - category: New variable category ("terraform" or "env")
                - hcl: Whether the value is HCL code (terraform variables only)
                - sensitive: Whether the variable value is sensitive
    
        Returns:
            The updated variable with all current settings and configuration
    
        See:
            docs/tools/variables.md#update-variable-in-variable-set for reference documentation
        """
        param_dict = params.model_dump(exclude_none=True) if params else {}
    
        payload = {"data": {"type": "vars", "attributes": param_dict}}
    
        return await api_request(
            f"varsets/{varset_id}/relationships/vars/{var_id}", method="PATCH", data=payload
        )
  • Pydantic model defining the optional input parameters (key, value, description, category, hcl, sensitive) for updating a variable in a variable set.
    class VariableSetVariableParams(APIRequest):
        """Parameters for variable set variable operations without routing fields.
    
        This model provides all optional parameters for creating or updating variables
        within variable sets, separating configuration parameters from routing information
        like variable set ID and variable ID.
    
        Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/variable-sets
    
        See:
            docs/models/variables.md for reference
        """
    
        key: Optional[str] = Field(
            None,
            description="Variable name/key",
            min_length=1,
            max_length=255,
        )
        value: Optional[str] = Field(
            None,
            description="Variable value",
            max_length=256000,
        )
        description: Optional[str] = Field(
            None,
            description="Description of the variable",
            max_length=512,
        )
        category: Optional[VariableCategory] = Field(
            None,
            description="Variable category (terraform or env)",
        )
        hcl: Optional[bool] = Field(
            None,
            description="Whether the value is HCL code (only valid for terraform variables)",
        )
        sensitive: Optional[bool] = Field(
            None,
            description="Whether the variable value is sensitive",
        )
  • FastMCP tool registration line that registers the update_variable_in_variable_set handler function with write permissions configuration.
    mcp.tool(**write_tool_config)(variables.update_variable_in_variable_set)
Behavior4/5

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

Annotations indicate readOnlyHint=false (mutation), which the description confirms with 'Modifies'. The description adds valuable behavioral context: it specifies that only specified attributes are updated (partial update behavior), mentions the API endpoint format, and notes that unspecified attributes remain unchanged. This goes beyond the annotation's basic mutation hint.

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?

The description is well-structured with clear sections (purpose, behavior, API endpoint, args, returns, see). It's appropriately sized but includes some redundancy (e.g., repeating 'New' for each param) and the 'See' reference could be more concise. Most sentences earn their place by adding value.

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?

For a mutation tool with no output schema and 0% schema coverage, the description provides strong context: clear purpose, behavioral details (partial updates), full parameter semantics, and return value description. It lacks explicit error handling or permission requirements, but covers most essential aspects given the complexity.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by detailing all 3 parameters: varset_id and var_id with their ID formats, and params with a comprehensive list of 6 sub-parameters (key, value, description, category, hcl, sensitive) including constraints like 'terraform variables only' for hcl. This adds complete semantic meaning beyond the bare schema.

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 ('Update an existing variable in a variable set') and distinguishes it from sibling tools like 'create_variable_in_variable_set' and 'update_workspace_variable' by specifying it modifies existing variables within variable sets. It provides both verb ('Modifies') and resource ('existing variable within a variable set').

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 when to use this tool (to modify existing variables) and distinguishes it from creation tools, but doesn't explicitly state when not to use it or mention specific alternatives among siblings like 'update_workspace_variable' for workspace-specific updates. The context is clear but lacks explicit exclusion guidance.

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