State backend, registries and mirrors
The state backend is the MCP server’s business, so its credentials go in the server’s environment.
Registry tokens and provider mirrors are read by both processes: the server for init, the engine
for each plan’s installs. Set them once where both can see them.
The state backend
Section titled “The state backend”The server reads and writes state, so a backend (S3, azurerm, gcs, remote) authenticates with the
server’s environment, plus open’s backend_config.
- Keep the backend’s non-secret settings in the
backendblock, so a reopen needs nothing but credentials. - Put a secret in
open’sbackend_config, never in the block. - Set the backend’s environment in your MCP client’s
envblock, beside anyTF_VAR_. Providers see none of it unlessTURF_PROVIDER_ENVnames it: see Send a variable to providers.
{ "mcpServers": { "turf": { "command": "npx", "args": ["-y", "@turfbuild/turf-mcp-server"], "env": { "AWS_PROFILE": "tfstate" } } }}With a Homebrew or script install the command is the server’s path, as command -v turf-mcp-server prints
it, with no args. This AWS_PROFILE is the backend’s alone, unless TURF_PROVIDER_ENV also names
it. When the backend and the providers need different profiles, send the providers’ as a fixed value,
"TURF_PROVIDER_ENV": "AWS_PROFILE=prod", or set the provider’s profile argument.
Registry and remote backend tokens
Section titled “Registry and remote backend tokens”A private module or provider registry, and the remote backend (HashiCorp’s hosted or self-managed platform, Scalr),
authenticate with a token for their host. Two ways:
turf login <host>, the simplest. Liketofu login, it writes the token to~/.terraform.d/credentials.tfrc.json, which the server and the engine both read. A co-installedtofuorterraformreads it too.turf loginis a command of theturfCLI, which comes with Homebrew or the script; the npx install does not carry it.TF_TOKEN_<host>, with the host’s dots as underscores (TF_TOKEN_app_terraform_io). It works per process: the server’s environment for theremotebackend andinit’s installs, the engine’s own for the installs a plan makes. Set it in both, or use the credentials file. An engine the server started gets noTF_TOKEN_variable, so for its installs the token must be in the credentials file. Naming it inTURF_PROVIDER_ENVdoes not help: the variables the server sends reach providers, not the engine’s own installs.
turf login app.terraform.ioecho "$TFE_TOKEN" | turf login --token-stdin tfe.example.com # in CIA TF_TOKEN_<host> variable wins over the credentials file, and turf login warns when the token it
is about to write would be shadowed by one. turf logout <host> forgets the token locally; it does not
revoke it on the host.
Two limits beside tofu login: a credentials block hand-written in .tofurc or .terraformrc
silently keeps winning over the file turf login writes, and credentials helpers are not supported.
Provider mirrors
Section titled “Provider mirrors”A provider mirror, or an air-gapped network, is a provider_installation block in the OpenTofu® CLI
configuration, exactly as tofu reads it: ~/.tofurc with ~/.terraform.d/*.tfrc, or the one file
TF_CLI_CONFIG_FILE names. It takes filesystem_mirror, network_mirror or oci_mirror, then
direct for the rest. Mirrors belong here, never in the .tf files.
provider_installation { network_mirror { url = "https://mirror.example.com/providers/" include = ["registry.opentofu.org/hashicorp/*"] } direct { exclude = ["registry.opentofu.org/hashicorp/*"] }}A filesystem_mirror takes a path; make it absolute, since the engine has no working directory of
yours. Air-gapped installation covers the rest of a network with no
route to the internet.
The server and the engine must read the same block. The server reads it for init and
provider_describe, the engine for a plan’s installs, and the engine checks what init locked.
- For an engine the server started, use
~/.tofurc, or setTF_CLI_CONFIG_FILEin your agent’s server definition: the server hands it to the engine it starts. - For the Homebrew service, use
~/.tofurc, or setTF_CLI_CONFIG_FILEinturf.envand in your agent’s server definition. - In a cluster, mount one ConfigMap on both.
Each reads it once, at start. After an edit, restart both:
turf-mcp-server engine stop # an engine the server started; the next call starts it againbrew services restart turf # the Homebrew service# then restart your agent's MCP connectionWith the npx install, the first line is npx -y @turfbuild/turf-mcp-server engine stop.
A CLI configuration in error stops either process from starting, where tofu warns and carries on.
Turf™ stops because carrying on would install from the public registry what you meant to take from
your mirror.
A provider the engine’s block does not serve fails the plan in the OpenTofu wording: “was not found in any
of the search locations”, a registry that “does not have a provider named” it, or a version that “is
not available for” the engine’s platform, as from a mirror filled on another machine. The fix is the
engine’s CLI configuration or the mirror it names, then a restart of the engine. Another up before
that fails the same way.
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