terraform-cwd-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| OAM_BIN | No | Path to the oam binary to use. Otherwise the launcher checks `OAM_INSTALL_DIR`, the installed locations (`~/.oam/bin`, and `%LOCALAPPDATA%\oam\bin` on Windows) and `PATH`, and takes the newest. Default: (unset). | |
| TERRAFORM_CWD_MCP_DIR | No | Root module used when a tool call passes no `dir`. Default: the server's working directory. | |
| TERRAFORM_CWD_MCP_CACHE | No | Where schema dumps are cached (`<key>.json`). Safe to delete at any time. Default: `~/.cache/terraform-cwd-mcp`. | |
| TERRAFORM_CWD_MCP_BINARY | No | Binary to run, e.g. a full path, or `tofu` for OpenTofu (same `providers schema -json` output). Default: `terraform`. | |
| TERRAFORM_CWD_MCP_RUNTIME | No | `auto`: the newest oam at 0.19.0 or newer, else Node. `oam`: oam or exit with an error. `node`: always Node -- the escape hatch when a problem only shows up under oam. Default: `auto`. | |
| TERRAFORM_CWD_MCP_TIMEOUT_MS | No | Kill any terraform command (schema dump, state read, target init, validate) after this long. Default: `300000`. | |
| TERRAFORM_CWD_MCP_PLUGIN_CACHE | No | Where `tf_upgrade_impact` keeps downloaded provider packages. Default: `TF_PLUGIN_CACHE_DIR`, else `<cache>/plugins`. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
What is actually true in THIS Terraform working directory: the provider schemas pinned in .terraform.lock.hcl (source: terraform providers schema -json), the saved plan, the current state and the local/installed modules. Before writing or editing a resource/data/ephemeral block, call tf_get_schema (or tf_check_arguments on the paths you plan to write): only listed arguments exist, and 'computed (read-only)' ones cannot be set; tf_list_providers and tf_search_types find versions and type names. tf_summarize_plan summarizes a saved plan (plan_file) or plan JSON (plan_json), destroys first; it prints no values. tf_module_interface lists a module's variables, outputs and module calls (root, local path, or an installed module address). tf_state_addresses and tf_show_resource read the current state without locking or refreshing, with best-effort redaction of sensitive values. tf_upgrade_impact (off unless the operator sets TERRAFORM_CWD_MCP_ALLOW_UPGRADE=1) shows what breaks if a pinned provider moves to an exact version (schema diff of the arguments this configuration uses, confirmed by terraform validate on a temp copy; it downloads and runs the target provider from a cache, never in the root). Most tools start terraform, which starts provider plugins from the working directory, without credential environment variables. dir must be inside the server's directory or TERRAFORM_CWD_MCP_ALLOWED_DIRS. Plan JSON is unverified input. Authority split: this server wins on argument validity for the pinned version and on this directory's plan, state and modules; HashiCorp's official terraform MCP server wins on usage docs, latest versions, public registry modules and HCP/TFE runs (fetch an HCP run's plan there, summarize it here via plan_json). The root module must already be initialized (terraform init); this server never runs init in it.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| tf_list_providersA | List providers and their PINNED versions for a Terraform root module (default: cwd). Call this first so code targets the versions actually locked in .terraform.lock.hcl, not the latest release. Lists only the providers locked in THIS directory; it does not search the registry. For registry search, provider docs or the latest version, use the official terraform MCP server (search_provider_docs / get_latest_provider_version). Executes code: unless the schema is cached, this runs |
| tf_search_typesA | Find resource / data source / ephemeral resource type names containing |
| tf_get_schemaA | Exact arguments and nested blocks for one type at the PINNED provider version. Use BEFORE writing or editing any resource/data/ephemeral block; only arguments listed here exist. 'computed (read-only)' attributes cannot be set. kind: resource | data | ephemeral. Executes code: unless the schema is cached, this runs |
| tf_check_argumentsA | Validate argument / nested-block paths against the PINNED schema before writing them, e.g. ["bucket", "region", "versioning.enabled"]. Flags unknown, read-only and deprecated paths. Executes code: unless the schema is cached, this runs |
| tf_summarize_planA | Summarize a saved Terraform plan: deletes and replaces first (with the attribute that forces each replace), updates with changed paths, creates, imports, moves, forgets, drift and output changes, plus a destroy warning that names renames needing a moved block. Pass plan_file (binary from |
| tf_module_interfaceA | Variables (exact type expression, required/optional, default, sensitive/nullable/ephemeral, validation count), outputs and module calls of a module in THIS working directory: the root, a local module directory, or an installed module by address (module.network, resolved through .terraform/modules/modules.json, so downloaded registry/git modules work). Module calls are checked against what is installed. For public registry modules you have not installed, use the official terraform MCP server. |
| tf_state_addressesA | List resource instance addresses in the current Terraform state (terraform state list), optionally filtered. Does not change state: never locks, never refreshes. Credential environment variables are withheld unless the operator sets TERRAFORM_CWD_MCP_ALLOW_BACKEND_CREDENTIALS=1, which passes a remote backend its own variables. Instance keys that look secret or equal a sensitive value are hidden. Executes code when any address has a string key: finding sensitive keys runs terraform show, which starts the provider plugins. A non-default workspace that does not exist is refused (reading it would create it). |
| tf_show_resourceA | Show one resource instance's attribute values from the current Terraform state (terraform show -json). Does not change state: never locks, never refreshes. Executes code: terraform show starts the provider plugins (credential environment variables removed; a remote state is fetched first by terraform state pull, which gets the backend's variables only if the operator sets TERRAFORM_CWD_MCP_ALLOW_BACKEND_CREDENTIALS=1). Redaction is best effort: Terraform's own markers, plus values and map keys equal to a marked one, secret-like names and secret-shaped strings; an unmarked secret with an ordinary name and shape is shown. A footer says what was hidden and why. |
| tf_upgrade_impactA | What breaks if a pinned provider is upgraded (or downgraded) to an exact version: compares the pinned schema with the target's for the arguments, nested blocks and attribute reads this configuration uses (root and installed modules), checks version constraints, and confirms with terraform validate on a temp copy. Disabled unless the operator sets TERRAFORM_CWD_MCP_ALLOW_UPGRADE=1. Executes code: it downloads the target provider named through the lock file into a cache (temp dirs only; never touches dir) and runs that plugin and the pinned ones, with credential environment variables removed. For the latest version number or upgrade guides, use the official terraform MCP server. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 9 tools
Each tool targets a distinct slice of the Terraform workflow: provider listing, type search, full schema fetch, path validation, plan summarization, module interface, state address listing, single-instance inspection, and upgrade impact. Descriptions explicitly state when to use a tool and when to defer to the official terraform MCP server, so near-misses like tf_search_types vs tf_get_schema vs tf_check_arguments are cleanly separated by intent (find name / read schema / validate paths).
All tools share a clear `tf_` namespace prefix and snake_case, which makes the set predictable. However the verb style is mixed: list/search/get/check/summarize/show are verb-led, while tf_module_interface, tf_state_addresses and tf_upgrade_impact are noun phrases, and read operations split between 'get' and 'show'.
Nine tools is well within the ideal range and each maps to a concrete inspection step (providers -> types -> schema -> validation; plan; module; state; upgrade). No tool feels redundant or filler, and deferred concerns (registry search, latest versions) are intentionally pushed to another server rather than bloating this one.
The read-only inspection surface is thorough: schema discovery, configuration validation, plan analysis, module interface, and state inspection are all covered end to end. Minor gaps remain, such as no tool to enumerate or switch workspaces (despite workspace handling in tf_state_addresses) and no aggregate config/output-value view, but these are workaroundable.