Skip to main content
Glama

lock_workspace

Prevent changes to infrastructure by locking a workspace. Use this tool to halt new runs during maintenance or manual adjustments without interrupting active operations.

Instructions

Lock a workspace.

Locks a workspace to prevent runs from being queued. This is useful when you want to prevent changes to infrastructure while performing maintenance or making manual adjustments. Locking a workspace does not affect currently running plans or applies.

API endpoint: POST /workspaces/{workspace_id}/actions/lock

Args: workspace_id: The ID of the workspace to lock (format: "ws-xxxxxxxx") reason: Optional reason for locking

Returns: The workspace with updated lock status and related metadata

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
reasonNo
workspace_idYes

Implementation Reference

  • The main handler function that implements the lock_workspace tool by making a POST request to the Terraform Cloud API to lock the specified workspace.
    @handle_api_errors async def lock_workspace(workspace_id: str, reason: str = "") -> APIResponse: """Lock a workspace. Locks a workspace to prevent runs from being queued. This is useful when you want to prevent changes to infrastructure while performing maintenance or making manual adjustments. Locking a workspace does not affect currently running plans or applies. API endpoint: POST /workspaces/{workspace_id}/actions/lock Args: workspace_id: The ID of the workspace to lock (format: "ws-xxxxxxxx") reason: Optional reason for locking Returns: The workspace with updated lock status and related metadata See: docs/tools/workspace.md for reference documentation """ payload = {} if reason: payload = {"reason": reason} return await api_request( f"workspaces/{workspace_id}/actions/lock", method="POST", data=payload )
  • Registers the lock_workspace tool with the MCP server using the mcp.tool decorator and write_tool_config.
    mcp.tool(**write_tool_config)(workspaces.lock_workspace)
  • Configuration used for registering write tools like lock_workspace, including enabling conditions and 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