Skip to main content
Glama

create_variable_set

Create and manage variable sets in Terraform Cloud organizations to streamline variable management across multiple workspaces and projects.

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
nameYes
organizationYes
paramsNo

Implementation Reference

  • The core async handler function that implements the tool logic: validates inputs using Pydantic models, constructs the API payload, and performs the POST request to create the variable set in Terraform Cloud.
    @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 the optional input parameters for the variable set (name, description, global, priority), used in the tool's params argument for input validation.
    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", )
  • MCP tool registration line that decorates the handler function with mcp.tool using write_tool_config to enable it conditionally and mark it as non-read-only.
    mcp.tool(**write_tool_config)(variables.create_variable_set)
  • Configuration dictionary used in registration for write tools, controlling enablement based on read-only mode and adding annotations.
    write_tool_config = { "enabled": not read_only_mode, "annotations": {"readOnlyHint": False} }

Other Tools

Related 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