MCP ServerSTDIO

Terraform MCP Server

Models hallucinate Terraform arguments constantly — a plausible attribute name that no provider version ever shipped. HashiCorp’s official MCP server fixes the root cause by giving the model live access to the Terraform Registry: real provider documentation, real modules, real policies, resolved against the version you are actually using.

Hosted URL

Bring your own

Suggested model

Claude Sonnet 4.5

Chat with 60+ AI models on the same workflow — switch to a different model mid-conversation and re-run the same prompt, or use Compare mode to put several side-by-side and balance quality vs. cost.

Auth

No token required

What the Terraform MCP server does

How models use it and what it is built for.

The Terraform MCP server is a documentation and registry tool first. An agent searches for a provider, resolves it to a concrete version, and pulls the actual documentation for a resource or data source before it writes a single line of HCL — which is the difference between generated configuration that plans cleanly and configuration that fails on an unknown argument. The same search-then-fetch pattern covers registry modules and Sentinel policies. Beyond the public registry, setting a TFE address and token unlocks the HCP Terraform and Terraform Enterprise APIs, so an agent can list organizations and workspaces, inspect runs and read state versions. It runs over stdio for local clients and can also be started in streamable-HTTP mode when you want to host it for a team.

Tools the Terraform MCP server exposes

Typical tools an AI model can call. Exact names vary by version.

  • search_providers — find a provider in the registry and resolve a documentation ID
  • get_provider_details — the real documentation for a resource or data source at a version
  • search_modules / get_module_details — registry modules, their inputs and outputs
  • get_latest_provider_version / get_latest_module_version — pin against what actually exists
  • search_policies / get_policy_details — Sentinel policy libraries from the registry
  • HCP Terraform tools — organizations, workspaces, runs and state versions with a TFE token

Connecting to Terraform

Taken from the official Terraform documentation — see hashicorp/terraform-mcp-server — official repository for the full reference.

Environment variables

  • TFE_ADDRESS

    Base URL of your HCP Terraform or Terraform Enterprise instance. Defaults to app.terraform.io.

  • TFE_TOKEN

    API token for HCP Terraform or Terraform Enterprise. Required only for the workspace, run and state tools.

  • TRANSPORT_MODE

    Set to http to run the server in streamable-HTTP mode instead of stdio, for hosting it centrally.

Client configuration

Docker (recommended)

HashiCorp publishes the image; nothing to install on the host beyond Docker itself.

{
  "mcpServers": {
    "terraform": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "hashicorp/terraform-mcp-server"]
    }
  }
}

With HCP Terraform access

Adds the workspace, run and state-version tools on top of the public registry lookups.

{
  "mcpServers": {
    "terraform": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "TFE_ADDRESS", "-e", "TFE_TOKEN",
        "hashicorp/terraform-mcp-server"
      ],
      "env": {
        "TFE_ADDRESS": "https://app.terraform.io",
        "TFE_TOKEN": "YOUR_TOKEN"
      }
    }
  }
}

Example prompts to try

Copy any of these into MCP Agent Studio after connecting.

  • What are the required arguments for aws_ecs_service in the latest AWS provider?

  • Find a registry module for a VPC with private subnets and show me its inputs.

  • Write a Terraform config for a Cloudflare DNS record, checking the real docs first.

  • Which of my HCP Terraform workspaces have runs that errored this week?

Models on MCP Playground

This is not a single-model product: you get the same MCP connection with 60+ models (Claude, GPT, Gemini, DeepSeek, open-weight, and more), you can switch mid-conversation, and you can open Compare mode to run the same prompt against multiple models at once. The card above is a suggested starting point for this server — not the only choice.

Default pick for Terraform

Claude Sonnet 4.5

Writing HCL against fetched documentation is a code-generation task with a verification step. Sonnet 4.5 reliably reads the docs before it writes rather than after.

Check an AI agent can actually use the Terraform MCP server

Listing tools proves the server is reachable, not that a model can work with it. Evals go further: they read every tool on the server, write a test suite from its real schemas, and run it — code decides pass/fail on the responses (schema conformance, error codes, pagination, result caps) while a scoring model grades plain-English tasks driven through the tools.

Get a pass/fail report per tool with the evidence behind each verdict — and replay the same suite after every schema change. Destructive tools are excluded from the run.

Run evals

Try the Terraform MCP server in your browser

Open MCP Agent Studio with the connection pre-filled. Add your token, pick any of 60+ models, and start chatting — no install required.

Open Agent Studio

Terraform MCP server — FAQ

Common questions about connecting, scoping and using it safely.

What is the Terraform MCP server?

It is HashiCorp’s official MCP server for the Terraform ecosystem. It gives an AI agent live access to Terraform Registry provider documentation, modules and policies, and optionally to HCP Terraform or Terraform Enterprise workspaces and runs.

Does it run terraform plan or apply?

Not against your local working directory. The public tools are registry lookups, and the HCP Terraform tools read organizations, workspaces, runs and state versions through the API. It is a research and inspection server, not a local execution wrapper.

Why does this reduce hallucinated Terraform code?

Because the model stops guessing. A provider’s arguments change between versions, and a model trained months ago will confidently produce an attribute that was renamed or never existed. Resolving the provider version and fetching the real documentation removes that whole failure mode.

Do I need a HashiCorp account?

Not for registry lookups, which are public and need no credentials. A TFE token is only required for the HCP Terraform and Terraform Enterprise tools.

Can I host it for a whole team?

Yes. Setting TRANSPORT_MODE to http starts the server in streamable-HTTP mode, so one instance can serve many clients instead of every developer running their own stdio process.

Other MCP servers

More on MCP Playground

Terraform MCP Server — Provider Docs and Modules for AI Agents