Skip to main content
Glama

create_project

Create and organize Terraform Cloud projects to group workspaces, manage settings, and apply permissions. Define project details, auto-destroy duration, and tag bindings for efficient infrastructure management.

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
nameYes
organizationYes
paramsNo

Implementation Reference

  • The async handler function implementing the core logic of the 'create_project' tool. It constructs a payload using Pydantic models and sends a POST request to the Terraform Cloud API to create a new project.
    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 )
  • The registration of the 'create_project' tool in the MCP server using FastMCP's mcp.tool decorator with write permissions configuration.
    mcp.tool(**write_tool_config)(projects.create_project)
  • Pydantic model for optional project parameters passed to the create_project tool, inheriting fields like description, auto-destroy duration, and tag bindings for input validation.
    class ProjectParams(BaseProjectRequest): """Parameters for project operations without routing fields. This model provides all optional parameters for creating or updating projects, reusing field definitions from BaseProjectRequest. It separates configuration parameters from routing information like organization and project ID. Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/projects Note: When updating a project, use this model to specify only the attributes you want to change. Unspecified attributes retain their current values. All fields are inherited from BaseProjectRequest. See: docs/models/project.md for reference """ # Inherits model_config and all fields from BaseProjectRequest
  • Internal Pydantic model used by the handler to structure the API request payload for project creation, providing type 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", )
  • Pydantic model for tag bindings that can be included in project parameters for associating tags with the project.
    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")

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