Skip to content

Variables and TF_VAR_

Variable values are read by the MCP server, never the engine. Your agent passes them to open or to a plan command; TF_VAR_<name> comes from the server’s environment; terraform.tfvars and *.auto.tfvars load on their own. mise never supplies one. For setting values as a task, see Variables and var files.

open’s var and var_file are kept for the workspace while it is open, in the server’s memory only. status lists their names, never their values. Every tool on the workspace derives its backend and reads its state with them.

Each plan command (up, destroy, refresh, import, invoke) takes its own var and var_file, laid over open’s name by name. They hold for that run, every round of it, and are never kept.

open({ var: { region: "eu-west-1" }, var_file: ["/Users/you/secrets/prod.tfvars"] })
up({ var: { image_tag: "v42" } })

The server writes nothing down. After the server restarts, open the workspace again with the same values. The engine keeps one copy: the values of the last up that converged, with that run’s configuration, for reading objects between runs. Sensitive values are in it; ephemeral ones never are. See Drift.

Keep a secret in a file and give the agent its path as var_file: the agent never needs to read it.

TF_VAR_<name> comes from the server’s environment, which your MCP client sets in the server’s definition. Put it in the env block:

Claude Desktop, Cursor and others
{
"mcpServers": {
"turf": {
"command": "npx",
"args": ["-y", "@turfbuild/turf-mcp-server"],
"env": { "TF_VAR_region": "eu-west-1" }
}
}
}

With a Homebrew or script install the command is the server’s path, as command -v turf-mcp-server prints it, with no args. Restart your agent’s MCP connection after editing the entry. From the Turf™ CLI, the server has the environment of the shell you started turf in.

The env block reaches the server. An engine the server started takes only Turf’s own settings from it for its own environment. A variable a provider needs, such as AWS_PROFILE, goes in the same block with TURF_PROVIDER_ENV naming it, and the server sends it to the engine with each run: see Send a variable to providers.

The same env block can carry TURF_ACCEPT_EULA, where no one will run the accept command. Setting it to yes accepts the license terms at https://turf.build/license/v1/ for that server and an engine it starts: see Before the license is accepted.

  • TF_VAR_ values load on their own, below .tfvars files and var.
  • They set declared variables only. A TF_VAR_ for an undeclared variable is ignored.
  • A provider sees one only where its block references that variable.
  • The server applies it to every configuration it plans that declares the variable.

terraform.tfvars and terraform.tfvars.json, then *.auto.tfvars and *.auto.tfvars.json in one lexical pass, as in Terraform®. They live in the configuration directory, so never put a secret in one.

The configuration’s mise environment reaches providers in the engine. Variables are resolved in the server, so a TF_VAR_ in mise.toml or mise.local.toml sets no variable.

Lowest to highest, as in Terraform:

Source
1 the variable block’s default
2 TF_VAR_<name> from the server’s environment
3 terraform.tfvars, terraform.tfvars.json, then *.auto.tfvars and *.auto.tfvars.json
4 open’s var_file, in listed order, then open’s var
5 the plan command’s var_file, in listed order
6 the plan command’s var: wins

Differs from Terraform: within one call var always wins over var_file, with no -var and -var-file interleaving; open keeps its values for the workspace; nothing prompts for a value at plan.

Turf™ is a trademark of Turf LLC. Terraform® is a trademark of HashiCorp. Ansible® is a trademark of Red Hat, LLC, registered in the United States and other countries. Helm®, Kubernetes®, Prometheus® and OpenTelemetry® are registered trademarks, and Jaeger™ is a trademark, of the Linux Foundation. OpenTofu® and Model Context Protocol® are registered trademarks of LF Projects, LLC. All other trademarks are the property of their respective owners. Turf is not affiliated with, endorsed by, or sponsored by HashiCorp, IBM, Red Hat, the Linux Foundation, LF Projects or the OpenTofu project.

© 2026 Turf LLC. Free for individuals, education and small businesses within the Community limits, under the Turf Community Edition License 1.0. Government and larger organizations need a commerciallicense.turf.build · Discord ·GitHub