update_organization
Modify organization settings in Terraform Cloud, including email, authentication policies, session timeouts, cost estimation, and workspace execution modes. Updates only specified attributes via API endpoint.
Instructions
Update an existing organization in Terraform Cloud
Modifies organization settings such as email contact, authentication policy, or other configuration options. Only specified attributes will be updated.
API endpoint: PATCH /organizations/{organization}
Args: organization: The name of the organization to update (required) params: Organization parameters to update: - email: Admin email address for the organization - collaborator_auth_policy: Authentication policy (password or two_factor_mandatory) - session_timeout: Session timeout after inactivity in minutes - session_remember: Session total expiration time in minutes - cost_estimation_enabled: Whether to enable cost estimation for workspaces - default_execution_mode: Default workspace execution mode (remote, local, agent) - aggregated_commit_status_enabled: Whether to aggregate VCS status updates - speculative_plan_management_enabled: Whether to auto-cancel unused speculative plans - assessments_enforced: Whether to enforce health assessments for all workspaces - allow_force_delete_workspaces: Whether to allow deleting workspaces with resources
Returns: The updated organization with all current settings
See: docs/tools/organization.md for reference documentation
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organization | Yes | ||
| params | No |
Implementation Reference
- The main asynchronous handler function implementing the tool logic. It constructs the request payload using Pydantic models and makes a PATCH API request to update the organization in Terraform Cloud.@handle_api_errors async def update_organization( organization: str, params: Optional[OrganizationParams] = None ) -> APIResponse: """Update an existing organization in Terraform Cloud Modifies organization settings such as email contact, authentication policy, or other configuration options. Only specified attributes will be updated. API endpoint: PATCH /organizations/{organization} Args: organization: The name of the organization to update (required) params: Organization parameters to update: - email: Admin email address for the organization - collaborator_auth_policy: Authentication policy (password or two_factor_mandatory) - session_timeout: Session timeout after inactivity in minutes - session_remember: Session total expiration time in minutes - cost_estimation_enabled: Whether to enable cost estimation for workspaces - default_execution_mode: Default workspace execution mode (remote, local, agent) - aggregated_commit_status_enabled: Whether to aggregate VCS status updates - speculative_plan_management_enabled: Whether to auto-cancel unused speculative plans - assessments_enforced: Whether to enforce health assessments for all workspaces - allow_force_delete_workspaces: Whether to allow deleting workspaces with resources Returns: The updated organization with all current settings See: docs/tools/organization.md for reference documentation """ # Extract parameters from the params object if provided param_dict = params.model_dump(exclude_none=True) if params else {} # Create request using Pydantic model request = OrganizationUpdateRequest(organization=organization, **param_dict) # Create API payload using utility function payload = create_api_payload( resource_type="organizations", model=request, exclude_fields={"organization"} ) # Make the API request return await api_request( f"organizations/{organization}", method="PATCH", data=payload )
- terraform_cloud_mcp/server.py:79-79 (registration)The registration of the 'update_organization' tool using the FastMCP decorator with write permissions configuration.mcp.tool(**write_tool_config)(organizations.update_organization)
- Pydantic base model defining all input fields and validation for organization update parameters, inherited by OrganizationParams used in the tool handler.class BaseOrganizationRequest(APIRequest): """Base class for organization create and update requests with common fields. This includes all fields that are commonly used in request payloads for the organization creation and update APIs. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/organizations Note: This class inherits model_config from APIRequest -> BaseModelConfig See: docs/models/organization.md for fields and usage examples """ # Fields common to both create and update requests with API defaults from docs name: Optional[str] = Field( None, # No alias needed as field name matches API field name description="Name of the organization", min_length=3, pattern=r"^[a-z0-9][-a-z0-9_]*[a-z0-9]$", ) email: Optional[str] = Field( None, # No alias needed as field name matches API field name description="Admin email address", pattern=r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", ) session_timeout: Optional[int] = Field( 20160, alias="session-timeout", description="Session timeout after inactivity in minutes", ge=1, le=43200, # 30 days in minutes ) session_remember: Optional[int] = Field( 20160, alias="session-remember", description="Session expiration in minutes", ge=1, le=43200, # 30 days in minutes ) collaborator_auth_policy: Optional[Union[str, CollaboratorAuthPolicy]] = Field( CollaboratorAuthPolicy.PASSWORD, alias="collaborator-auth-policy", description="Authentication policy", ) cost_estimation_enabled: Optional[bool] = Field( False, alias="cost-estimation-enabled", description="Whether cost estimation is enabled for all workspaces", ) send_passing_statuses_for_untriggered_speculative_plans: Optional[bool] = Field( False, alias="send-passing-statuses-for-untriggered-speculative-plans", description="Whether to send VCS status updates for untriggered plans", ) aggregated_commit_status_enabled: Optional[bool] = Field( True, alias="aggregated-commit-status-enabled", description="Whether to aggregate VCS status updates", ) speculative_plan_management_enabled: Optional[bool] = Field( True, alias="speculative-plan-management-enabled", description="Whether to enable automatic cancellation of plan-only runs", ) owners_team_saml_role_id: Optional[str] = Field( None, alias="owners-team-saml-role-id", description="SAML only - the name of the 'owners' team", ) assessments_enforced: Optional[bool] = Field( False, alias="assessments-enforced", description="Whether to compel health assessments for all eligible workspaces", ) allow_force_delete_workspaces: Optional[bool] = Field( False, alias="allow-force-delete-workspaces", description="Whether workspace admins can delete workspaces with resources", ) default_execution_mode: Optional[Union[str, ExecutionMode]] = Field( ExecutionMode.REMOTE, alias="default-execution-mode", description="Default execution mode", ) default_agent_pool_id: Optional[str] = Field( None, alias="default-agent-pool-id", description="The ID of the agent pool (required when default_execution_mode is 'agent')", )
- Pydantic model directly used as input type 'params' in the update_organization handler, inheriting all fields from BaseOrganizationRequest.class OrganizationParams(BaseOrganizationRequest): """Parameters for organization operations without routing fields. This model provides all optional parameters that can be used when creating or updating organizations, reusing the field definitions from BaseOrganizationRequest. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/organizations Note: All fields are inherited from BaseOrganizationRequest. See: docs/models/organization.md for reference """ # Inherits model_config and all fields from BaseOrganizationRequest