# Terraform Cloud (HCP) MCP for AI Agents AI Agent Connect

> Terraform Cloud (HCP) MCP lets you manage your entire infrastructure lifecycle through an AI agent. You can create organizations, manage workspaces, trigger runs, and inspect state outputs without leaving your chat interface. It turns your Infrastructure as Code into a conversational workflow, giving you direct control over your HCP environment.

## Overview
- **Category:** ship-it
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_pNVIE7JDmTNH9R3AT9KWNrBlFpc8rqVEBmhZ8zXB/ai-agent-connect
- **Tags:** infrastructure-as-code, provisioning, workspace-management, automation, cloud-ops, state-management

## Description

Imagine you're in the middle of a production incident and need to see why a specific workspace is locked or what the last successful plan output was. Usually, that means jumping into the browser, hunting for the right organization, and digging through logs. With this Connector, you just ask your agent. It handles the heavy lifting of talking to the Terraform Cloud API for you. You can tell it to spin up a new workspace, configure your variable sets, or even check on the progress of a running plan. It's about moving from clicking through tabs to telling the agent what to do. By connecting this to Vinkius, you get a unified way to manage your cloud infrastructure alongside your other tools. It makes the tedious parts of cloud ops, like managing team access or updating policy sets, feel like a quick conversation rather than a multi-step manual process. You can also manage high-level governance by listing projects or creating new organizations on the fly. If you need to audit your security posture, you can list audit events or upload new policy code to your registry. This Connector turns your Infrastructure as Code into a conversational workflow, giving you direct control over your HCP environment without the friction of a complex UI. It's for anyone who wants to move faster and keep their focus on the actual infrastructure rather than the management overhead.

## Tools

### apply_run
Apply a planned run to your infrastructure. Use this to finalize changes after a plan is approved.

### get_state_version_outputs
Get the outputs for a specific state version. Use this to retrieve values like IPs or IDs.

### add_team_workspace_access
Grant a team access to a workspace. This is useful for setting up environment-specific permissions.

### apply_variable_set_to_workspace
Apply a variable set to a workspace. This lets you inject configuration data into your environments quickly.

### associate_run_task_to_workspace
Associate a run task with a workspace. This helps in organizing and tracking specific tasks within your infrastructure.

### create_team
Create a new team in your organization. This is a core part of managing user access.

### create_variable_set
Create a variable set. Use this to store reusable variables for different environments.

### create_workspace
Create a new workspace. This is how you define a new environment or project area.

### discard_run
Discard a run after it's finished. This keeps your run history clean and organized.

### explorer_query
Execute an explorer query across your workspaces. Use this to find specific resources across your entire account.

### force_unlock_workspace
Force unlock a workspace. This is a lifesaver when a run gets stuck or a process hangs.

### get_current_state_version
Get the current state version for a workspace. Use this to see the most recent snapshot of your infrastructure.

### get_plan_json
Get the JSON output of an execution plan. This is useful for programmatic analysis of what will change.

### list_audit_events
List all audit events for an organization. Use this to track who did what and when.

### list_organizations
List all HCP Terraform organizations. This gives you a high-level view of your account.

### list_projects
List all projects in an organization. Use this to see how resources are grouped.

### list_teams
List all teams in an organization. This helps you audit your current user permissions.

### safe_delete_workspace
Safe delete a workspace. This ensures that a workspace is removed without leaving orphaned resources.

### show_apply
Show the details of a completed apply. Use this to review what actually happened during a deployment.

### show_organization
Show details of a specific organization. Use this to see the high-level configuration of an org.

### show_plan
Show the details of a plan. Use this to see what changes are about to happen before you apply them.

### unlock_workspace
Unlock a workspace. Use this to release a workspace after maintenance is finished.

### update_organization
Update an existing organization. Use this to change high-level settings or metadata.

### update_team
Update a team's configuration. Use this to modify team names or other attributes.

### upload_policy_code
Upload code for a policy. Use this to update your Sentinel or OPA rules.

### add_team_user
Add a user to a specific team. This helps you manage permissions without manually editing user roles.

### cancel_run
Cancel a run that is currently in progress. Use this to stop a plan or apply if it's behaving unexpectedly.

### create_notification_configuration
Create a notification configuration for a workspace. This ensures your team gets alerted on important infrastructure changes.

### create_organization
Create a new organization in your HCP account. Use this to set up new governance boundaries.

### create_policy_set
Create a new policy set. This helps in grouping your security and compliance policies.

### create_policy
Create a new policy. This allows you to define specific rules for your infrastructure.

### create_project
Create a new project within an organization. Use this to group related workspaces and resources.

### create_registry_module
Create a private registry module without a VCS. This is great for sharing internal modules.

### create_registry_provider
Create a private registry provider. Use this to host your own private Terraform providers.

### create_run_task
Create a new run task. This allows you to break down complex runs into smaller, manageable tasks.

### create_run
Create a new run for a plan or apply. This is the primary way to start infrastructure changes.

### create_state_version
Create a new state version. Use this to manage your state history and snapshots.

### create_workspace_variable
Create a variable in a specific workspace. This helps with fine-grained configuration.

### destroy_organization
Destroy an organization. Use this for decommissioning entire infrastructure environments.

### list_workspaces
List all workspaces in an organization. Use this to see every environment you have active.

### lock_workspace
Lock a workspace to prevent other changes. Use this when performing sensitive maintenance.

### remove_team_user
Remove a user from a team. This is the standard way to revoke access from an account.

## Prompt Examples

**Prompt:** 
```
List all the organizations I have access to in Terraform Cloud.
```

**Response:** 
```
I've found the following organizations in your account:

| Organization Name | ID |
| :--- | :--- |
| **Acme-Corp** | `org-9921` |
| **Dev-Sandbox** | `org-4412` |

Which one would you like to explore further?
```

**Prompt:** 
```
Show me the workspaces in the production org that have a 'vpc' tag.
```

**Response:** 
```
Searching the production organization... I found 3 workspaces matching that tag:

*   **vpc-prod** (`ws-K9j2L8mP1`)
    *   **vpc-backup** (`ws-L2mP9...`)
    *   **vpc-test** (`ws-M5kP0...`)

Would you like me to show the state outputs for any of these?
```

**Prompt:** 
```
What are the output values for workspace ws-K9j2L8mP1?
```

**Response:** 
```
Here are the current outputs for the **vpc-prod** workspace:

*   **vpc_id**: `vpc-0a1b2c`
*   **public_subnets**: `['subnet-1', 'subnet-2']`
*   **region**: `us-east-1`

Let me know if you need me to check any other workspace outputs.
```

## Capabilities

### Manage workspace locks
Force unlock or lock workspaces to prevent concurrent changes during maintenance.

### Trigger infrastructure plans
Start new runs and monitor their progress in real-time from your chat.

### Configure variable sets
Apply environment-specific variables to your workspaces to automate configuration.

### Control team access
Add or remove users from specific teams to maintain strict security governance.

### Inspect state outputs
Retrieve specific values from your current state versions for downstream data use.

### Manage policy sets
Create and upload code for OPA or Sentinel policies to enforce compliance.

## Use Cases

### Emergency Workspace Unlock
An engineer finds a workspace locked during a deployment. They ask the agent to use force_unlock_workspace to clear the block and resume the pipeline.

### Quick State Auditing
A lead architect needs to see outputs for a production VPC. They ask the agent to use get_state_version_outputs for the specific workspace to find the IP range.

### Automated Team Onboarding
A new hire needs access. The admin tells the agent to use create_team and add_team_user to set up their permissions in seconds.

### Run Status Monitoring
A developer wants to know if a run finished. They ask the agent to use show_apply to get the status of the latest infrastructure change.

## Benefits

- Stop hunting for workspace IDs by using list_workspaces to see everything in one view.
- Handle incident response faster by using force_unlock_workspace to clear stuck runs.
- Speed up deployments by using apply_variable_set_to_workspace to inject configuration data.
- Simplify governance by using create_team and add_team_user to manage access without manual tickets.
- Get instant data by using get_state_version_outputs to pull values directly into your workflow.
- Automate policy updates by using upload_policy_code to keep your security standards current.

## How It Works

The bottom line is you get a conversational interface for your entire Terraform Cloud infrastructure.

1. Connect your Terraform Cloud User or Team API Token to the Connector.
2. Ask your agent to perform a task like listing workspaces or triggering a run.
3. Review the results and give follow-up instructions to your agent.

## Frequently Asked Questions

**What can I do with the Terraform Cloud (HCP) MCP?**
You can manage your entire infrastructure lifecycle through a chat interface. This includes creating organizations, managing workspaces, triggering plans, and inspecting state outputs using your AI agent.

**Can I manage my Terraform Cloud workspaces using an AI agent?**
Yes, this Connector connects your Terraform Cloud account to your agent. You can perform actions like locking workspaces, listing environments, and applying variable sets using natural language commands.

**How do I use the Terraform Cloud (HCP) MCP for team management?**
You can use the agent to handle team-based permissions. Simply ask it to create a new team, add users to that team, or remove access for specific members to keep your governance up to date.

**Can this Connector help me with Terraform Cloud state outputs?**
Absolutely. You can ask your agent to retrieve specific output values from any workspace state version, which is helpful for getting IDs, IP addresses, or other configuration data quickly.

**Is the Terraform Cloud (HCP) MCP good for SRE teams?**
It is excellent for SREs because it provides a fast way to handle incident response tasks, such as force-unlocking a stuck workspace or quickly checking the status of a failed infrastructure run.

**How does the Terraform Cloud (HCP) MCP handle workspace locks?**
The Connector allows your agent to lock or unlock workspaces. If a run gets stuck or you need to perform maintenance, you can just ask the agent to release the lock so your team can continue working.

**Can I trigger a new infrastructure deployment (run) using this server?**
Yes. You can use the `create_run` tool by providing the Workspace ID. You can also subsequently use `apply_run` or `discard_run` to manage the lifecycle of that specific execution.

**How do I see the output variables from my last successful Terraform apply?**
Use the `get_state_version_outputs` tool with the Workspace ID. It will retrieve all calculated outputs from the current state, such as IP addresses, DNS names, or resource IDs.

**Is it possible to list all workspaces across my organization?**
Absolutely. Use the `list_workspaces` tool and provide your organization name. You can also filter the results by name or tags using optional parameters.