Skip to content

Menu

Terraform MCP Server logo

Terraform MCP Server

Published · Updated

At a glance

Watch out for
Registry help is only as good as the docs: it improves arguments and syntax, not architecture decisions.

HashiCorp's Terraform MCP Server connects an agent to two things: the public Terraform Registry, and HCP Terraform or Terraform Enterprise. The first is the reason most people install it. When a model writes Terraform, it often guesses at resource arguments from old provider versions. With this server it can look up the current provider documentation, module inputs and Sentinel policies before it writes a line of HCL.

The second half is about your own workspaces. With an HCP Terraform or Terraform Enterprise token, the agent can list workspaces, read their state and variables, and create runs. HashiCorp keeps the riskiest actions off by default: applying, discarding or cancelling runs, deleting workspaces, projects or teams, and auto-approved or destroy runs need ENABLE_TF_OPERATIONS set to true. That is the right default for anything that can change real infrastructure.

The server is written in Go and distributed as a binary and the Docker image hashicorp/terraform-mcp-server. HashiCorp also hosts a remote version at mcp.terraform.io, and the README includes a long section on running it centrally for a team, with token passthrough and an organisation allowlist. Its security note is blunt: depending on the query, Terraform data may be exposed to the client and the model, so do not use it with clients or models you do not trust.

How it connects

Your AI app

An assistant or agent that supports MCP

Terraform MCP Server

Runs as

  • Docker
  • Remote (HTTP)

Gives the agent

  • Registry lookups
  • Private registry
  • Workspace operations
  • Approval-gated tools
  • Tool filtering

Terraform

Signs in with

  • Token
Your AI app talks to Terraform MCP Server over the Model Context Protocol, and the server carries out the work. Built from the setup and capability sections on this page.

What it can do

Registry lookups
The registry toolset searches providers (search_providers), fetches provider details (get_provider_details), and finds modules and policies, so generated HCL matches the current provider version.
Private registry
The registry-private toolset searches modules and providers published in your own HCP Terraform or Terraform Enterprise organisation.
Workspace operations
The terraform toolset works with HCP Terraform and Terraform Enterprise workspaces, for example list_workspaces, variables and runs. It needs TFE_TOKEN, plus TFE_ADDRESS for Terraform Enterprise.
Approval-gated tools
Destructive actions such as action_run (apply, discard, cancel), delete_workspace_safely and the tool that force-releases a workspace lock need ENABLE_TF_OPERATIONS=true. Other write tools, such as create_workspace and create_run, work with just a token.
Tool filtering
--toolsets picks groups (registry, registry-private, terraform, all) and --tools picks individual tools. The two flags cannot be combined.

Setting it up

The quickest local setup uses Docker. In Claude Code: claude mcp add terraform -s user -t stdio -- docker run -i --rm hashicorp/terraform-mcp-server. In Codex: codex mcp add terraform -- docker run -i --rm hashicorp/terraform-mcp-server. That gives you the public registry tools with no credentials. For your own workspaces, add -e TFE_TOKEN (and -e TFE_ADDRESS for Terraform Enterprise) to the Docker command and enable the terraform toolset with --toolsets=registry,terraform. To use HashiCorp's hosted server instead, add an HTTP server at https://mcp.terraform.io/mcp with your token in an Authorization: Bearer header. For a shared deployment, run the streamable-http mode and restrict it with --organization-allowlist.

Where each client keeps its MCP config file, and the JSON it expects (cheat sheet)

Where it helps

  • Writing a new resource block with arguments checked against the current AWS, Azure or Google provider docs
  • Finding a well-maintained registry module and its required inputs instead of writing one from scratch
  • Asking which HCP Terraform workspaces exist for a project and what variables they use
  • Reviewing provider upgrade notes before bumping a version constraint

Limitations and things to watch

  • Registry help is only as good as the docs: it improves arguments and syntax, not architecture decisions.
  • Workspace data, including variables and state details, is passed to the model. HashiCorp warns against untrusted clients or models.
  • Write operations are off by default; turning on ENABLE_TF_OPERATIONS lets the agent apply runs and delete workspaces against real infrastructure.
  • The server does not run terraform plan or apply on your local working directory. Local Terraform still happens in your shell or CI.

Sources

Written from the project's own documentation, checked November 2026.

How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…