Terraform Cloud MCP server

Integrates with Terraform Cloud API to enable natural language management of infrastructure through workspace and run operations including creation, updates, planning, and application.
Back to servers
Setup instructions
Provider
John Reilly Pospos
Release date
Mar 17, 2025
Language
Python
Stats
17 stars

The Terraform Cloud MCP Server provides a Model Context Protocol server for seamlessly integrating AI assistants with Terraform Cloud APIs. This allows you to manage your infrastructure through natural language conversation with support for various MCP-compatible platforms like Claude, Claude Code CLI, and more.

Installation

Prerequisites

  • Python 3.12+
  • Terraform Cloud API token
  • uv package manager (recommended) or pip

Environment Variables

TFC_TOKEN - Terraform Cloud API token (required)
TFC_ADDRESS - Terraform Cloud/Enterprise address (optional, defaults to https://app.terraform.io)
ENABLE_DELETE_TOOLS - Enable/disable destructive operations (optional, defaults to false)
ENABLE_RAW_RESPONSE - Return raw vs filtered responses (optional, defaults to false)

Setting Up

# Clone the repository
git clone https://github.com/severity1/terraform-cloud-mcp.git
cd terraform-cloud-mcp

# Create virtual environment and activate it
uv venv
source .venv/bin/activate

# Install package
uv pip install .

Integration with Claude Tools

Claude Code CLI

# Add to Claude Code with your Terraform Cloud token
claude mcp add -e TFC_TOKEN=YOUR_TF_TOKEN -e ENABLE_DELETE_TOOLS=false -s user terraform-cloud-mcp -- "terraform-cloud-mcp"

# For self-hosted Terraform Enterprise:
# claude mcp add -e TFC_TOKEN=YOUR_TF_TOKEN -e TFC_ADDRESS=https://terraform.example.com -s user terraform-cloud-mcp -- "terraform-cloud-mcp"

# To enable delete operations (use with caution):
# claude mcp add -e TFC_TOKEN=YOUR_TF_TOKEN -e ENABLE_DELETE_TOOLS=true -s user terraform-cloud-mcp -- "terraform-cloud-mcp"

Claude Desktop

Create a configuration file at:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "terraform-cloud-mcp": {
      "command": "/path/to/uv",
      "args": [
        "--directory",
        "/path/to/your/terraform-cloud-mcp",
        "run",
        "terraform-cloud-mcp"
      ],
      "env": {
        "TFC_TOKEN": "my token...",
        "TFC_ADDRESS": "https://app.terraform.io",
        "ENABLE_DELETE_TOOLS": "false"
      }
    }
  }
}

Available Tools

Account Management

  • get_account_details() - Get authenticated user or service account information

Workspace Management

list_workspaces(organization, page_number, page_size, search)
get_workspace_details(workspace_id, organization, workspace_name)
create_workspace(organization, name, params)
update_workspace(organization, workspace_name, params)
lock_workspace(workspace_id, reason)
unlock_workspace(workspace_id)
force_unlock_workspace(workspace_id)

When ENABLE_DELETE_TOOLS=true:

delete_workspace(organization, workspace_name)
safe_delete_workspace(organization, workspace_name)

Run Management

create_run(workspace_id, params)
list_runs_in_workspace(workspace_id, ...)
list_runs_in_organization(organization, ...)
get_run_details(run_id)
apply_run(run_id, comment)
discard_run(run_id, comment)
cancel_run(run_id, comment)
force_cancel_run(run_id, comment)
force_execute_run(run_id)

Plan Management

get_plan_details(plan_id)
get_plan_json_output(plan_id)
get_run_plan_json_output(run_id)
get_plan_logs(plan_id)

Apply Management

get_apply_details(apply_id)
get_errored_state(apply_id)
get_apply_logs(apply_id)

Project Management

create_project(organization, name, params)
update_project(project_id, params)
list_projects(organization, ...)
get_project_details(project_id)
list_project_tag_bindings(project_id)
add_update_project_tag_bindings(project_id, tag_bindings)
move_workspaces_to_project(project_id, workspace_ids)

When ENABLE_DELETE_TOOLS=true:

delete_project(project_id)

Organization Management

get_organization_details(organization)
get_organization_entitlements(organization)
list_organizations(page_number, page_size, query, query_email, query_name)
create_organization(name, email, params)
update_organization(organization, params)

When ENABLE_DELETE_TOOLS=true:

delete_organization(organization)

Cost Estimation

get_cost_estimate_details(cost_estimate_id)

Assessment Results

get_assessment_result_details(assessment_result_id)
get_assessment_json_output(assessment_result_id)
get_assessment_json_schema(assessment_result_id)
get_assessment_log_output(assessment_result_id)

State Version Management

list_state_versions(organization, workspace_name, page_number, page_size, filter_status)
get_current_state_version(workspace_id)
get_state_version(state_version_id)
create_state_version(workspace_id, serial, md5, params)
download_state_file(state_version_id, json_format)

State Version Outputs

list_state_version_outputs(state_version_id, page_number, page_size)
get_state_version_output(state_version_output_id)

Variables Management

Workspace Variables

list_workspace_variables(workspace_id)
create_workspace_variable(workspace_id, key, category, params)
update_workspace_variable(workspace_id, variable_id, params)

When ENABLE_DELETE_TOOLS=true:

delete_workspace_variable(workspace_id, variable_id)

Variable Sets

list_variable_sets(organization, page_number, page_size)
get_variable_set(varset_id)
create_variable_set(organization, name, params)
update_variable_set(varset_id, params)
assign_variable_set_to_workspaces(varset_id, workspace_ids)
unassign_variable_set_from_workspaces(varset_id, workspace_ids)
assign_variable_set_to_projects(varset_id, project_ids)
unassign_variable_set_from_projects(varset_id, project_ids)

When ENABLE_DELETE_TOOLS=true:

delete_variable_set(varset_id)

Variable Set Variables

list_variables_in_variable_set(varset_id)
create_variable_in_variable_set(varset_id, key, category, params)
update_variable_in_variable_set(varset_id, var_id, params)

When ENABLE_DELETE_TOOLS=true:

delete_variable_from_variable_set(varset_id, var_id)

Troubleshooting

  1. Check server logs (debug logging is enabled by default)
  2. Use the MCP Inspector (http://localhost:5173) for debugging
  3. Verify your Terraform Cloud API token has sufficient permissions
  4. Ensure environment variables are correctly set
  5. For destructive operations, confirm ENABLE_DELETE_TOOLS=true is set

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "terraform-cloud-mcp" '{"command":"terraform-cloud-mcp","env":{"TFC_TOKEN":"${TFC_TOKEN}"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "terraform-cloud-mcp": {
            "command": "terraform-cloud-mcp",
            "env": {
                "TFC_TOKEN": "${TFC_TOKEN}"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "terraform-cloud-mcp": {
            "command": "terraform-cloud-mcp",
            "env": {
                "TFC_TOKEN": "${TFC_TOKEN}"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later