Skip to main content
Glama

move_workspaces_to_project

Relocate multiple workspaces to a specified project in Terraform Cloud using the designated API endpoint. Requires user permissions on both source and destination projects.

Instructions

Move workspaces into a project.

Moves one or more workspaces into a project. The user must have permission to move workspaces on both source and destination projects.

API endpoint: POST /projects/{project_id}/relationships/workspaces

Args: project_id: The ID of the destination project (format: "prj-xxxxxxxx") workspace_ids: List of workspace IDs to move (format: ["ws-xxxxxxxx", ...])

Returns: Empty response with HTTP 204 status code if successful

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
workspace_idsYes

Implementation Reference

  • The main asynchronous handler function that executes the tool logic: validates inputs using Pydantic, constructs the API payload, and sends a POST request to move workspaces into the specified project.
    @handle_api_errors async def move_workspaces_to_project( project_id: str, workspace_ids: List[str] ) -> APIResponse: """Move workspaces into a project. Moves one or more workspaces into a project. The user must have permission to move workspaces on both source and destination projects. API endpoint: POST /projects/{project_id}/relationships/workspaces Args: project_id: The ID of the destination project (format: "prj-xxxxxxxx") workspace_ids: List of workspace IDs to move (format: ["ws-xxxxxxxx", ...]) Returns: Empty response with HTTP 204 status code if successful See: docs/tools/project.md for reference documentation """ # Create request using Pydantic model request = WorkspaceMoveRequest(project_id=project_id, workspace_ids=workspace_ids) # Create payload payload: Dict[str, List[Dict[str, str]]] = {"data": []} for workspace_id in request.workspace_ids: payload["data"].append({"type": "workspaces", "id": workspace_id}) # Make API request return await api_request( f"projects/{project_id}/relationships/workspaces", method="POST", data=payload )
  • Pydantic model (WorkspaceMoveRequest) providing input schema validation for project_id and list of workspace_ids used by the handler.
    class WorkspaceMoveRequest(APIRequest): """Request model for moving workspaces into a project. This model is used for the POST /projects/{project_id}/relationships/workspaces endpoint, which allows moving one or more workspaces into a project. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/projects#move-workspaces-into-a-project See: docs/models/project.md for reference """ project_id: str = Field( ..., description="The ID of the destination project", ) workspace_ids: List[str] = Field( ..., description="The IDs of workspaces to move into the project", )
  • Registers the move_workspaces_to_project handler as an MCP tool with write permissions configuration.
    mcp.tool(**write_tool_config)(projects.move_workspaces_to_project)

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