Terraform MCP Server

HashiCorp's MCP server for Terraform Registry lookups and HCP Terraform / Terraform Enterprise workspaces.

By defaultCan write
With our presetRead-only
Flagssecrets

Labels are provisional (from the project README/docs, checked Nov 3, 2026). Not yet tested in our sandbox.

Read-only switch

Limit to registry lookups with --toolsets=registry. Workspace/run operations are behind ENABLE_TF_OPERATIONS (off by default). Keep it unset.

Preset

Read-onlyRead-only switch from the vendor's docs. Not sandbox-tested yet.
What the preset changes
  • Added --toolsets=registry

Claude Code

.mcp.json
{
  "mcpServers": {
    "terraform": {
      "command": "docker",
Removed:       "args": ["run", "-i", "--rm", "hashicorp/terraform-mcp-server"]
      "args": [
        "run", "-i", "--rm", "hashicorp/terraform-mcp-server",
        "--toolsets=registry"
      ]
    }
  }
}

Optional third layer: add "deny": ["mcp__terraform__<write tool>"] under permissions in .claude/settings.json.

Codex

~/.codex/config.toml
# Generated by redpresets.dev on 2026-11-03. Unverified preset. Also use a read-only credential. Not a security guarantee.

[mcp_servers.terraform]
command = "docker"
Removed: args = ["run", "-i", "--rm", "hashicorp/terraform-mcp-server"]
args = ["run", "-i", "--rm", "hashicorp/terraform-mcp-server", "--toolsets=registry"]
default_tools_approval_mode = "writes"

default_tools_approval_mode = "writes" asks before any tool the server does not mark read-only.

Cursor

.cursor/mcp.json
{
  "mcpServers": {
    "terraform": {
      "type": "stdio",
      "command": "docker",
Removed:       "args": ["run", "-i", "--rm", "hashicorp/terraform-mcp-server"]
      "args": [
        "run", "-i", "--rm", "hashicorp/terraform-mcp-server",
        "--toolsets=registry"
      ]
    }
  }
}

Don't add write tools to mcpAllowlist in .cursor/permissions.json. Leave them on approval. Cursor's docs say the allowlist is not a security boundary.

Lines marked + are what we added to the vendor's install command. Struck-through lines marked − are what they replaced; Copy leaves those out.

Credential layer

Do not give the agent a TFE/HCP Terraform token for registry-only use. Your local terraform CLI and cloud credentials are a separate path: see the DataTalks.Club incident.

Gotchas

  • This MCP server does not stop an agent from running terraform destroy in a shell. Restrict shell commands in your agent too.

Related incidents

Facts

Vendor
HashiCorp official
Source
hashicorp/terraform-mcp-server
License
MPL-2.0
GitHub stars
1.6k
Latest release
v1.4.1 (Oct 23, 2026)
Last push
Oct 26, 2026
Status
Active
Last checked
Nov 3, 2026

Sources

Spotted something wrong? Labels change when vendors change. Suggest a correction

Read-only alternatives in IaC