Skip to main content
Glama

get_current_state_version

Retrieve the current state version for a Terraform workspace to access input state details and download URLs, essential for managing infrastructure operations with Terraform Cloud.

Instructions

Get the current state version for a workspace.

Retrieves the current state version for a workspace, which is the input state when running terraform operations.

API endpoint: GET /workspaces/:workspace_id/current-state-version

Args: workspace_id: The ID of the workspace (format: "ws-xxxxxxxx")

Returns: The current state version including details and download URLs

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspace_idYes

Implementation Reference

  • The main handler function that executes the tool logic: validates the workspace_id using CurrentStateVersionRequest model and makes an API request to /workspaces/{workspace_id}/current-state-version to fetch the current state version.
    @handle_api_errors async def get_current_state_version(workspace_id: str) -> APIResponse: """Get the current state version for a workspace. Retrieves the current state version for a workspace, which is the input state when running terraform operations. API endpoint: GET /workspaces/:workspace_id/current-state-version Args: workspace_id: The ID of the workspace (format: "ws-xxxxxxxx") Returns: The current state version including details and download URLs See: docs/tools/state_versions.md for reference documentation """ # Validate parameters params = CurrentStateVersionRequest(workspace_id=workspace_id) # Make API request return await api_request(f"workspaces/{params.workspace_id}/current-state-version")
  • Pydantic model for input schema validation: defines and validates the workspace_id parameter with regex pattern for workspace IDs.
    class CurrentStateVersionRequest(APIRequest): """Request model for retrieving a workspace's current state version. Used to validate the workspace ID parameter for current state version API requests. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/state-versions#get-current-state-version See: docs/models/state_versions.md for reference """ workspace_id: str = Field( ..., description="The ID of the workspace to retrieve the current state version for", pattern=r"^ws-[a-zA-Z0-9]{16}$", # Standard workspace ID pattern )
  • Registers the get_current_state_version function from the state_versions module as an MCP tool using FastMCP's tool decorator.
    mcp.tool()(state_versions.get_current_state_version)

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