Terraform MCP server security: permissions, risky tools and lockdown

The official Terraform MCP server controls access through toolsets, the TFE_TOKEN's permissions and a destructive-operations gate, but it has no built-in SSO or audit log in the sources supplied. This page sets out what is built in, what needs outside components and what to lock down.

On this page

Does the Terraform MCP server meet our permission and lockdown requirement?

A security or platform reviewer deciding whether AI agents may use the Terraform MCP server will find built-in permission controls in its local and self-hosted forms: toolset selection, token-bound permissions and a destructive-operations gate. On the remote beta server, the token's permissions set the boundary instead. These controls are the server's own, so they apply whichever deployment you choose, but they only hold if your team sets them deliberately rather than accepting defaults.

Meeting the requirement takes three decisions. First, choose a deployment: local, self-hosted in an environment you manage, or the remote server, which does not support Terraform Enterprise. Second, scope the TFE_TOKEN to the least access the agent needs and use get_token_permissions and whoami to confirm what it can do and who owns it. Third, set the flags deliberately. Without --toolsets, all toolsets are enabled, and the registry-private and terraform toolsets register only when a valid token is provided. Destructive tools also need ENABLE_TF_OPERATIONS set to true, so leave it unset unless a workflow requires it. The --tools flag cannot be combined with --toolsets, so pick one approach and document it.

The supplied material does not establish SSO, an RBAC layer above the token or a server-side audit log, so confirm those with HashiCorp before approval. If your policy requires per-user attribution or centrally enforced approval of tool calls, you may need controls in the MCP client or your identity and logging stack. The HashiCorp security model documentation also recommends validating every write change before it is applied, which should be part of your review process regardless of the flags chosen.

Which lockdown controls each deployment option supports

This table compares which lockdown controls the Local, Self-hosted and Remote (beta) Terraform MCP server deployments support, and who sets each one. Read each cell as built in, set by the operator, not supported, or confirm with HashiCorp. The remote server is in beta, and HashiCorp's docs strongly discourage using beta features in production, so treat its controls as unverified until HashiCorp confirms them.

ControlLocalSelf-hostedRemote (beta)
Toolset selection (--toolsets)Set by the operator, all toolsets load without the flagSet by the operator, all toolsets load without the flagConfirm with HashiCorp
Individual tools (--tools flag)Set by the operator, cannot combine with --toolsetsSet by the operator, cannot combine with --toolsetsConfirm with HashiCorp
Destructive operations gate (ENABLE_TF_OPERATIONS)Set by the operator, must be true for deletes and run actionsSet by the operator, must be true for deletes and run actionsConfirm with HashiCorp
Token permission inspection (get_token_permissions, whoami)Built in, reports what the operator's TFE_TOKEN may doBuilt in, reports what the operator's TFE_TOKEN may doToken permissions bound actions, confirm whether these tools are exposed
Terraform Enterprise supportBuilt in, supports HCP Terraform and Terraform EnterpriseBuilt in, supports HCP Terraform and Terraform EnterpriseNot supported
Loopback binding and strict CORSSet by the operator, run at 127.0.0.1 with empty allowed originsSet by the operator, same loopback and CORS settings applyNot applicable to the operator
API gateway with authentication, TLS and IP allowlistNot applicable, runs on the user's own machineSet by the operator, recommended for remote hosting of your own serverConfirm with HashiCorp

How the server decides which tools an agent can call

The server applies four checks in sequence, and a reviewer should be able to trace each one. First, the --toolsets and --tools flags decide which tools are registered at all. The --tools flag enables individual tools by name and cannot be combined with --toolsets, so a team should pick one approach and document it. Second, when the server starts without --toolsets, it enables every toolset, but it registers the registry-private and terraform toolsets only when a valid TFE_TOKEN is provided. That makes the token a gate on whether HCP Terraform or Terraform Enterprise tools exist in the session, not only a credential. Third, destructive tools in the terraform toolset, such as delete_workspace_safely, also require ENABLE_TF_OPERATIONS to be set to true. The reference lists deletes, force unlock, and applying, discarding or cancelling runs as destructive operations, so these are the actions to review first.

On the remote server at the flags and environment variables you control locally are not in the path. Instead, the token's permissions bound what the server can do. The server cannot perform an action the token is not allowed to perform, so a token without apply rights cannot apply runs through the server. Confirm this with HashiCorp for your own token types, and use the get_token_permissions tool to see what a given token may do before any agent connects. The whoami` tool shows the token owner and whether it is a service account, which tells you whether actions are tied to a person or to a machine identity.

Because the token is the real boundary on the remote server, token design is the main lockdown decision. Use a token scoped to the least work the agent needs, prefer a dedicated identity that you can audit, and plan a revocation procedure, because revoking the token stops access. For local and self-hosted servers, the same logic applies, but your own controls such as network binding and CORS settings sit alongside the token. Document which combination of flags, ENABLE_TF_OPERATIONS and token scope each agent is allowed to use, and review that record whenever the agent or its client changes.

Which Terraform tools can delete, unlock or apply

The Terraform MCP server's terraform toolset is where changes to HCP Terraform and Terraform Enterprise happen, and it is the part of the server a reviewer should gate first. The cards below group the tools by what they do, name the gate that applies, and list what to confirm about the TFE_TOKEN behind them.

Workspace and project deletes

Tools such as delete_project, delete_team and delete_workspace_safely remove infrastructure objects from the organization. Under the reference, these destructive tools in the terraform toolset also require ENABLE_TF_OPERATIONS set to true before they run. Confirm that the flag is unset on every shared or team-wide deployment, and that the token's owner has no rights to delete projects or teams it does not need.

Terraform MCP server reference

Force unlocking workspaces

A force unlock clears the lock another run holds on a workspace, which can let a second run start while the first is still changing state. The reference lists force unlock among the destructive operations, so it sits behind the same ENABLE_TF_OPERATIONS gate. Ask whether anyone on the team can clear a state lock, and whether the token's permissions allow it at all.

Applying runs

Applying a run executes a plan against real cloud resources, which makes it the most consequential write the server can trigger. The security model recommends validating any write change before it happens, so treat apply as a human decision. Confirm that the token cannot apply runs in workspaces that hold production state, and that the gate is off for any client that is not reviewed.

Security model for the server

Discarding and cancelling runs

Discarding a pending run throws away a reviewed plan, and cancelling stops a run mid-execution, which can leave resources partly changed. Both appear in the reference's list of destructive operations and both sit behind ENABLE_TF_OPERATIONS. Check who on the team is expected to discard or cancel runs, and whether an agent should ever stop a run another engineer started.

Identity and token scope lookups

The read-only tools whoami and get_token_permissions return the token owner's username, email address and whether the account is a service account, along with the actions the TFE_TOKEN may take. They change nothing, but they show an agent exactly what it can do. Confirm that the token belongs to a service account where possible, and review the permissions it returns before any destructive gate is opened.

Terraform MCP server reference

How to lock down a local, self-hosted or remote deployment

A local server runs on a developer's machine and acts with whatever Terraform token that machine holds. The main risk is that other processes, other users or a web page in the browser can reach the server and use its tools. HashiCorp's guidance narrows that exposure by limiting where the server listens, which origins may call it and how much the token can do.

  • Bind to 127.0.0.1: Listening only on the loopback address keeps the server off the local network, so a neighbor or a container on another interface cannot send it requests.
  • Keep CORS strict: HashiCorp's default is an empty allowed origins list. Browser pages on other sites cannot call the server unless you add an origin, which blocks drive-by requests from a page the developer happens to visit.
  • Keep TFE_SKIP_TLS_VERIFY at false: Certificate checking stays on, so the token is not sent to a server whose identity has not been verified.
  • Limit TFE_TOKEN permissions: The token's own permissions set the ceiling on what any tool can do. A narrower token limits damage from a bad prompt or a poisoned tool description. Use get_token_permissions to confirm what the token can do.
  • Add rate limits: Throttling caps how many calls an agent can make in a burst, which limits runaway loops and bulk changes.

Before approving local use, ask whether each developer has a separate token with the smallest workable permissions and whether the server is started with the --tools flag so only the tools the team needs are available.

Decisions the organization must make before approval

Approving the Terraform MCP server is a series of configuration choices, not a single yes or no. Each choice sets how much an AI client can read, how much it can change, and how well your audit trail attributes those actions. The cards below cover the decisions reviewers should settle and record before any staff member connects an agent.

Which toolsets to expose

The server has three toolsets: registry for the public registry, registry-private for private registries, and terraform for HCP Terraform and Terraform Enterprise. Only the terraform toolset touches your workspaces, runs and projects, so it carries most of the blast radius. Without a --toolsets flag the server enables everything, and it registers the registry-private and terraform toolsets only when a valid TFE_TOKEN is present. Decide which toolsets each team needs and set them explicitly.

Server reference

Dedicated least-privilege or service account token

The token's permissions bound what the server can do, and revoking the token stops access. A personal token inherits that person's rights and makes AI actions hard to tell apart from their own. A dedicated token, ideally owned by a service account, gives you a narrow permission set and a clear audit identity. Use get_token_permissions to confirm what a token can do and whoami to confirm who owns it before rollout.

Whether to allow destructive operations

Destructive tools in the terraform toolset, such as delete_project, delete_team and delete_workspace_safely, also require ENABLE_TF_OPERATIONS set to true. HashiCorp lists deletes, force unlock, and applying, discarding or cancelling runs as destructive operations. Keep that variable unset for most teams, and treat any approval to enable it as a decision for the owner of the affected workspaces. Record who approved it and for which environments.

Local, self-hosted or beta remote deployment

Local and self-hosted servers run in an environment you control, support HCP Terraform and Terraform Enterprise, and can be installed with Docker, a binary or from source. The remote server at mcp.terraform.io is in beta, which HashiCorp's docs strongly discourage for production, and it does not support Terraform Enterprise. For a remote setup, HashiCorp recommends an API gateway with authentication, TLS and IP whitelisting, plus an organization allowlist. Confirm support terms for whichever option you choose.

Remote server docs

HCP Terraform or Terraform Enterprise as target

The target platform decides which deployment options are valid and which token and audit records apply. The remote server supports HCP Terraform only, so Terraform Enterprise environments must use a local or self-hosted server. Map each target to its owner, its token and the tools it will expose. Ask your platform team to confirm which organizations and workspaces the token can reach, because that boundary is the practical limit on what an agent can touch.

Named tools allowed with the --tools flag

The --tools flag enables individual tools by name, but it cannot be combined with --toolsets. Pick either a toolset-level scope or a named tool list, and document the choice. A short named list, such as read-only lookups for plans and workspace metadata, is easier to review than an entire toolset. Review the list whenever the server is upgraded, because the set of tools may change between releases. Confirm the current tool names in the reference before writing the allowlist.

Tool reference

Decision path from agent request to Terraform action

The diagram follows one tool call from the AI client through the MCP server. It starts at the client, passes the server's toolset and TFE_TOKEN registration check, then the ENABLE_TF_OPERATIONS gate for destructive tools, and finally the token's own permissions on the Terraform side. Blue nodes are settings the operator chooses, and grey nodes are checks HashiCorp enforces. Reviewers should confirm which checks their deployment actually runs, because this illustrates the documented decision path, not a traced run.

Illustrative of the documented decision path; operator-set steps are marked separately from HashiCorp-enforced checks.

Where the server's controls stop short of enterprise requirements

HashiCorp's controls limit what the Terraform MCP server can do, but they do not replace identity, review or logging controls around it. The cards below name the gaps a security or platform reviewer should close with a gateway, token policy, change review or log collection, and what to confirm with HashiCorp before approval.

No SSO or OAuth on the remote server

Sibling coverage indicates the remote server authenticates with a Terraform API token rather than OAuth, so individual sign-in through your identity provider is not available there. Confirm current behavior with HashiCorp before approval. Cover the gap with an API gateway that enforces authentication, TLS and IP allowlisting in front of the server, and an organization allowlist, as HashiCorp's deployment guidance recommends for remote hosting.

Deploy docs

Prompt injection and tool poisoning remain open

HashiCorp's security model names prompt injection, tool poisoning, rug pull attacks, tool shadowing and hallucinations as risks for MCP clients. The server does not stop these by itself, so a malicious instruction in a module, plan output or tool description can still steer an agent. Reduce exposure by pinning approved server versions, reviewing tool descriptions before enabling them, and limiting the agent to the toolsets it needs.

Security model

Write changes depend on human validation

HashiCorp recommends validating every write change before it runs, which places the final check with the people and pipelines around the server. Destructive operations such as applying, discarding or cancelling runs and force unlocking require ENABLE_TF_OPERATIONS set to true, so the flag is the first gate to review. Require plan review in HCP Terraform or Terraform Enterprise, and keep apply permissions separate from the agent's token.

Server reference

Remote server is in beta

The remote server at the hosted MCP endpoint is in beta, and HashiCorp's docs strongly discourage beta features in production. Teams that want a production path should prefer a self-hosted or local deployment in an environment they manage, or limit remote use to evaluation. Ask HashiCorp for the expected move to general availability and any change to terms before rollout.

No Terraform Enterprise on remote

The remote server does not support Terraform Enterprise. Organizations running Terraform Enterprise must use a local or self-hosted deployment, which keeps the server inside infrastructure they manage and needs its own gateway, TLS and token handling. Check the deployment choice against where your Terraform state and workspaces live before the server is approved.

Remote server docs

Audit logs and retention need confirmation

The server's documentation covers token permissions and the token owner's identity, but it does not give a complete audit trail for agent actions. Confirm which events HCP Terraform or Terraform Enterprise records for runs, variable changes and API calls made with the agent's token, how long they are kept, and how you export them. Add gateway request logging and forward both sets of logs to your SIEM.

Order of work to put the lockdown in place

This sequence moves the Terraform MCP server from a default-open setup to one where each capability is chosen, scoped and recorded before any staff member or agent uses it. Each step closes with a check that must pass before the next step begins.

  1. Choose the deployment and rule out beta production use

    The platform or security lead picks one of the three deployment options: local, self-hosted in an environment you manage, or the remote server HashiCorp hosts. The remote server is at a beta endpoint, and HashiCorp's docs strongly discourage beta features in production, so confirm with HashiCorp whether the remote option is suitable for your use. The remote server also does not support Terraform Enterprise. Done when the chosen deployment is written down with a reason, and the team confirms it is not relying on beta for production work.

  2. Create a scoped token and confirm its permissions

    The Terraform administrator creates a dedicated TFE_TOKEN for the MCP server, preferably tied to a service account rather than a personal user, and grants only the actions the use case needs. Then run the get_token_permissions tool to list what the token may do, and run whoami to confirm the owner and whether it is a service account. Done when the returned permissions match the approved request. If they are broader, reissue the token before going further.

  3. Register only the toolsets and tools the use case needs

    Without a --toolsets flag, the server enables all toolsets, so the engineer sets the toolsets explicitly to registry, registry-private or terraform, based on the use case. The --tools flag can enable individual tools by name, but it cannot be combined with --toolsets. Registry-private and terraform register only when a valid token is provided, so confirm the token step first. Done when the startup configuration lists the exact toolsets and tools, and a test session shows no other tools available to the client.

  4. Keep destructive operations off until a process exists

    Leave ENABLE_TF_OPERATIONS unset or false. Destructive tools such as delete_workspace_safely, along with deletes, force unlock, and applying, discarding or cancelling runs, need this setting to be true. Enable it only after the change owner has a reviewed approval process and HashiCorp's guidance that changes must be validated before any write is accepted. Done when a test call to a destructive tool is refused while the setting is off, and the decision is recorded with the approver's name.

  5. Place the self-hosted endpoint behind a gateway

    The network engineer binds the self-hosted server to 127.0.0.1 and keeps CORS strict with an empty allowed origins list. TFE_SKIP_TLS_VERIFY stays false. For remote or shared hosting, put an API gateway in front of the server that enforces authentication, TLS and IP allowlisting, and add an organization allowlist. Rate limits are also recommended. Done when a request from an address outside the allowlist fails, a plain HTTP request is refused, and a request with a valid credential succeeds through the gateway.

  6. Test against a non-production organization

    The Terraform administrator points the configured server at a non-production HCP Terraform organization, not production workspaces. The test team runs read queries, confirms that write and destructive tools behave as the earlier steps define, and checks that revoking the token stops access, which HashiCorp's security model describes for the remote server. Done when every test case matches the expected result and any gap is logged as a finding that must be fixed before production use.

  7. Review the configuration and record decisions

    The security reviewer compares the live configuration with the decisions from earlier steps: deployment choice, token scope, toolsets, destructive flag, gateway rules and test results. Record each decision, its owner and the date it was approved, and set a schedule to repeat the token and toolset review. Done when a signed record exists that a reviewer or auditor can read without asking the team, and any open items have a named owner.

Evidence a security reviewer will ask to see

This table lists the evidence a reviewer should request for a Terraform MCP server rollout, with what each item shows and where it comes from. Read each row as a question to answer with a file, a token listing or a log export, not with a verbal assurance. The main takeaway is that the server's own tools report token scope and owner identity, while the actual limits come from the token, the deployment settings and Terraform's run records.

EvidenceWhat it showsWhere it comes from
MCP client configurationWhich toolsets and individual tools the server loads, and confirmation that --toolsets and --tools are not combinedClient config file and server start command, checked against the Terraform MCP server reference
Token permission listingThe actions the TFE_TOKEN may take, so reviewers can compare them with the intended roleOutput of the get_token_permissions tool, described in the Terraform MCP server reference
Token owner identityUsername, email address and whether the token belongs to a service accountOutput of the whoami tool, described in the Terraform MCP server reference
Destructive operation gateWhether ENABLE_TF_OPERATIONS is set to true, which unlocks deletes, force unlock and applying, discarding or cancelling runsServer environment settings, checked against the Terraform MCP server reference
Gateway and organization allowlistFor remote or self-hosted use, the API gateway with authentication, TLS and IP allowlisting, plus the permitted organization listGateway configuration and allowlist records, following the deployment guidance in the Deploy the Terraform MCP server docs
TLS and certificate verificationThat TFE_SKIP_TLS_VERIFY is false and the server reaches Terraform over verified TLSServer environment settings, following the deployment guidance in the Deploy the Terraform MCP server docs
Terraform-side audit recordsRun history and delete events in HCP Terraform or Terraform Enterprise, showing who triggered each actionTerraform audit and run logs in your HCP Terraform or Terraform Enterprise organization, to be confirmed with HashiCorp's current documentation

Questions buyers and reviewers ask before approving the server

Can the Terraform MCP server be restricted to read-only use?

Not with a single switch that this page can confirm, but you can limit writes with two controls. First, start the server with --toolsets or --tools so only the read tools you need are registered. The --tools flag cannot be combined with --toolsets. Second, destructive tools in the terraform toolset, such as delete_workspace_safely, also require ENABLE_TF_OPERATIONS set to true. The reference lists deletes, force unlock, and applying, discarding or cancelling runs as destructive operations, so leaving that variable unset keeps those actions gated. Before approval, ask HashiCorp whether a dedicated read-only mode exists for your version, and test the registered tool list in your own environment.

Is it acceptable to connect the Terraform MCP server with a personal token?

A personal token works, but it is the weakest option for shared team use. Agent actions are tied to that person's identity, and the token's permissions set the ceiling for what the server can do. Anything that person may do in HCP Terraform, the agent can attempt. That gives clear attribution to one individual but weak separation of duties and a larger blast radius if the token is exposed. A service account token with narrowly granted permissions is usually the stronger choice for shared use. Use get_token_permissions to list what a token may do and whoami to confirm the owner and whether it is a service account. Ask your platform team which token types they issue and who rotates them.

What does the Terraform MCP server cost to run?

The repository shows an MPL-2.0 license, which governs the published code. It does not set the price of your Terraform subscription. The main cost sits in the HCP Terraform or Terraform Enterprise plan your team already buys or plans to buy, and HashiCorp sets those terms. Your internal costs include hosting if you self-host, an API gateway with TLS and IP whitelisting for remote use, and the engineering time for token management, rate limits and review. Ask HashiCorp for written licensing terms covering the edition you run and whether MCP server use changes anything in your agreement. Costs rise with the number of hosted deployments, users and controls you must build. Do not rely on any figure until it is in writing.

How long does a Terraform MCP server rollout take, and what drives it?

No duration is supplied for this rollout, so confirm any estimate with HashiCorp or your implementation partner. The main drivers are the deployment option, the toolsets you enable, and the controls you must build around it. A local install by Docker, binary or source can be trialed quickly, but each developer machine then needs its own lockdown. A self-hosted server needs hosting, TLS, strict CORS and rate limits. The remote server needs no installation, but it is in beta, HashiCorp's docs strongly discourage beta features in production, and it does not support Terraform Enterprise. If remote use is planned, scope the API gateway, IP whitelisting and organization allowlist before the timeline is set.

What can our own team do, and when do we need outside help?

A team with someone who owns both Terraform and identity can complete the core configuration alone. That means choosing a deployment, binding the server to 127.0.0.1, keeping CORS strict with an empty allowed origins list, keeping TFE_SKIP_TLS_VERIFY at false, scoping TFE_TOKEN, and enabling only the toolsets you need. Outside help is worth considering for work that needs independent evidence: testing tool permissions, prompt injection and tool poisoning exposure, and the gateway design for remote use. DeployOpen runs AI agent rollout security reviews that test tool and file permissions, credential handling, and SSO and admin settings, then deliver a findings report with fixes and a retest. Work is fixed-scope and agreed in writing. DeployOpen does not issue audit reports or certifications.

What happens if a token leaks or an employee leaves?

Revoking the token stops the server's access, which is the fastest containment step. On the remote server, the token's permissions bound what the server can do, so a narrowly scoped token limits damage before any response begins. Plan for three events: a leaked token, a departing employee, and an agent proposing a risky change. For the first two, revoke and rotate the token, then review what it could do using get_token_permissions. For the third, keep ENABLE_TF_OPERATIONS unset and require human review before any apply. HashiCorp's security model recommends validating every write change before it runs, so keep that review step in your process. Confirm revocation and rotation procedures with your HCP Terraform administrators before rollout.

How DeployOpen works on this

DeployOpen reviews how a Terraform MCP server deployment is configured, tested and locked down inside your own environment, covering tool exposure, token permissions, deployment choice and the controls that gate destructive operations. Engagements are fixed-scope, with the scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • Confirm which deployment option applies: local, self-hosted or the remote server, and which HCP Terraform or Terraform Enterprise environment it reaches.
  • Inventory the toolsets and tools enabled, and map which tools read state, change workspaces or run destructive operations.
  • Define the TFE_TOKEN permissions in scope and agree in writing which clients, teams and repositories the review covers.

How we build

  • Configure the server to bind to 127.0.0.1 with strict CORS, TLS verification enabled and an explicit tool list, based on the agreed scope.
  • Test prompt injection, tool poisoning and tool shadowing against the configured tools, including whether write and apply paths require validation.
  • For remote or self-hosted deployments, review the API gateway controls covering authentication, TLS, IP allowlisting and the organization allowlist.

How we hand over

  • Deliver a findings report with severity, the reproduction steps for each finding and the specific configuration change that fixes it.
  • Provide a documented lockdown baseline covering toolsets, ENABLE_TF_OPERATIONS, token scope, rate limits and approval steps for your admins.
  • Run a retest after fixes are applied and record the results so your security and compliance reviewers can verify the controls.

How we support

  • Offer ongoing support as a retainer for upgrades, configuration drift checks and repeated testing as the server and toolsets change.
  • Re-review the lockdown baseline when teams add clients, new token holders or new Terraform workspaces that the agent can reach.
  • Prepare control evidence and documentation for internal reviews and independent assessments, without issuing audit reports or certifications.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.