Terraform — Claude Code MCP server: registry and HCP Terraform
Connects your AI assistant to Terraform Registry and HCP Terraform: provider and module lookup, workspace management.
claude mcp add terraform -- docker run -i --rm docker.io/hashicorp/terraform-mcp-server:1.4.1What Terraform does
The server wires an assistant into the public Terraform Registry and the HCP Terraform and Terraform Enterprise APIs. From chat you can search providers, modules and policies, and manage workspaces: create, update, delete, set variables and tags, start runs. Private registry access for an organization is included.
It runs in a container, so Docker has to be installed and running. Stdio is the default transport; streamable-http mode lets you set host, port and the /mcp endpoint path. In HTTP mode the HCP Terraform address comes only from TFE_ADDRESS — a client cannot pass it through a header. Private registry and workspace work needs a TFE_TOKEN.
Streamable-http mode exposes OpenTelemetry metrics: tool-call volume, latency and failures. The README warns that depending on the query the server may hand Terraform data to the MCP client and the model, so untrusted clients are a bad fit.
What it helps with
- find the current version of a provider in the registry
- assemble a module from existing blocks instead of searching by hand
- create a workspace with variables and tags
- start a run and check its status
- pull policies from an organization's private registry
Example prompts for the agent
- Find the AWS provider in the Terraform Registry and show its latest version
- Create a workspace
stagingin the organization and add aregionvariable - Which registry modules fit a VPC on GCP?
How to install Terraform
Platform CLI
claude mcp add terraform -- docker run -i --rm docker.io/hashicorp/terraform-mcp-server:1.4.1Platform CLI
codex mcp add terraform -- docker run -i --rm docker.io/hashicorp/terraform-mcp-server:1.4.1Config file
{
"mcpServers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"docker.io/hashicorp/terraform-mcp-server:1.4.1"
]
}
}
}Config file
{
"servers": {
"terraform": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"docker.io/hashicorp/terraform-mcp-server:1.4.1"
]
}
}
}Platform CLI
gemini mcp add terraform docker run -i --rm docker.io/hashicorp/terraform-mcp-server:1.4.1Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Terraform
How do I install the Terraform MCP server in Claude Code?
One command: claude mcp add terraform -- docker run -i --rm docker.io/hashicorp/terraform-mcp-server:1.4.1. Docker must be installed and running.
What does the Terraform MCP server do?
It gives an assistant access to Terraform Registry and the HCP Terraform API: provider, module and policy lookup, plus workspace, variable, tag and run management.
What do I need for HCP Terraform and the private registry?
A token in TFE_TOKEN. The address goes in TFE_ADDRESS with the protocol, for example https://app.terraform.io.