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
Provider
John Reilly Pospos
Release date
Mar 17, 2025
Language
Python
Stats
10 stars

This MCP server integrates AI assistants with the Terraform Cloud API, allowing you to manage your infrastructure through natural conversation. It works with any MCP-supporting platform including Claude, Claude Code CLI, Claude Desktop, Cursor, and Copilot Studio.

Installation

Prerequisites

  • Python 3.12+
  • MCP (includes FastMCP and development tools)
  • uv package manager (recommended) or pip
  • Terraform Cloud API token

Setup Instructions

# 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 .

Configuration

Adding to Claude Code CLI

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

Adding to Claude Desktop

Create a configuration file in:

  • 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": "your_terraform_cloud_token"
      }
    }
  }
}

Other MCP-Compatible Platforms

For platforms like Cursor, Copilot Studio, or Glama:

  1. Specify the server path or command
  2. Configure the Terraform Cloud API token as an environment variable
  3. Set up auto-start capabilities as needed for your platform

Available Tools

Account Management

  • Get authenticated user account details

Workspace Management

Listing and Information

  • List and search workspaces
  • Get detailed workspace information

Creation and Updates

  • Create new workspaces
  • Update existing workspace configurations

Access Control

  • Lock workspaces to prevent runs
  • Unlock workspaces to allow operations
  • Force unlock workspaces when needed

Lifecycle Management

  • Delete workspaces
  • Safe delete workspaces (only if not managing resources)

Run Management

  • Create and queue Terraform runs
  • List and filter runs by workspace or organization
  • Get detailed run information
  • Apply, discard, or cancel runs
  • Force cancel runs immediately
  • Force execute pending runs

Plan Management

  • Get plan details
  • Retrieve JSON execution plans with redirect handling

Apply Management

  • Get apply details
  • Recover from failed state uploads

Project Management

  • Create and update projects
  • List and filter projects
  • Get project details
  • Delete projects
  • Manage project tag bindings
  • Move workspaces between projects

Organization Management

  • Get organization details and entitlements
  • List and filter organizations
  • Create and update organizations
  • Delete organizations

Troubleshooting

If you encounter issues:

  1. Check server logs (debug logging is enabled by default)
  2. Use the MCP Inspector (http://localhost:5173) for debugging
  3. Verify your TFC_TOKEN is valid and has appropriate permissions
  4. Ensure proper connectivity to Terraform Cloud API endpoints

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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