Skip to main content
Glama
severity1

terraform-cloud-mcp

get_current_state_version

Retrieve the current Terraform state version for a workspace to access input state details and download URLs for infrastructure operations.

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 handler function that retrieves the current state version for a given workspace ID using the Terraform Cloud API endpoint GET /workspaces/:workspace_id/current-state-version. It validates input with CurrentStateVersionRequest model and uses api_request utility.
    @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 validation of the workspace_id parameter, ensuring it matches the ws-xxxxxxxx pattern.
    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
        )
  • Tool registration using FastMCP's mcp.tool() decorator, importing from tools.state_versions.
    mcp.tool()(state_versions.get_current_state_version)

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