Is the Terraform MCP server safe? What it can reach
What the Terraform MCP server can read, write and delete, how it signs in, and how to limit it in Claude Code and Codex.
HashiCorp maintains the official Terraform MCP server. By default it only reads the public registry. With a TFE_TOKEN it can manage HCP Terraform and Terraform Enterprise workspaces, variables, runs and teams with that token’s rights. ENABLE_TF_OPERATIONS defaults to false and gates deletes, force unlocks and applies.
Who maintains it
| Implementation | Kind | Status |
|---|---|---|
| hashicorp/terraform-mcp-server (official) | Official | active |
It runs as a local process on your machine or as a hosted remote server. The documented endpoint is https://mcp.terraform.io/mcp.
How it signs in
HCP Terraform and Terraform Enterprise tools use a TFE_TOKEN API token, set in the environment or sent as a bearer header, and act with that token’s rights. The registry tools need no token.
What its tools can do
| Kind | Tools |
|---|---|
| Read | search_providers, get_provider_details, get_provider_capabilities, get_latest_provider_version, search_modules, get_module_details, get_latest_module_version, search_policies, get_policy_details, search_private_modules, get_private_module_details, search_private_providers, get_private_provider_details, whoami, get_token_permissions, list_terraform_orgs, list_terraform_projects, get_project, list_teams, get_team, list_workspaces, get_workspace_details, list_runs, get_run_details, get_run_comments, get_plan_details, get_plan_logs, get_plan_json_output, get_apply_details, get_apply_logs, get_sentinel_mock, list_state_versions, get_state_version, list_workspace_policy_sets, list_variable_sets, list_workspace_variables, read_workspace_tags, list_stacks, get_stack_details |
| Write | create_project, create_team, add_team_member, grant_team_access, create_workspace, create_no_code_workspace, update_workspace, create_workspace_tags, create_variable_set, create_variable_in_variable_set, create_workspace_variable, update_workspace_variable, attach_variable_set_to_workspaces, detach_variable_set_from_workspaces, attach_policy_set_to_workspaces |
| Can’t be undone | create_run, action_run, delete_project, delete_team, delete_workspace_safely, delete_variable_in_variable_set, force_unlock_workspace |
The default toolset is registry only. The registry-private and terraform toolsets register only when a valid TFE_TOKEN is set. create_run is listed as destructive because it can start auto-approved or destroy runs; those run types, plus action_run and the delete and force-unlock tools, need ENABLE_TF_OPERATIONS=true. Search and import tools (execute_search_query, prepare_import and others) are also documented but not itemized here.
Built-in limits
| Option | What it does |
|---|---|
--toolsets | Choose groups: registry, registry-private, terraform, all or default. The default is registry only. |
--tools | Enable individual tools by name. It cannot be combined with --toolsets. |
ENABLE_TF_OPERATIONS | Defaults to false. Gates delete tools, force_unlock_workspace, action_run and create_run with auto_approve or is_destroy. |
MCP_ORGANIZATION_ALLOWLIST | For the HTTP server, a CSV of organizations a bearer token must be able to access. |
TFE_ADDRESS | Set server-side only in HTTP mode; clients cannot redirect the token to another host. |
The risks
- With a TFE_TOKEN, an injected instruction in a run log or workspace description could make the agent change workspace variables or attach variable sets, which changes what the next apply does.
- create_run and action_run can start and apply runs, and the server’s own docs gate auto-approved and destroy runs behind ENABLE_TF_OPERATIONS=true, so leave that unset.
- State version and plan output tools can return values from your state and plan JSON to the model.
- The token carries its own organization or team rights, so a broad token lets the agent act across every workspace it can reach.
- HashiCorp warns not to use the server with untrusted MCP clients or LLMs.
Limit it in Claude Code
Add it from the documented launch settings, at local or user scope so a token never lands in a shared .mcp.json:
claude mcp add --env TFE_TOKEN=... --env TFE_ADDRESS=... terraform -- docker run -i --rm hashicorp/terraform-mcp-serverClaude Code names MCP tools mcp__terraform__<tool>. Deny rules win over ask rules, and ask rules over allow rules. Put these in ~/.claude/settings.json or the project’s .claude/settings.json:
{
"permissions": {
"deny": [
"mcp__terraform__delete_project",
"mcp__terraform__delete_team",
"mcp__terraform__delete_workspace_safely",
"mcp__terraform__delete_variable_in_variable_set",
"mcp__terraform__force_unlock_workspace",
"mcp__terraform__action_run"
],
"ask": [
"mcp__terraform__create_run",
"mcp__terraform__create_workspace",
"mcp__terraform__create_no_code_workspace",
"mcp__terraform__update_workspace",
"mcp__terraform__create_workspace_variable",
"mcp__terraform__update_workspace_variable",
"mcp__terraform__create_variable_set",
"mcp__terraform__create_variable_in_variable_set",
"mcp__terraform__attach_variable_set_to_workspaces",
"mcp__terraform__detach_variable_set_from_workspaces",
"mcp__terraform__attach_policy_set_to_workspaces",
"mcp__terraform__add_team_member",
"mcp__terraform__grant_team_access",
"mcp__terraform__create_team",
"mcp__terraform__create_project"
]
}
}Limit it in Codex
Codex reads MCP servers from ~/.codex/config.toml. disabled_tools removes tools, and enabled_tools keeps only the ones you list:
[mcp_servers.terraform]
command = "docker"
args = ["run", "-i", "--rm", "hashicorp/terraform-mcp-server"]
env_vars = ["TFE_TOKEN", "TFE_ADDRESS"]
disabled_tools = ["delete_project", "delete_team", "delete_workspace_safely", "delete_variable_in_variable_set", "force_unlock_workspace", "action_run"]Checklist
- Start with the default registry toolset and no token.
- Add --toolsets terraform only when the agent must touch workspaces.
- Use a team token limited to the workspaces it needs.
- Leave ENABLE_TF_OPERATIONS unset.
- Keep apply approval in HCP Terraform, not in the chat.
Checked against the vendor documentation on November 25, 2026. terraform-mcp-server README · Terraform MCP server reference
What Excellent covers
Excellent doesn’t inspect MCP servers themselves. Its free scan reads supported logs on the Mac (Claude Code, Codex, Grok Build, GitHub Copilot CLI, Gemini CLI and Qwen Code) and reports findings for review, so you can see what an agent did after a session. Run the free scan · See a sample report · How to vet any MCP server
Excellent Pro adds checks before supported actions. Claude Code can display an ask prompt. With Codex, an Excellent “ask” refuses the action and tells the agent to ask you. Pro is US-only for now. Agent coverage · Pricing