Terraform Cloud MCP Server


What is this?

The Terraform Cloud MCP Server is an agentic, AI-driven bridge between the Model Context Protocol ecosystem and HashiCorp’s Terraform Cloud. It packages the MCP server interface in @modelcontextprotocol/server-terraform-cloud, allowing LLMs and autonomous agents to plan, apply, and manage Terraform Cloud resources using natural-language prompts.

Under the hood, it exposes Terraform Cloud’s GraphQL API via standard MCP resource and tool calls. This design not only accelerates DevOps workflows by reducing imperative code but also enforces compliance guardrails in real time through Sentinel policy integration and audit-grade logging.

Quick Start

Install the server using npm:

npm install @modelcontextprotocol/server-terraform-cloud

Then add it to your MCP client configuration:

{
  "mcpServers": {
    "terraform-cloud": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-terraform-cloud"],
      "env": {
        "API_KEY": "your-api-key-here"
      }
    }
  }
}

Key Features

Feature 1: Natural-language provisioning of infrastructure enabling you to plan and apply Terraform Cloud runs by simple prompts or function calls.

Feature 2: Sentinel policy integration to enforce compliance guardrails automatically before execution.

Feature 3: Real-time run status streaming and audit-compliant logging for full visibility into every operation.

Example Usage

Imagine you need to spin up a new VPC workspace in Terraform Cloud using an LLM agent:

// Example code
const result = await client.callTool({
  name: "createWorkspace",
  arguments: { name: "my-vpc" }
});

This code calls the createWorkspace tool to provision a workspace named “my-vpc” and returns the workspace details for further planning and execution.

Configuration

The server accepts the following environment variables:

API_KEY – Terraform Cloud API token used to authenticate requests.

SETTING_1 (optional) – Enable WebSocket subscriptions by setting to true.

Available Tools/Resources

createWorkspace: Create or configure a Terraform Cloud workspace through MCP.

planRun: Generate and plan infrastructure changes before applying.

Who Should Use This?

This server is perfect for:

Use case 1: DevOps teams looking to accelerate infrastructure workflows with AI-driven prompts.

Use case 2: Enterprises needing audit-compliant automation and policy enforcement at scale.

Use case 3: Developers building multi-agent or CI/CD pipelines that integrate Terraform Cloud programmatically.

Conclusion

The Terraform Cloud MCP Server revolutionizes how you control Terraform Cloud by injecting AI-driven, natural-language workflows into every stage of your infrastructure lifecycle. Try it out to streamline provisioning, enforce compliance, and enhance visibility across your teams.

Check out the GitHub repository for more information and to contribute.