# @yawlabs/terraform-cwd-mcp [Health: Active]

**Category:** ☁️ Cloud Platforms  
**Repository:** https://github.com/YawLabs/terraform-cwd-mcp  
**GitHub Stars:** 1  
**npm Downloads (last month):** 1397  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/yawlabs-terraform-cwd-mcp

## Description
Terraform MCP server for what is true in THIS working directory: exact pinned provider schemas, saved plans, state (redacted), local modules and provider-upgrade impact

## Tools
Capabilities this server exposes over MCP:

- **tf_list_providers** — 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).
- **tf_search_types** — Find resource / data source / ephemeral resource type names containing `query` (e.g. 's3_bucket') in the pinned providers. kind: resource | data | ephemeral.
- **tf_get_schema** — 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.
- **tf_check_arguments** — 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.
- **tf_summarize_plan** — 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 `terraform plan -out`, rendered with `terraform show -json` in dir, or a plan JSON file) or plan_json (e.g. from the official terraform MCP server's get_plan_json_output(plan_id) for an HCP run; get the plan id from its get_run_details). Prints no values: sensitive paths are truncated, import IDs omitted.
- **tf_module_interface** — 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_addresses** — List resource instance addresses in the current Terraform state (terraform state list), optionally filtered. Read-only: never locks, never refreshes. With a remote backend this reads S3/GCS/HCP using the server's credentials; a non-default workspace that does not exist is refused (reading it would create it).
- **tf_show_resource** — Show one resource instance's attribute values from the current Terraform state (terraform show -json). Read-only: never locks, never refreshes. Sensitive values are redacted: Terraform's own markers, plus values equal to a marked one, secret-like names and secret-shaped strings; a footer says what was hidden and why.
- **tf_upgrade_impact** — 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. Downloads the target provider from the registry into a cache (temp dirs only; never touches dir). For the latest version number or upgrade guides, use the official terraform MCP server.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "terraform-cwd-mcp": {
    "command": "npx",
    "args": ["-y","@yawlabs/terraform-cwd-mcp@latest"]
  }
}
```

## Documentation

## What @yawlabs/terraform-cwd-mcp does

@yawlabs/terraform-cwd-mcp exposes Terraform working-directory inspection through MCP. Its primary source of schema information is `terraform providers schema -json` from the root module, with provider versions tied to `.terraform.lock.hcl` rather than the latest registry documentation.

The server covers provider types, argument paths, saved plans, module interfaces, state addresses, individual resource values, and provider upgrade effects. It is intended for agents that need repository-specific Terraform facts before editing configuration. The server complements, rather than replaces, HashiCorp's official Terraform MCP server: the official server covers usage documentation, current versions, registry modules, and HCP/TFE runs, while this server focuses on the checked-out working directory.

## How it works

Each tool accepts an optional `dir` identifying the root module. Provider discovery should begin with `tf_list_providers`, followed by type search and schema inspection when an agent needs to write or modify a resource, data source, or ephemeral block.

Schema dumps are cached in memory and on disk using the root path and lock-file contents as the cache key. Changing the lock file therefore invalidates the cached provider data. Terraform is launched directly rather than through a shell, and output is streamed for use across macOS, Linux, and Windows.

The server does not run `terraform init` in the working directory. State tools invoke `terraform state list` and `terraform show -json`; they do not refresh state or acquire a state lock. Remote backends may still be contacted using credentials available to the MCP client. Terraform child processes receive `CHECKPOINT_DISABLE=1`.

Provider upgrade analysis is isolated in a temporary directory. The target provider is installed into a plugin cache, then a temporary configuration copy is validated. The root state and `*.tfvars` files are not copied.

## Setup and configuration

Install the package through an MCP client using the command `npx -y @yawlabs/terraform-cwd-mcp`. The working directory supplied to a tool should contain the Terraform root module and its initialized provider data; an uninitialized directory produces an actionable error instead of triggering initialization.

For upgrade analysis, the plugin cache can be selected with `TERRAFORM_CWD_MCP_PLUGIN_CACHE`. If it is unset, the server uses `TF_PLUGIN_CACHE_DIR`, followed by a cache location under the user's cache directory. Upgrade installation calls are serialized because the plugin cache is not safe for concurrent installs.

## Tools and capabilities

- `tf_list_providers` reports root-module providers, pinned versions, and resource, data, and ephemeral counts.
- `tf_search_types`, `tf_get_schema`, and `tf_check_arguments` locate types, render their arguments and nested blocks, and classify dotted paths as valid, computed-only, deprecated, unknown, or attribute-versus-block mismatches.
- `tf_summarize_plan` reads a binary plan, plan JSON, or JSON text and prioritizes deletes and replacements, including replacement causes. It also reports updates, creates, imports, moves, forgets, drift, deferred changes, outputs, counts, and destroy warnings without printing values.
- `tf_module_interface` describes variables, outputs, and module calls for root, local, or installed modules, including type expressions, defaults, sensitivity, nullability, ephemeral status, and validation counts.
- `tf_state_addresses` lists state instances with filtering and ID lookup. `tf_show_resource` displays one instance with sensitive and secret-like values redacted.
- `tf_upgrade_impact` compares a pinned provider with an exact target version, identifies affected configuration usage and constraints, and confirms findings with validation in a temporary copy.

## Limitations and notes

State redaction has no option to reveal sensitive values. It covers Terraform-sensitive values, values derived from marked secrets in state, secret-like keys, and recognizable token or private-key formats; some unmarked derived values may remain visible. Selecting a nonexistent non-default workspace is refused to avoid creating an empty remote state. The server never writes the root module, its `.terraform` directory, lock file, or state.

_Full upstream README: https://allmcps.com/mcp/yawlabs-terraform-cwd-mcp/readme_

