Skip to main content
Glama

create_project

Create a Terraform Cloud project to organize workspaces into logical groups with configurable settings and permissions.

Instructions

Create a new project in an organization.

Creates a new Terraform Cloud project which serves as a container for workspaces. Projects help organize workspaces into logical groups and can have their own settings and permissions.

API endpoint: POST /organizations/{organization}/projects

Args: organization: The name of the organization name: The name to give the project params: Additional project parameters (optional): - description: Human-readable description of the project - auto_destroy_activity_duration: How long each workspace should wait before auto-destroying (e.g., '14d', '24h') - tag_bindings: List of tag key-value pairs to bind to the project

Returns: The created project data including configuration, settings and metadata

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationYes
nameYes
paramsNo

Implementation Reference

  • Main handler function implementing the create_project tool. It constructs the API payload using Pydantic models, handles special tag_bindings in relationships, and makes a POST request to the Terraform Cloud API to create the project.
    @handle_api_errors async def create_project( organization: str, name: str, params: Optional[ProjectParams] = None ) -> APIResponse: """Create a new project in an organization. Creates a new Terraform Cloud project which serves as a container for workspaces. Projects help organize workspaces into logical groups and can have their own settings and permissions. API endpoint: POST /organizations/{organization}/projects Args: organization: The name of the organization name: The name to give the project params: Additional project parameters (optional): - description: Human-readable description of the project - auto_destroy_activity_duration: How long each workspace should wait before auto-destroying (e.g., '14d', '24h') - tag_bindings: List of tag key-value pairs to bind to the project Returns: The created project data including configuration, settings and metadata See: docs/tools/project.md for reference documentation """ param_dict = params.model_dump(exclude_none=True) if params else {} request = ProjectCreateRequest(organization=organization, name=name, **param_dict) # Create the base payload payload = create_api_payload( resource_type="projects", model=request, exclude_fields={"organization"} ) # Handle tag bindings if present if request.tag_bindings: tag_bindings_data = [] for tag in request.tag_bindings: tag_bindings_data.append( { "type": "tag-bindings", "attributes": {"key": tag.key, "value": tag.value}, } ) if "relationships" not in payload["data"]: payload["data"]["relationships"] = {} payload["data"]["relationships"]["tag-bindings"] = {"data": tag_bindings_data} # Remove tag-bindings from attributes if present since we've moved them to relationships if "tag-bindings" in payload["data"]["attributes"]: del payload["data"]["attributes"]["tag-bindings"] logger = logging.getLogger(__name__) logger.debug(f"Create project payload: {payload}") return await api_request( f"organizations/{organization}/projects", method="POST", data=payload )
  • Registration of the create_project tool in the MCP server using the mcp.tool decorator with write permissions configuration.
    mcp.tool(**write_tool_config)(projects.create_project)
  • Pydantic schema model ProjectCreateRequest used internally in the handler for payload creation and validation.
    class ProjectCreateRequest(BaseProjectRequest): """Request model for creating a Terraform Cloud project. Validates and structures the request according to the Terraform Cloud API requirements for creating projects. Extends BaseProjectRequest with required fields for creation. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/projects#create-a-project Note: This inherits all configuration fields from BaseProjectRequest while making organization and name required. See: docs/models/project.md for reference """ # Organization is needed for routing but not included in the payload organization: str = Field( ..., description="The name of the organization to create the project in", ) # Override name to make it required for creation name: str = Field( ..., description="Name of the project", )
  • Base Pydantic schema defining optional parameters (name, description, auto_destroy_activity_duration, tag_bindings) used via ProjectParams in the tool function signature.
    class BaseProjectRequest(APIRequest): """Base class for project create and update requests with common fields. This includes common fields used in request payloads for project creation and update APIs, providing a foundation for more specific project models. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/projects Note: This class inherits model_config from APIRequest -> BaseModelConfig and provides default values for fields based on Terraform Cloud API defaults. See: docs/models/project.md for detailed field descriptions and usage examples """ # Fields common to both create and update requests name: Optional[str] = Field( None, description="Name of the project", ) description: Optional[str] = Field( None, description="Description of the project", ) auto_destroy_activity_duration: Optional[str] = Field( None, alias="auto-destroy-activity-duration", description="How long each workspace should wait before auto-destroying (e.g., '14d', '24h')", ) tag_bindings: Optional[List[TagBinding]] = Field( None, alias="tag-bindings", description="Tags to bind to the project, inherited by workspaces", )
  • Pydantic schema for individual tag bindings used in project creation.
    class TagBinding(APIRequest): """Tag binding configuration for a project. Defines a tag key-value pair that can be bound to a project and inherited by its workspaces. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/projects See: docs/models/project.md for reference """ # Inherits model_config from APIRequest -> BaseModelConfig key: str = Field(..., description="The key of the tag") value: str = Field(..., description="The value of the tag")

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