Skip to main content
Glama

move_workspaces_to_project

Move Terraform Cloud workspaces into a specified project by providing project and workspace IDs. Organize infrastructure management by grouping related workspaces together.

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 handler function that implements the tool logic by validating inputs with WorkspaceMoveRequest model and making a POST API 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 defining the input schema for the tool, including required project_id and list of workspace_ids with descriptions and validation.
    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 function as an MCP tool with write permissions using the FastMCP decorator.
    mcp.tool(**write_tool_config)(projects.move_workspaces_to_project)

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