Skip to main content
Glama
severity1

terraform-cloud-mcp

create_variable_set

Create a new variable set to manage Terraform variables across multiple workspaces and projects in your organization.

Instructions

Create a new variable set in an organization.

Creates a new variable set which can be used to manage variables across multiple workspaces and projects.

API endpoint: POST /organizations/{organization}/varsets

Args: organization: The name of the organization name: The name to give the variable set

params: Additional variable set parameters (optional):
    - description: Description of the variable set
    - global: Whether this is a global variable set
    - priority: Whether this variable set takes priority over workspace variables

Returns: The created variable set with its configuration and metadata

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationYes
nameYes
paramsNo

Implementation Reference

  • The main async handler function that executes the tool logic: creates a variable set by constructing a request payload and calling the Terraform Cloud API.
    @handle_api_errors
    async def create_variable_set(
        organization: str,
        name: str,
        params: Optional[VariableSetParams] = None,
    ) -> APIResponse:
        """Create a new variable set in an organization.
    
        Creates a new variable set which can be used to manage variables across
        multiple workspaces and projects.
    
        API endpoint: POST /organizations/{organization}/varsets
    
        Args:
            organization: The name of the organization
            name: The name to give the variable set
    
            params: Additional variable set parameters (optional):
                - description: Description of the variable set
                - global: Whether this is a global variable set
                - priority: Whether this variable set takes priority over workspace variables
    
        Returns:
            The created variable set with its configuration and metadata
    
        See:
            docs/tools/variables.md#create-variable-set for reference documentation
        """
        param_dict = params.model_dump(exclude_none=True) if params else {}
        request = VariableSetCreateRequest(
            organization=organization, name=name, **param_dict
        )
    
        payload = create_api_payload(
            resource_type="varsets", model=request, exclude_fields={"organization"}
        )
    
        return await api_request(
            f"organizations/{organization}/varsets", method="POST", data=payload
        )
  • Pydantic model defining optional parameters (name, description, global, priority) for variable set creation and updates.
    class VariableSetParams(APIRequest):
        """Parameters for variable set operations without routing fields.
    
        This model provides all optional parameters for creating or updating variable
        sets, separating configuration parameters from routing information.
    
        Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/variable-sets
    
        See:
            docs/models/variables.md for reference
        """
    
        name: Optional[str] = Field(
            None,
            description="Variable set name",
            min_length=1,
            max_length=90,
        )
        description: Optional[str] = Field(
            None,
            description="Description of the variable set",
            max_length=512,
        )
        global_: Optional[bool] = Field(
            None,
            alias="global",
            description="Whether this is a global variable set",
        )
        priority: Optional[bool] = Field(
            None,
            description="Whether this variable set takes priority over workspace variables",
        )
  • Pydantic model for the full create request, including required organization and name fields, embedding optional params.
    class VariableSetCreateRequest(APIRequest):
        """Request model for creating variable sets.
    
        Used for POST /organizations/:organization/varsets endpoint.
    
        Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/variable-sets
    
        See:
            docs/models/variables.md for reference
        """
    
        organization: str = Field(
            ...,
            description="The organization name",
            min_length=1,
        )
        name: str = Field(
            ...,
            description="Variable set name",
            min_length=1,
            max_length=90,
        )
        params: Optional[VariableSetParams] = Field(
            None,
            description="Additional variable set parameters",
        )
  • Registers the create_variable_set handler as an MCP tool with write permissions configuration.
    mcp.tool(**write_tool_config)(variables.create_variable_set)

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