Credentials Reference
Three things need credentials, and each reads them from a different place. Get this right before blaming a provider.
| What | Runs in | Reads credentials from |
|---|---|---|
| Providers (AWS, Azure, GCP, Kubernetes, …) | the engine | the engine’s own environment, then the variables this server sends by name (the provider environment, TURF_PROVIDER_ENV), then the configuration directory’s mise environment, each over the one before; provider arguments in HCL override all three |
Variables (var, var_file, TF_VAR_<name>) |
this server | the tool calls — open’s, kept for the workspace, under each plan command’s own — and this server’s environment (the MCP client’s env block) for TF_VAR_; never mise |
The state backend (S3, azurerm, gcs, remote) |
this server | this server’s environment, plus open’s backend_config |
State encryption (the terraform { encryption {} } block, TF_ENCRYPTION) |
this server | the block’s var.* through open’s var (every tool reads the state with it); TF_ENCRYPTION and a key provider’s own credentials (aws_kms, gcp_kms, openbao) from this server’s environment — never mise |
Providers
Section titled “Providers”Providers run in the engine, not in this server. A plugin never gets your shell’s or the agent session’s whole environment: it gets the engine’s own, and of this server’s only the variables the provider environment names.
A provider that finds no credentials usually wants a variable (AWS_PROFILE, KUBECONFIG, GOOGLE_APPLICATION_CREDENTIALS) that the user’s shell or client holds and nothing has named for the providers:
-
Call
status. When this server declares a provider environment it carriesprovider_env:names, the variables a convergence started now would send, andunset, the declared ones this server’s environment does not hold. Noprovider_envkey: none is declared. Names only; no tool shows a value. -
The fix is the user’s, in the MCP client’s entry for this server: two lines in its
envblock, the variable andTURF_PROVIDER_ENVnaming it."env": {"AWS_PROFILE": "prod","TURF_PROVIDER_ENV": "AWS_PROFILE"}Then the user restarts the client, so that it starts this server again: the list is read when this server starts.
-
Run
upagain. The variables go with the start, and every result of the convergence names them inprovider_env_names.
When names already holds the variable, the provider got it: look at what the value names where the engine runs (a profile, a file’s path), and at the layers that win over it, below. A command that is not found is never fixed this way, since PATH is not sent: it is layer 1’s or layer 3’s.
A plugin’s environment is three layers, a later one winning over an earlier, and provider arguments over all of them:
- The engine’s own environment. A local engine this server started (the default;
turf-mcp-server engine statussays “started on demand”) has a small fixed one:HOME,USER,LOGNAME,SHELL,TMPDIR, theTURF_*settings,DO_NOT_TRACK,CI,TF_PLUGIN_CACHE_DIR,TF_CLI_CONFIG_FILE, and aPATHof Homebrew’s and the system’s directories (/opt/homebrew/bin,/usr/local/bin,/home/linuxbrew/.linuxbrew/bin,/usr/bin,/bin, and theirsbins). Nothing else of the session or theenvblock is in it. Credentials in their usual files —~/.aws/config’s default profile,~/.kube/config, gcloud’s application-default credentials, theazlogin — are read there as anywhere. A user who needs more in it (a proxy for everything the engine runs, say) runs theturfHomebrew service instead (brew services start turf): its environment is launchd’s, the HomebrewPATH, and~/.homebrew/services/turf.env, which takes effect afterbrew services restart turf(a paused convergence waits through the restart). Run asturf-mcp-server engine runin a terminal, it is that terminal’s; an engineTURF_RESTATE_URLnames has whatever its deployment gives it. - The provider environment, sent by this server. Declared where this server is launched:
TURF_PROVIDER_ENVin its environment (comma-separated, so a value there ends at the next comma; one that holds a comma goes on the flag), then--provider-envon its command line (repeatable), a later entry for a name winning. An entry isNAME(this server’s value of it; nothing when it is unset, andstatuslists it underunset),NAME=VALUE(that value, whatever this server holds) orPREFIX_*(every variable of this server’s under the prefix, asAWS_*). Nothing is sent unless named.- Never sent:
PATH, and the other variables the engine keeps its own (home and shell variables, the dynamic loader’s,TURF_*, CI markers and the like). An entry that names one (or a pattern wholly under such a prefix, asTURF_*), a bare*or a malformed entry stops this server at start, the error naming the entry’s position and never a value; a wider pattern that merely matches one (CI_*) leaves it out. - Read at each start, fixed for the convergence. The values are this server’s when a convergence starts (
up,destroy,refresh,import,invoke,applyof a planfile) and hold for every round’s plan and apply, as itsvarvalues do. A planfile applied later runs with the applying server’s values, not the planner’s. - Bounded: 64 variables and 16 KiB in all, judged when this server starts and again at each start. Over either, the server stops or the start fails, with an error that names no value.
- Any engine: the local one however it was started, and one
TURF_RESTATE_URLnames. A value that is a file’s path names a file where the engine runs, which for a remote engine is another machine. An engine too old to take the provider environment is refused, not run with its own credentials: the start fails, saying so, and the fix is the engine’s upgrade. - Kept by the engine, in its store, with the convergence. After a converged
upthey stay with the workspace’s standing seal, so a drift check that runs with nobody attached reads with the last convergedup’s values (references/drift.md). Arefresh,importorinvokedoes not replace them: after changing a credential, it is the next convergedupthat hands unattended reads the new value. - A secret’s place is the profile or credential store a variable names. One that must be sent goes in the client’s
envblock by name:--provider-env NAME=VALUEshows in the process list. Over--transport httpevery client of one server gets that server’s values. - Not reached: the engine’s own installs of modules and providers, and a launch that only reads a provider’s schema, which run on layer 1 alone (Registries, below).
- Never sent:
- The configuration directory’s mise environment, applied over both. On an engine with mise installed, each round’s providers launch with what
mise envadds in the configuration directory, asterraformwould in a shell with mise active there:mise.toml(committed: tool versions, a Python venv,[env]) andmise.local.toml(per machine, kept out of git). This is the place for a configuration’s own credential settings — anAWS_PROFILE, aKUBECONFIGpath — and the tools its providers run; a secret’s value belongs in the profile or credential store it names, not in a committed file. mise is evaluated over the engine’s environment alone, so a template in it cannot read a variable this server sent. A directory the user has not runmise truston fails the plan in mise’s words. A toolmise installhas not installed is missing, and the provider says so. The engine never installs anything: setup is the user’s. - Provider arguments in HCL (
profile,assume_role,config_path) override the environment: the way to pin an account in the configuration itself. A secret there arrives through a variable, never a literal.
Common names: AWS AWS_PROFILE, AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY, AWS_REGION; Azure ARM_SUBSCRIPTION_ID, ARM_CLIENT_ID, ARM_CLIENT_SECRET, ARM_TENANT_ID; GCP GOOGLE_APPLICATION_CREDENTIALS, GOOGLE_PROJECT.
With the credentials in the environment a plugin gets, a default provider instance needs no block at all. Aliased instances need their own blocks for what differs.
Plugins run with the configuration directory as their working directory, so a relative path a provider resolves (a kubeconfig it writes) lands there, as with Terraform run from that directory.
Modules install twice. init installs under this server’s data directory — the configuration’s .terraform, or TF_DATA_DIR relative to the configuration as tofu resolves it — and reports it as data_dir; an absolute TF_DATA_DIR is one directory for every configuration, so init refuses a second configuration on it. The engine installs under a data directory of its own, one per workspace (<data-dir>/<lineage>/modules, the lineage being the workspace’s state lineage as open reports it; turf-engine --data-dir, default the engine’s per-user cache beside its plugin cache; the local engine’s is its stack directory’s data, ~/.turf/engine/data), which no plan names and TF_DATA_DIR does not move: the engine writes nothing into a configuration. A configuration directory nothing may write (one mounted from an image) therefore plans when this server’s TF_DATA_DIR names a directory init can write, given its lock file committed complete and its state elsewhere (a remote backend, or a statefile outside the configuration); the engine needs nothing set, and a provider that writes into its working directory still fails there, as under tofu. path.module of a module the engine installed is that directory’s absolute path, as tofu spells it under an absolute TF_DATA_DIR.
Relative paths resolve as under tofu -chdir: from the configuration directory with its symlinks resolved, so a module source = "../modules/x", a file("../x") and a relative statefile path all reach beside the directory the link points to. Differs from Terraform: path.cwd is the configuration directory as written, the link unresolved, where tofu -chdir answers the directory tofu was launched from (references/divergences.md).
The engine reads each configuration itself. The local engine, and any engine that mounts the configuration at the same path as this server, needs nothing set: it reads the path this server names. Only when an engine of your own mounts it elsewhere — a pod — set this server’s --workdir and turf-engine --workdir, both or neither, to the directories holding the same layout: the engine is told the configuration’s path below this server’s and reads it below its own. Mount the configuration, and everything it reaches by a relative path, the same way under both. init then refuses a configuration outside --workdir, and the server refuses --workdir against the local engine.
Registries
Section titled “Registries”A private module or provider registry, and the remote backend, authenticate with a token for their host:
tofu login <host>(the Turf CLI’sturf login <host>does the same) writes it to~/.terraform.d/credentials.tfrc.json, which this server and the engine both read — the simplest way.TF_TOKEN_<host>(dots as underscores) works in a process’s environment: this server’s for theremotebackend andinit’s installs, the engine’s own for the installs a plan makes, which the provider environment does not reach. Set it in both, or use the credentials file; a local engine this server started gets noTF_TOKEN_*, so there it is the credentials file.
A provider mirror, or an air-gapped network, is a provider_installation block in the OpenTofu CLI configuration (~/.tofurc with ~/.terraform.d/*.tfrc, or the one file TF_CLI_CONFIG_FILE names), exactly as tofu reads it: filesystem_mirror, network_mirror or oci_mirror, then direct for the rest. This server reads it for init and provider_describe, the engine for a plan’s installs, and both must read the same block, since the engine checks what init locked: set it in both environments (a local engine this server started reads ~/.tofurc too and is handed this server’s TF_CLI_CONFIG_FILE; for the Homebrew service, ~/.tofurc or TF_CLI_CONFIG_FILE in turf.env; in a cluster, one ConfigMap mounted on both). Each reads it once, at start, so restart both after an edit. A configuration in error stops either from starting, where tofu warns and carries on. A provider the engine’s block does not serve fails the plan in the words of OpenTofu (“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), as init fails. Tell the user: the fix is the engine’s CLI configuration or the mirror it names, then a restart of the engine, and another up before that fails the same way.
Variables
Section titled “Variables”open’s var and var_file are kept for the workspace while it is open, in this server’s memory only (status lists the names, never the values): every tool on the workspace derives its backend and reads its state with them, and each plan command lays its own var and var_file over them, name by name. A plan command’s values hold for that convergence and are never kept. Nothing is persisted: after a restart, open the workspace again with the same values.
TF_VAR_<name> come from this server’s environment — set in the MCP client’s server definition — and load on their own, below .tfvars files and var. They set declared variables only: a provider sees one only where its block references that variable. Prefer var for a value the user gives you in conversation, and var_file naming a file for a secret the user keeps in one: you never need to read it.
State encryption
Section titled “State encryption”A configuration’s terraform { encryption {} } block (the OpenTofu one: key providers, methods, the state target with enforced and fallback) is honoured where the statefile is read and written — this server, never the engine. TF_ENCRYPTION in this server’s environment merges over the block, setting by setting, as tofu merges it, and never leaves this server. The engine’s own records and plan documents are plaintext in its store, as they are for any configuration; what the block protects is the backend’s store.
Give the passphrase or key a block reads through var.* to open, as var — or var_file naming the file that holds it — once: the workspace keeps it, and every tool reads the state with it (state_list, output, show, taint, cancel, apply taking a convergence up again, and each plan command beneath its own var). Given to a plan command alone, it serves that convergence only, and the read tools cannot decrypt; open warns when it cannot build the encryption, and a plan command given values on such a workspace says so. delete and list take their own var. Declare the variable sensitive = true, or ephemeral = true to keep it out of the plan document as well (OpenTofu accepts either in a key provider, neither in a backend block).
TF_ENCRYPTION in this server’s environment configures the encryption there, merged over the block, and never leaves this server — the place for a key provider configured wholly outside the configuration. A passphrase in TF_VAR_ works too, but it then reaches every configuration this server plans. The key provider’s own credentials (an aws_kms key, an openbao token) come from this server’s environment, as a backend’s do.
To encrypt an existing plaintext statefile, declare method "unencrypted" "plain" {} and fallback { method = method.unencrypted.plain } under state, run up once (the file is rewritten encrypted when the convergence applies, as tofu apply writes it — a declined plan writes nothing), then remove the fallback and add enforced = true. An encrypted statefile met by a configuration that no longer declares encryption, or by the wrong passphrase, is refused at open and up in the words of OpenTofu, with the directory named.
Long-running applies
Section titled “Long-running applies”Some resources block during apply while the provider waits for the world to catch up. helm_release defaults to wait = true with timeout = 300: a release whose pods cannot become Ready — most often an image that will not pull — hangs for the full timeout, then fails with a bare “timed out waiting for the condition”. That is not a Turf or cluster fault.
- Pick charts whose images pull. Avoid
bitnami/*charts: Bitnami retired its public catalog in August 2025, and those pods sit inImagePullBackOff.podinfo(https://stefanprodan.github.io/podinfo) is a small, reliable choice. - Diagnose a stuck apply out of band:
kubectl get pods -n <namespace>. - Bound the wait on the resource: a lower
timeout, orwait = false.
Every convergence call returns within the server’s deadline (55 s unless whoever launched the server set another): an apply still applying at the deadline returns outcome applying with ended: false, and its next names the call that follows it — apply with the same convergence_id. The convergence goes on in the engine meanwhile. A provider call in progress cannot be cancelled: cancel takes effect between changes.
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