Skip to main content
Glama
severity1

terraform-cloud-mcp

update_workspace

Modify Terraform Cloud workspace settings like execution mode, VCS repository, description, or configuration options. Only specified attributes are updated while others remain unchanged.

Instructions

Update an existing workspace.

Modifies the settings of a Terraform Cloud workspace. This can be used to change attributes like execution mode, VCS repository settings, description, or any other workspace configuration options. Only specified attributes will be updated; unspecified attributes remain unchanged.

API endpoint: PATCH /organizations/{organization}/workspaces/{workspace_name}

Args: organization: The name of the organization that owns the workspace workspace_name: The name of the workspace to update

params: Workspace parameters to update (optional):
    - name: New name for the workspace (if renaming)
    - description: Human-readable description of the workspace
    - execution_mode: How Terraform runs are executed (remote, local, agent)
    - terraform_version: Version of Terraform to use
    - working_directory: Subdirectory to use when running Terraform
    - vcs_repo: Version control repository configuration (oauth-token-id, identifier)
    - auto_apply: Whether to automatically apply successful plans
    - file_triggers_enabled: Whether file changes trigger runs
    - trigger_prefixes: Directories that trigger runs when changed
    - trigger_patterns: Glob patterns that trigger runs when files match
    - allow_destroy_plan: Whether to allow destruction plans
    - auto_apply_run_trigger: Whether to auto-apply changes from run triggers

Returns: The updated workspace with all current settings and configuration

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationYes
workspace_nameYes
paramsNo

Implementation Reference

  • The handler function that implements the tool logic: accepts organization, workspace_name, and optional WorkspaceParams; builds WorkspaceUpdateRequest; creates API payload excluding routing fields; logs and sends PATCH request to Terraform Cloud API; returns the updated workspace response.
    @handle_api_errors
    async def update_workspace(
        organization: str, workspace_name: str, params: Optional[WorkspaceParams] = None
    ) -> APIResponse:
        """Update an existing workspace.
    
        Modifies the settings of a Terraform Cloud workspace. This can be used to change
        attributes like execution mode, VCS repository settings, description, or any other
        workspace configuration options. Only specified attributes will be updated;
        unspecified attributes remain unchanged.
    
        API endpoint: PATCH /organizations/{organization}/workspaces/{workspace_name}
    
        Args:
            organization: The name of the organization that owns the workspace
            workspace_name: The name of the workspace to update
    
            params: Workspace parameters to update (optional):
                - name: New name for the workspace (if renaming)
                - description: Human-readable description of the workspace
                - execution_mode: How Terraform runs are executed (remote, local, agent)
                - terraform_version: Version of Terraform to use
                - working_directory: Subdirectory to use when running Terraform
                - vcs_repo: Version control repository configuration (oauth-token-id, identifier)
                - auto_apply: Whether to automatically apply successful plans
                - file_triggers_enabled: Whether file changes trigger runs
                - trigger_prefixes: Directories that trigger runs when changed
                - trigger_patterns: Glob patterns that trigger runs when files match
                - allow_destroy_plan: Whether to allow destruction plans
                - auto_apply_run_trigger: Whether to auto-apply changes from run triggers
    
        Returns:
            The updated workspace with all current settings and configuration
    
        See:
            docs/tools/workspace.md for reference documentation
        """
        # Extract parameters from the params object if provided
        param_dict = params.model_dump(exclude_none=True) if params else {}
    
        # Create request using Pydantic model
        request = WorkspaceUpdateRequest(
            organization=organization, workspace_name=workspace_name, **param_dict
        )
    
        # Create API payload using utility function
        payload = create_api_payload(
            resource_type="workspaces",
            model=request,
            exclude_fields={"organization", "workspace_name"},
        )
    
        # Log payload for debugging
        logger = logging.getLogger(__name__)
        logger.debug(f"Update workspace payload: {payload}")
    
        # Make API request
        response = await api_request(
            f"organizations/{organization}/workspaces/{workspace_name}",
            method="PATCH",
            data=payload,
        )
    
        # Log response for debugging
        logger.debug(f"Update workspace response: {response}")
    
        return response
  • Pydantic base model defining all configurable parameters for workspace updates (name, description, execution_mode, vcs_repo, auto_apply, terraform_version, trigger_patterns, etc.). Inherited by WorkspaceParams (tool input) and WorkspaceUpdateRequest (internal payload).
    class BaseWorkspaceRequest(APIRequest):
        """Base class for workspace create and update requests with common fields.
    
        This includes common fields used in request payloads for workspace
        creation and update APIs, providing a foundation for more specific workspace models.
    
        Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/workspaces
    
        Note:
            This class inherits model_config from APIRequest -> BaseModelConfig and provides
            default values for most fields based on Terraform Cloud API defaults.
    
        See:
            docs/models/workspace.md for detailed field descriptions and usage examples
        """
    
        # Fields common to both create and update requests with API defaults from docs
        name: Optional[str] = Field(
            None,
            # No alias needed as field name matches API field name
            description="Name of the workspace",
        )
        description: Optional[str] = Field(
            None,
            # No alias needed as field name matches API field name
            description="Description of the workspace",
        )
        execution_mode: Optional[Union[str, ExecutionMode]] = Field(
            ExecutionMode.REMOTE,
            alias="execution-mode",
            description="How operations are executed",
        )
        agent_pool_id: Optional[str] = Field(
            None, alias="agent-pool-id", description="The ID of the agent pool"
        )
        assessments_enabled: Optional[bool] = Field(
            False,
            alias="assessments-enabled",
            description="Whether to perform health assessments",
        )
        auto_apply: Optional[bool] = Field(
            False,
            alias="auto-apply",
            description="Whether to automatically apply changes in runs triggered by VCS, UI, or CLI",
        )
        auto_apply_run_trigger: Optional[bool] = Field(
            False,
            alias="auto-apply-run-trigger",
            description="Whether to automatically apply changes initiated by run triggers",
        )
        auto_destroy_at: Optional[str] = Field(
            None,
            alias="auto-destroy-at",
            description="Timestamp when the next scheduled destroy run will occur",
        )
        auto_destroy_activity_duration: Optional[str] = Field(
            None,
            alias="auto-destroy-activity-duration",
            description="Value and units for automatically scheduled destroy runs based on workspace activity",
        )
        file_triggers_enabled: Optional[bool] = Field(
            True,
            alias="file-triggers-enabled",
            description="Whether to filter runs based on file paths",
        )
        working_directory: Optional[str] = Field(
            None,
            alias="working-directory",
            description="The directory to execute commands in",
        )
        speculative_enabled: Optional[bool] = Field(
            True,
            alias="speculative-enabled",
            description="Whether this workspace allows speculative plans",
        )
        terraform_version: Optional[str] = Field(
            "latest",
            alias="terraform-version",
            description="Specifies the version of Terraform to use for this workspace",
        )
        global_remote_state: Optional[bool] = Field(
            False,
            alias="global-remote-state",
            description="Whether to allow all workspaces to access this workspace's state",
        )
        vcs_repo: Optional[Union[VcsRepoConfig, None]] = Field(
            None,
            alias="vcs-repo",
            description="Settings for the workspace's VCS repository",
        )
        allow_destroy_plan: Optional[bool] = Field(
            True,
            alias="allow-destroy-plan",
            description="Whether to allow destruction plans",
        )
        queue_all_runs: Optional[bool] = Field(
            False,
            alias="queue-all-runs",
            description="Whether runs should be queued immediately",
        )
        source_name: Optional[str] = Field(
            None,
            alias="source-name",
            description="Indicates where the workspace settings originated",
        )
        source_url: Optional[str] = Field(
            None, alias="source-url", description="URL to origin source"
        )
        trigger_prefixes: Optional[List[str]] = Field(
            None, alias="trigger-prefixes", description="List of paths that trigger runs"
        )
        trigger_patterns: Optional[List[str]] = Field(
            None,
            alias="trigger-patterns",
            description="List of glob patterns that trigger runs",
        )
        setting_overwrites: Optional[Dict[str, bool]] = Field(
            None,
            alias="setting-overwrites",
            description="Specifies attributes that have organization-level defaults",
        )
  • MCP tool registration calling mcp.tool on workspaces.update_workspace with write_tool_config (enabled unless read-only mode, non-readOnlyHint).
    mcp.tool(**write_tool_config)(workspaces.update_workspace)
  • Pydantic model used internally to construct the update request, adding required organization and workspace_name fields to BaseWorkspaceRequest.
    class WorkspaceUpdateRequest(BaseWorkspaceRequest):
        """Request model for updating a Terraform Cloud workspace.
    
        Validates and structures the request for updating workspaces. Extends BaseWorkspaceRequest
        with routing fields while keeping all configuration fields optional.
    
        Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/workspaces#update-a-workspace
    
        Note:
            This inherits all configuration fields from BaseWorkspaceRequest
            and adds required routing fields for the update operation.
    
        See:
            docs/models/workspace.md for reference
        """
    
        # Add fields which are required for updates but not part of the workspace attributes payload
        organization: str = Field(
            ...,
            # No alias needed as field name matches API field name
            description="The name of the organization that owns the workspace",
        )
        workspace_name: str = Field(
            ...,
            # No alias needed as field name matches API field name
            description="The name of the workspace to update",
        )
  • Pydantic model for optional params argument in tool signature, directly inheriting all fields from BaseWorkspaceRequest.
    class WorkspaceParams(BaseWorkspaceRequest):
        """Parameters for workspace operations without routing fields.
    
        This model provides all optional parameters for creating or updating workspaces,
        reusing field definitions from BaseWorkspaceRequest. It separates configuration
        parameters from routing information like organization and workspace name.
    
        Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/workspaces
    
        Note:
            When updating a workspace, use this model to specify only the attributes
            you want to change. Unspecified attributes retain their current values.
            All fields are inherited from BaseWorkspaceRequest.
    
        See:
            docs/models/workspace.md for reference
        """
    
        # Inherits model_config and all fields from BaseWorkspaceRequest
Behavior4/5

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

The description adds valuable behavioral context beyond the annotations. While annotations only indicate readOnlyHint=false (implying mutation), the description clarifies that 'only specified attributes will be updated; unspecified attributes remain unchanged', which is a critical partial-update behavior. It also mentions the API endpoint and references external documentation, though it does not detail authentication needs, rate limits, or error handling.

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, usage, args, returns, see) and front-loads the core purpose. However, it includes some redundancy (e.g., repeating 'update' in the first sentence) and could be more concise by integrating the parameter list more seamlessly, though the detailed parameter explanations are justified given the complexity.

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 (3 parameters with 0% schema coverage, no output schema, and no annotations beyond readOnlyHint), the description is largely complete. It explains the tool's purpose, parameters, and behavior, and references external documentation. However, it lacks details on return values (since no output schema) and does not fully address all behavioral aspects like error conditions or side effects.

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?

The description provides extensive parameter semantics that compensate for the 0% schema description coverage. It lists and explains 14 specific parameters (e.g., 'execution_mode: How Terraform runs are executed (remote, local, agent)'), adding meaning not present in the schema. This is crucial given the low schema coverage and the tool's 3 parameters, including a complex nested object.

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 tool 'updates an existing workspace' and specifies it 'modifies the settings of a Terraform Cloud workspace', providing a specific verb (update/modify) and resource (workspace settings). It distinguishes from sibling tools like 'create_workspace' by focusing on existing workspaces and from 'update_workspace_variable' by targeting workspace settings rather than variables.

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

Usage Guidelines3/5

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

The description implies usage for modifying workspace settings and mentions that 'only specified attributes will be updated', which provides some context. However, it lacks explicit guidance on when to use this tool versus alternatives like 'update_organization' or 'update_project', and does not mention prerequisites such as required permissions or when not to use it.

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