Terraform MCP Server

HashiCorp Terraform MCP server for Infrastructure as Code workflows, including provider and module discovery through the Terraform Registry.

Remote serverstreamable-httpGo

What is the Terraform MCP server?

The terraform mcp server connects Terraform to AI assistants that speak the Model Context Protocol. HashiCorp Terraform MCP server for Infrastructure as Code workflows, including provider and module discovery through the Terraform Registry.

What Terraform does

The Terraform MCP Server is a Model Context Protocol (MCP) server that provides seamless integration with Terraform Registry APIs, enabling advanced automation and interaction capabilities for Infrastructure as Code (IaC) development.

Key capabilities

  • Dual Transport Support — Both Stdio and StreamableHTTP transports with configurable endpoints
  • Terraform Registry Integration — Direct integration with public Terraform Registry APIs for providers, modules, and policies
  • HCP Terraform & Terraform Enterprise Support — Full workspace management, organization/project listing, and private registry access
  • Workspace Operations — Create, update, delete workspaces with support for variables, tags, and run management
  • OTel metrics for monitoring tool usage — Integration with open telemetry meters to track tool-call volume, latency and failures in Streamable HTTP mode. Also exposes default http server metrics when this feature is enabled

Installing the terraform mcp server

The server is distributed via a container image as hashicorp/terraform-mcp-server, so most clients can run it without a manual build step. Add it to your MCP client's configuration and restart the client to pick it up — the copy-paste configs for Claude Desktop, Claude Code and Cursor are on this page.

Configuration

Before the server will start you need to supply 5 environment variables: TFE_TOKEN, MCP_SESSION_MODE, TF_MCP_SHARED_SECRET, TRANSPORT_HOST, MCP_REDIRECT_ROOT_URL. Keep credentials in your client's env block or a secrets manager rather than committing them.

Requirements

  1. Ensure Docker is installed and running to use the server in a containerized environment. 1. Install an AI assistant that supports the Model Context Protocol (MCP).

Good to know

  • This is a hosted server — you point your client at an endpoint rather than running a local process.
  • Written in Go.
  • Every MCP client asks for confirmation before a tool call by default — keep that on while you learn what the terraform mcp server does with your data.
  • Listed here as part of the SyncDev MCP directory; each entry is reviewed before it goes live.

How to install the Terraform MCP server

{
  "mcpServers": {
    "terraform": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e", "TFE_ADDRESS=<<PASTE_TFE_ADDRESS_HERE>>",
        "-e", "TFE_TOKEN=<<PASTE_TFE_TOKEN_HERE>>",
        "hashicorp/terraform-mcp-server:1.1.0"
      ]
    }
  }
}

Configuration as documented by the project. Restart the client after saving.

Configuration

  1. Ensure Docker is installed and running to use the server in a containerized environment. 1. Install an AI assistant that supports the Model Context Protocol (MCP).
VariableDescriptionRequired
TFE_TOKENCredential the server authenticates with.Yes
MCP_SESSION_MODEConfiguration value read at startup.Optional
TF_MCP_SHARED_SECRETCredential the server authenticates with.Yes
TRANSPORT_HOSTEndpoint or connection string the server talks to.Optional
MCP_REDIRECT_ROOT_URLEndpoint or connection string the server talks to.Yes

Frequently asked questions

It connects Terraform to MCP-compatible AI assistants such as Claude and Cursor. Instead of copying data back and forth by hand, the assistant works with Terraform directly.