Terraform MCP Server with Claude Code - Install with Docker or the Binary, the 9 Registry Tools, a Provider Docs Lookup, HCP Terraform with a Token, and What It Cannot Do

TL;DR

  • The Terraform MCP server is a small program that an AI client starts and asks for Terraform facts. Version 1.4.1 is a 27.5 MB Docker image (hashicorp/terraform-mcp-server) or a single binary from releases.hashicorp.com.
  • One command registers it in Claude Code: claude mcp add terraform -- docker run -i --rm hashicorp/terraform-mcp-server:latest. claude mcp list then shows ✔ Connected.
  • Without a token it has 9 tools, all read-only against the public registry: provider docs, provider versions and capabilities, module search and details, policies. That is the part that stops an agent from writing arguments that no longer exist.
  • With TFE_TOKEN set it has 56 tools for HCP Terraform and Terraform Enterprise: workspaces, variables, runs, state versions, teams. The destructive ones stay off until ENABLE_TF_OPERATIONS=true.
  • It does not run Terraform on your machine. None of the 56 tools executes terraform plan or apply locally; a run is created in an HCP Terraform workspace through the API.
  • The three failures you will meet in claude mcp list: ⏸ Pending approval (project scope, not approved yet), ENOENT ... posix_spawn (the binary path is wrong) and CONNECTION_CLOSED (the Docker image name is wrong).
  • Looking for plain Terraform instead? Start with how Terraform modules work; if you want another MCP server built end to end, see an MCP server for Claude on Bedrock.

An agent that writes Terraform from memory writes the provider it was trained on. The AWS provider alone is at 6.74.0 today with 1,765 resources, and argument names move between major versions. The Terraform MCP server is HashiCorp's answer: it "gives AI models real-time access to Terraform provider docs, modules, policies", and to HCP Terraform and Terraform Enterprise workspaces. I ran everything below on 2026-11-30 on Ubuntu 24.04 with Docker 28.0.4, terraform-mcp-server 1.4.1 and Claude Code 2.1.332. For the tool lists and tool calls I did not use a chat session at all: I spoke the protocol to the server directly with a short Python client, so what you see is what the server answers, not what a model made of it.

Table of Content

  1. What the server is
  2. Install it - Docker image or binary
  3. The nine tools you get without a token
  4. A provider docs lookup, step by step
  5. Register it in Claude Code
  6. HCP Terraform - what a token adds
  7. What it can and cannot do
  8. What broke when I ran this
  9. Conclusion

1. What the server is

Claude Code starts the Terraform MCP server over stdio or reaches it over HTTP; registry tools call registry.terraform.io, workspace tools call the HCP Terraform API

MCP, the Model Context Protocol, is the plug between an AI client and a tool. The client (Claude Code here) starts a server process, asks it which tools it has, and calls them with JSON arguments when the model decides it needs one. The Terraform MCP server is such a process. The deployment page lists three ways to have one:

DeploymentWho runs itInstallNotes
Localyou, on your machineDocker, binary or sourcewhat this post uses; talks stdio to the client
Self-hostedyou, in an environment you manageDocker, binary or sourcethe same binary in streamable-http mode behind your own TLS
RemoteHashiCorpnonein beta; "requires an HCP Terraform user or team API token for every request"; Terraform Enterprise not supported

The project's README carries one sentence I would put on the wall: "Do not use the MCP server with untrusted MCP clients or LLMs." With a token the server acts on your workspaces with that token's rights.

2. Install it - Docker image or binary

The image is small enough to pull on demand:

 1$ docker pull hashicorp/terraform-mcp-server:latest
 2latest: Pulling from hashicorp/terraform-mcp-server
 37832fb5bcabb: Pulling fs layer
 4b9aa5407e31b: Pulling fs layer
 5b9aa5407e31b: Download complete
 67832fb5bcabb: Verifying Checksum
 77832fb5bcabb: Download complete
 87832fb5bcabb: Pull complete
 9b9aa5407e31b: Pull complete
10Digest: sha256:11dd418bba6003dd5777e9d0979b68de59929a155b355f338f407947e00e9d80
11Status: Downloaded newer image for hashicorp/terraform-mcp-server:latest
12docker.io/hashicorp/terraform-mcp-server:latest
13
14$ docker run --rm hashicorp/terraform-mcp-server:latest --version
15Terraform MCP Server
16Version: 1.4.1

docker image inspect reports 27,495,177 bytes and the entrypoint /bin/terraform-mcp-server. If you would rather not have Docker in the loop, the same program is a zip on releases.hashicorp.com, with a checksum file next to it:

 1$ curl -fsSLO https://releases.hashicorp.com/terraform-mcp-server/1.4.1/terraform-mcp-server_1.4.1_linux_amd64.zip
 2$ curl -fsSLO https://releases.hashicorp.com/terraform-mcp-server/1.4.1/terraform-mcp-server_1.4.1_SHA256SUMS
 3$ grep linux_amd64.zip terraform-mcp-server_1.4.1_SHA256SUMS | sha256sum -c
 4terraform-mcp-server_1.4.1_linux_amd64.zip: OK
 5$ unzip -o terraform-mcp-server_1.4.1_linux_amd64.zip
 6Archive:  terraform-mcp-server_1.4.1_linux_amd64.zip
 7  inflating: LICENSE.txt             
 8  inflating: terraform-mcp-server    
 9$ ./terraform-mcp-server --version
10Terraform MCP Server
11Version: 1.4.1

The binary has two modes, stdio (the client starts it and talks over standard input and output) and streamable-http (it listens on a port). The image runs stdio when you give it no command.

3. The nine tools you get without a token

To see what an agent is offered, I sent the three messages every MCP client sends: initialize, notifications/initialized, tools/list. The first two lines below are my client's summary of the answers, the third is the server's own log on standard error:

1initialize -> {"protocolVersion": "2025-06-18", "serverInfo": {"name": "terraform-mcp-server", "version": "1.4.1"}, "capabilities": ["elicitation", "resources", "tools"]}
2tools/list -> 9 tool(s)
3time="2026-11-30T03:44:57Z" level=warning msg="Session has no valid TFE client - TFE tools will not be available"
ToolRequired argumentsWhat it returns
search_provider_docsprovider_name, provider_namespace, service_slug, provider_document_typea list of matching documents, each with a providerDocID
get_provider_detailsprovider_doc_idthe full documentation page for that id
get_provider_capabilitiesnamespace, namewhat a provider offers: resources, data sources, functions, actions, guides
get_latest_provider_versionnamespace, nameone version string
search_modulesmodule_querymatching registry modules with module_id, downloads and publish date
get_module_detailsmodule_idinputs, outputs and documentation of that module version
get_latest_module_versionmodule_publisher, module_name, module_providerone version string
search_policiespolicy_querymatching policy sets in the registry
get_policy_detailsterraform_policy_idthe documentation of one policy

The server also hands the client a block of instructions on connect. Its first rule is the reason the whole thing exists: "BEFORE generating any Terraform code: Query registries for latest provider/module versions and styling guidelines."

You can narrow what a client sees. --toolsets=registry gave the same nine in my run and is the documented way to keep the workspace tools of section 6 away from a client; --tools=search_provider_docs,get_provider_details left exactly 2 tools. The two flags exclude each other; section 8 has the error.

4. A provider docs lookup, step by step

The documentation tools work as a pair, and the order matters. First the search, with the provider, a service slug and the kind of document:

 1tools/call search_provider_docs {"provider_name": "aws", "provider_namespace": "hashicorp", "service_slug": "vpc", "provider_document_type": "resources", "provider_version": "latest"}
 2  isError: False
 3  text (12942 chars):
 4    Available Documentation (top matches) for resources in Terraform provider hashicorp/aws version: 6.74.0
 5    Each result includes:
 6    - providerDocID: tfprovider-compatible identifier
 7    - Title: Service or resource name
 8    - Category: Type of document
 9    - Description: Brief summary of the document
10    For best results, select libraries based on the service_slug match and category of information requested.
11    ---
12    - providerDocID: 14985969
13    - Title: apigatewayv2_vpc_link
14    - Category: resources
15    - Description: Manages an Amazon API Gateway Version 2 VPC Link.
16    ---
17    - providerDocID: 14985956
18    - Title: api_gateway_vpc_link
19    - Category: resources
20    - Description: Provides an API Gateway VPC Link.

The answer is 12.9 KB of candidates, everything with "vpc" in its name, roughly in alphabetical order; the plain vpc resource is far down the list with id 14987542. Then the page itself:

 1tools/call get_provider_details {"provider_doc_id": "14987542"}
 2  isError: False
 3  text (8386 chars):
 4    ---
 5    subcategory: "VPC (Virtual Private Cloud)"
 6    layout: "aws"
 7    page_title: "AWS: aws_vpc"
 8    description: |-
 9      Provides a VPC resource.
10    ---
11    # Resource: aws_vpc
12    Provides a VPC resource.

That is the registry's Markdown source for aws_vpc at provider version 6.74.0, 8.4 KB of it, with the example usage and the argument reference. An agent that reads this before writing a resource "aws_vpc" block is working from today's arguments. (For which block to put in cidr_block, see how to choose a VPC CIDR.)

The version and module tools are one call each:

 1tools/call get_latest_provider_version {"namespace": "hashicorp", "name": "aws"}
 2  text (6 chars):
 3    6.74.0
 4tools/call get_latest_module_version {"module_publisher": "terraform-aws-modules", "module_name": "vpc", "module_provider": "aws"}
 5  text (5 chars):
 6    6.9.0
 7tools/call search_modules {"module_query": "vpc"}
 8  text (4464 chars):
 9    - module_id: terraform-aws-modules/vpc/aws/6.9.0
10    - Name: vpc
11    - Description: Terraform module to create AWS VPC resources 🇺🇦
12    - Downloads: 237138717
13    - Verified: false
14    - Published: 2026-11-25 14:53:24.924151 +0000 UTC

(I cut the isError: False lines and the result header from that block, and kept only the first of the modules.) The server's log shows what each call really is, a plain GET against the registry API, for example GET https://registry.terraform.io/v1/modules/terraform-aws-modules/vpc/aws. By the log's timestamps the three calls finished inside the same second, so under 1 s for three registry lookups. Nothing here needs an account.

5. Register it in Claude Code

claude mcp add takes a name, then --, then the command that starts the server. The Claude Code MCP documentation describes three scopes; the default is local, which is private to you and to the current project:

 1$ claude mcp add terraform -- docker run -i --rm hashicorp/terraform-mcp-server:latest
 2Added stdio MCP server terraform with command: docker run -i --rm hashicorp/terraform-mcp-server:latest to local config
 3File modified: /home/runner/.claude.json [project: /tmp/tfmcp/proj2]
 4
 5$ claude mcp add terraform-bin -- /tmp/tfmcp/terraform-mcp-server stdio
 6Added stdio MCP server terraform-bin with command: /tmp/tfmcp/terraform-mcp-server stdio to local config
 7File modified: /home/runner/.claude.json [project: /tmp/tfmcp/proj2]
 8
 9$ claude mcp get terraform
10terraform:
11  Scope: Local config (private to you in this project)
12  Status: ✔ Connected
13  Type: stdio
14  Command: docker
15  Args: run -i --rm hashicorp/terraform-mcp-server:latest
16  Environment:
17
18To remove this server, run: claude mcp remove terraform -s local

claude mcp list starts every configured server and reports its health, which makes it the first thing to run when a tool does not show up in a session. Inside a session the /mcp command shows the same status.

Sharing it with the team is --scope project. That writes a .mcp.json into the repository:

 1$ claude mcp add --scope project terraform -- docker run -i --rm hashicorp/terraform-mcp-server:latest
 2Added stdio MCP server terraform with command: docker run -i --rm hashicorp/terraform-mcp-server:latest to project config
 3File modified: /tmp/tfmcp/proj/.mcp.json
 4
 5$ cat .mcp.json
 6{
 7  "mcpServers": {
 8    "terraform": {
 9      "type": "stdio",
10      "command": "docker",
11      "args": [
12        "run",
13        "-i",
14        "--rm",
15        "hashicorp/terraform-mcp-server:latest"
16      ],
17      "env": {}
18    }
19  }
20}
21
22$ claude mcp list
23Checking MCP server health…
24terraform: docker run -i --rm hashicorp/terraform-mcp-server:latest - ⏸ Pending approval (run `claude` to approve)

Pending approval is not an error. A .mcp.json arrives with a git pull, and it names a command to execute, so Claude Code asks for approval before it uses a project-scoped server. Start claude in the repository and approve it.

A server that is already running on a port is added with --transport http. I started the binary with streamable-http --transport-port 8080 and pointed Claude Code at it:

 1$ claude mcp add --transport http terraform-http http://127.0.0.1:8080/mcp
 2Added HTTP MCP server terraform-http with URL: http://127.0.0.1:8080/mcp to local config
 3File modified: /home/runner/.claude.json [project: /tmp/tfmcp/proj2]
 4
 5$ curl -s -i -m 10 http://127.0.0.1:8080/health
 6HTTP/1.1 200 OK
 7Content-Type: application/json
 8Date: Mon, 30 Nov 2026 03:45:03 GMT
 9Content-Length: 114
10
11{"status":"ok","service":"terraform-mcp-server","transport":"streamable-http","endpoint":"/mcp","version":"1.4.1"}

The server's own startup log is worth reading before you put this on a network: it binds 127.0.0.1 by default and prints "TLS is disabled on StreamableHTTP server; this is not recommended for production" and "No allowed origins configured in strict mode. All cross-origin requests will be rejected."

6. HCP Terraform - what a token adds

Set TFE_TOKEN (and TFE_ADDRESS for Terraform Enterprise) in the server's environment and the tool list grows. The Claude Code documentation gives the form claude mcp add --env KEY=value <name> -- <command>; for the Docker image the variable also has to reach the container, which is -e TFE_TOKEN on the docker run line. I did not run that with a real token. Whatever form you use, keep the token out of a committed .mcp.json.

I do not have an HCP Terraform organisation to show here, so I did the one honest thing available: I started the server with a token that is not real and looked at what changes.

1tools/list -> 56 tool(s)
2tools/call list_terraform_orgs {}
3  isError: True
4  text (52 chars):
5    failed to list Terraform organizations: unauthorized

56 tools instead of 9. The 47 new ones, by what they touch:

AreaTools (from the real list)
Identitywhoami, get_token_permissions, list_terraform_orgs, list_terraform_projects, get_project
Workspaceslist_workspaces, get_workspace_details, create_workspace, update_workspace, create_no_code_workspace, read_workspace_tags, create_workspace_tags
Variableslist_workspace_variables, create_workspace_variable, update_workspace_variable, list_variable_sets, create_variable_set, create_variable_in_variable_set, delete_variable_in_variable_set, attach_variable_set_to_workspaces, detach_variable_set_from_workspaces
Runslist_runs, create_run, get_run_details, get_run_comments, get_plan_details, get_plan_logs, get_plan_json_output, get_apply_details, get_apply_logs
State and stackslist_state_versions, get_state_version, list_stacks, get_stack_details
Teams and policylist_teams, get_team, create_team, add_team_member, grant_team_access, create_project, list_workspace_policy_sets, attach_policy_set_to_workspaces, get_sentinel_mock
Private registrysearch_private_modules, get_private_module_details, search_private_providers, get_private_provider_details

Two things are not in that list, and that is deliberate. The reference names the destructive tools, among them action_run ("Can apply or destroy infrastructure") and delete_workspace_safely, and says: "These tools are disabled by default and require setting ENABLE_TF_OPERATIONS=true". The same page lists the auto_approve and destroy options of create_run as gated too. So without that variable an agent can start a run and read its plan, and the apply is confirmed in HCP Terraform, unless the workspace itself is set to auto-apply. That is the setting I would keep.

7. What it can and cannot do

QuestionAnswer from the runs above
Does it need an account?No for the 9 registry tools. Yes, a token, for everything about workspaces.
Does it need Docker?No. The 1.4.1 binary did everything the image did.
Does it run terraform plan on my laptop?No. There is no such tool; create_run creates a run in an HCP Terraform workspace.
Does it read my local .tf files or state?I found no tool for it in the list. Claude Code reads your files itself; the server supplies documentation and API access.
Can it apply or destroy?Only with a token and ENABLE_TF_OPERATIONS=true.
Does it work with open-source Terraform and a local or S3 backend?The registry half does. The workspace half is HCP Terraform and Terraform Enterprise only.
Can a team share one?Yes, streamable-http mode; the defaults are rate limits of 10:20 global and 5:10 per session (requests per second and burst) per the README.
Does it make the model right?It makes the facts current. The README says outputs "may vary based on the query, model, and the connected MCP client".

Where it earns its place for me is narrow and real: before the agent writes a resource or calls a module, it can check the provider version and read the argument list of the day. Combined with a fast feedback loop like terraform console or terraform validate, wrong arguments get caught twice. The workspace tools are for teams already on HCP Terraform; if you separate environments with Terraform workspaces on a plain backend, they do nothing for you.

8. What broke when I ran this

A wrong binary path, and a wrong image name. I registered two broken servers on purpose, one pointing at a path where no binary exists and one with a typo in the image name, and stopped the HTTP server:

1$ claude mcp list
2Checking MCP server health…
3terraform: docker run -i --rm hashicorp/terraform-mcp-server:latest - ✔ Connected
4terraform-bin: /tmp/tfmcp/terraform-mcp-server stdio - ✔ Connected
5terraform-missing: /usr/local/bin/terraform-mcp-server stdio - ✘ Failed to connect — ENOENT: no such file or directory, posix_spawn '/usr/local/bin/terraform-mcp-server'
6terraform-typo: docker run -i --rm hashicorp/terraform-mcp-servr:latest - ✘ Failed to connect — CONNECTION_CLOSED: Connection closed
7terraform-http: http://127.0.0.1:8080/mcp (HTTP) - ✘ Failed to connect — ECONNREFUSED: Unable to connect. Is the computer able to access the url?

The missing binary gets a precise message. The mistyped image does not: the docker run exits because there is no such image, and all Claude Code can report is that the connection closed. When you see CONNECTION_CLOSED for a Docker-based server, run the exact command from the Args: line of claude mcp get <name> in a terminal; Docker's own error is there. Note also that claude mcp add accepted all three broken servers without complaint. It writes configuration and checks nothing.

A fake token unlocked the whole tool list. The reference says the server registers the workspace tools "only when you provide a valid TFE_TOKEN". In my run the token not-a-real-token was enough: the log says "Created TFE client" and "Registering TFE tools - first session with valid TFE client detected", and the client was offered all 56 tools. Only the first real call failed, with failed to list Terraform organizations: unauthorized. So an expired token does not look like "no HCP tools"; it looks like a full toolbox in which everything answers unauthorized. Ask the agent to call whoami first.

One module call returned 258 KB. get_module_details for terraform-aws-modules/vpc/aws/6.9.0 came back with 258,422 characters: every input with its default, every output, the README. It is correct and far too much for one tool result. For big modules, let the agent search first and ask for what it needs, or read the module's page yourself.

--tools and --toolsets together kill the server. ./terraform-mcp-server stdio --toolsets=registry --tools=search_modules exits at once with level=fatal msg="Cannot use both --tools and --toolsets flags together". From the client's side that is one more silent CONNECTION_CLOSED.

I guessed tool names and was wrong. My first script called search_providers and list_workspaces without a token. Both came back as tool 'search_providers' not found: tool not found. The tool is search_provider_docs in 1.4.1, and list_workspaces does not exist until a token is set. Read tools/list for the version you run instead of trusting a blog post, this one included.

No results is reported as an error. search_policies with the query cis aws returned isError: True and "no policies found matching query: cis aws - try a different search term". An agent may read that as a failure of the tool, not as an empty result.

9. Conclusion

  1. Install: docker pull hashicorp/terraform-mcp-server or the checksummed binary; both are version 1.4.1 today.
  2. Register: claude mcp add terraform -- docker run -i --rm hashicorp/terraform-mcp-server:latest, then claude mcp list until it says Connected.
  3. Without a token you get 9 registry tools; that alone is worth having for current provider and module documentation.
  4. With TFE_TOKEN you get 56; leave ENABLE_TF_OPERATIONS off and keep the token out of the repository.
  5. When it fails, read the status: Pending approval, ENOENT, CONNECTION_CLOSED and ECONNREFUSED each point at a different cause.

Did this save you a debugging session? Stay in the loop -

Read More - Terragrunt -

  1. How to use Terragrunt?