terraform-cloud-mcp
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Integrations
Terraform Cloud MCP Server
A Model Context Protocol (MCP) server that integrates Claude with the Terraform Cloud API, allowing Claude to manage your Terraform infrastructure through natural conversation.
Features
- Authentication - Validate tokens and get user information
- Workspace Management - Create, read, update, delete, lock/unlock workspaces
- Run Management - Create runs, list runs, get run details, apply/discard/cancel runs
- Future Features - State management, variables management, and more
Quick Start
Setup
Starting the Server
The server supports multiple ways to provide your Terraform Cloud API token:
When a token is provided, Claude can use it without you having to specify it in every command.
Connecting with Claude
Using Claude Code CLI
Available Tools
Authentication Tools
The following tools help validate and work with Terraform Cloud API tokens:
validate_token()
Validates a Terraform Cloud API tokenget_terraform_user_info()
Gets user information for the provided token
Workspace Management Tools
List & Search
Tools for finding and inspecting workspaces:
list_workspaces(organization, ...)
List and filter workspaces with comprehensive optionsRequired:organization
- Organization name
Optional: Filtering by name, tags, pagination, sorting and moreget_workspace_details(organization, workspace_name)
Get detailed information about a specific workspaceRequired:organization
,workspace_name
Create & Update
Tools for creating and modifying workspaces:
create_workspace(organization, name, ...)
Create a new workspace with various configuration optionsRequired:organization
,name
Optional: Configure Terraform version, VCS settings, execution mode, etc.update_workspace(organization, workspace_name, ...)
Update an existing workspace's configurationRequired:organization
,workspace_name
Optional: Update name, description, settings, VCS connections, etc.
Delete
Tools for removing workspaces:
delete_workspace(organization, workspace_name)
Delete a workspace and all its contentRequired:organization
,workspace_name
safe_delete_workspace(organization, workspace_name)
Delete only if the workspace isn't managing any resourcesRequired:organization
,workspace_name
Lock & Unlock
Tools for controlling workspace access:
lock_workspace(organization, workspace_name, reason)
Lock a workspace to prevent runsRequired:organization
,workspace_name
Optional:reason
- Explanation for the lockunlock_workspace(organization, workspace_name)
Unlock a workspace to allow runsRequired:organization
,workspace_name
force_unlock_workspace(organization, workspace_name)
Force unlock a workspace locked by another userRequired:organization
,workspace_name
Run Management Tools
Tools for managing Terraform runs (plan, apply, and other operations):
create_run(organization, workspace_name, ...)
Create and queue a Terraform run in a workspaceRequired:organization
,workspace_name
Optional:message
,auto_apply
,is_destroy
,refresh
,refresh_only
,plan_only
,target_addrs
,replace_addrs
,variables
, and more configuration optionslist_runs_in_workspace(organization, workspace_name, ...)
List and filter runs in a specific workspace with comprehensive optionsRequired:organization
,workspace_name
Optional: Pagination, filtering by status/operation/source, searching by user/commitlist_runs_in_organization(organization, ...)
List and filter runs across an entire organizationRequired:organization
Optional: Pagination, filtering by workspace/status/operation/source, searching by user/commitget_run_details(run_id)
Get detailed information about a specific runRequired:run_id
apply_run(run_id, comment)
Apply a run that is paused waiting for confirmation after a planRequired:run_id
Optional:comment
discard_run(run_id, comment)
Discard a run that is waiting for confirmation or priorityRequired:run_id
Optional:comment
cancel_run(run_id, comment)
Cancel a run that is currently planning or applyingRequired:run_id
Optional:comment
force_cancel_run(run_id, comment)
Forcefully cancel a run immediately (after a normal cancel)Required:run_id
Optional:comment
force_execute_run(run_id)
Forcefully execute a pending run by canceling prior runsRequired:run_id
Example Conversations
Authentication & Listing
Workspace Management
Locking Workspaces
Run Management
User: Apply the pending run for "staging" workspace Claude: [Uses apply_run to apply the waiting run]
User: Cancel the run "run-CZcmD7eagjhyX0vN", it's taking too long Claude: [Uses cancel_run to safely interrupt the running process]
User: Discard the plan for the "dev" workspace, those changes aren't needed Claude: [Uses discard_run to discard the pending run]
User: Force cancel the stuck run in "production" Claude: [Uses force_cancel_run to immediately terminate the stuck run]
User: I need to execute this run immediately, force execute it Claude: [Uses force_execute_run to bypass the queue and start the run]
User: List all variables defined in "production" Claude: [Will use list_workspace_variables tool]
User: Show me the plan output and explain the changes Claude: [Will use get_plan_output and explain_plan tools]
terraform-cloud-mcp/ ├── api/ # API client and communication │ ├── init.py │ └── client.py # HTTP client for Terraform Cloud API ├── models/ # Data models │ ├── init.py │ └── auth.py # Authentication models ├── tools/ # MCP tools implementation │ ├── init.py │ ├── auth.py # Authentication tools │ ├── runs.py # Run management tools (create, list, apply, discard, cancel runs) │ └── workspaces.py # Workspace management tools ├── utils/ # Utility functions │ ├── init.py │ └── validators.py # Input validation ├── server.py # Main server entry point └── requirements.txt # Project dependencies
- If using
mcp dev server.py
, use the MCP Inspector at http://localhost:5173 to debug tool calls
Contributing
Contributions are welcome! Please open an issue or pull request if you'd like to contribute to this project.
This server cannot be installed
A Model Context Protocol (MCP) server that integrates Claude with the Terraform Cloud API, allowing Claude to manage your Terraform infrastructure through natural conversation.