Terraform MCP server

The Terraform MCP server gives AI agents current Terraform Registry data on providers, modules and policies, and with a token manages HCP Terraform and Terraform Enterprise workspaces, runs and plans.

Checked by CookiesForAI on : repository facts (stars, last push, archived) re-read from GitHub; listing in the MCP Registry checked.

Written by

Connect Terraform

Claude Code, local Docker server

Terminal
claude mcp add terraform -s user -t stdio -- docker run -i --rm hashicorp/terraform-mcp-server

Codex, local Docker server

Terminal
codex mcp add terraform -- docker run -i --rm hashicorp/terraform-mcp-server

Gemini CLI extension

Terminal
gemini extensions install https://github.com/hashicorp/terraform-mcp-server

For HCP Terraform or Terraform Enterprise tools, add -e TFE_TOKEN and -e TFE_ADDRESS to the docker run command, with the token from your HCP Terraform user settings and the address including https. Choose toolsets with --toolsets, for example registry,terraform.

Or paste this into your coding agent: Connect the Terraform MCP server to my coding agent using its documented setup: https://github.com/hashicorp/terraform-mcp-server. Checked by CookiesForAI on : repository facts (stars, last push, archived) re-read from GitHub; listing in the MCP Registry checked.

Your first question with this server installed

1,830tokens sent to the model with your first question: the tool list plus one tool answer

TerraformTool list 1,815One answer 159 tools listed without a key

Typical serverFirst question 2,022 (median of 10 servers)

Terraform's first question takes 1,830 tokens: its tool list plus one answer. That is close to the median first question of the 10 servers we measured with both numbers on (2,022 tokens).

Measured without a key or sign-in. Assistants that load every tool send this list to the model with each question; some load tools only when a task needs them. The one answer is from get_latest_provider_version, a fixed read-only call. Some tools need more than a keyless connection: an HCP Terraform or Terraform Enterprise API token, only for the organization tools. Tokens are counted with OpenAI's o200k tokenizer; other models count a little differently.

Measured . How we measure.

What the Terraform MCP server does

The Terraform MCP server is HashiCorp's own server for connecting AI agents to Terraform data. Its default toolset looks up the public Terraform Registry: providers and their resource docs, modules and policies, so the agent writes HCL against the current provider version instead of guessing at arguments that changed.

With an HCP Terraform or Terraform Enterprise token set in TFE_TOKEN, the Terraform server adds tools for your organization: list and manage workspaces, their variables and tags, read the private registry, and inspect runs. get_plan_details, get_plan_logs and get_plan_json_output let the agent read what a plan will change and why it failed. Tools that need explicit approval stay off unless ENABLE_TF_OPERATIONS is set to true.

HashiCorp ships the Terraform server as a Docker image and a Go binary. It runs over stdio by default or over Streamable HTTP for a shared deployment, with per-session rate limits, CORS rules and an organization allowlist. The README warns that the server may expose Terraform data to the LLM and should not be used with untrusted clients. The repo had 1,539 GitHub stars on .

Tools it gives your agent

  • search_providers
  • get_provider_details
  • list_workspaces
  • get_plan_details
  • get_plan_logs
  • get_plan_json_output

We also list this company's other pages: 4 skills by HashiCorp.

When to use Terraform

  • You want the agent to write a module using the current version of a provider's resources.
  • You need to compare community modules in the registry for a job.
  • A plan failed in HCP Terraform and you want the agent to read its logs.
  • You want to know which workspaces use a variable or tag.

When to pick something else

  • Teams on plain open-source Terraform with local state only: the workspace and plan tools need HCP Terraform or Terraform Enterprise.
  • Running applies unattended: with ENABLE_TF_OPERATIONS on and a broad token, the agent can change workspaces and start runs, so keep tokens scoped.

What Terraform needs

  • Docker, or the terraform-mcp-server binary
  • An HCP Terraform or Terraform Enterprise API token, only for the organization tools

What the Terraform MCP server costs

Free and open source under MPL-2.0; public registry lookups need no account, and the HCP Terraform and Terraform Enterprise tools need an account HashiCorp prices separately.