Let Claude read your Terraform configs, dry-run plans, and (opt-in) apply changes — without handing over your cloud keys.
tfmcp wraps the local Terraform CLI as an MCP server. It reads HCL, runs plan/validate/format, explores state, and — only when you explicitly enable TFMCP_ALLOW_DANGEROUS_OPS — can apply or destroy. Credentials stay in your existing AWS/GCP/Azure env; tfmcp never sees them directly.
Wann einsetzen: A PR changes 40+ resources and you want a sanity check on blast radius before approving.
Voraussetzungen
Terraform CLI installed and cloud credentials configured — aws configure or equivalent; tfmcp uses whatever your shell has
tfmcp installed via cargo — cargo install tfmcp
Ablauf
Point tfmcp at the Terraform directory
Set TERRAFORM_DIR to ~/work/infra/prod and run terraform plan. Summarize what's changing.✓ Kopiert
→ Clean plan summary with add/change/destroy counts
Ask for a risk-scored breakdown
For every resource being destroyed or replaced, rate the risk (low/med/high) and explain why. Flag anything stateful.✓ Kopiert
→ Risk table highlighting DB, queue, or data resources
Get a PR-ready review comment
Draft a PR review comment: approve, request changes, or block — with reasoning.✓ Kopiert
→ Actionable review text ready to paste
Ergebnis: A risk-aware plan review in 3 minutes instead of 30, with no keystrokes spent on apply.
Fallstricke
Plan succeeds locally but will fail in CI due to different provider versions — Make sure tfmcp's terraform version matches what your CI uses — pin via .terraform-version or tfenv
State is remote and tfmcp gets stuck on auth — Run terraform init once manually to cache backend creds before invoking tfmcp
👤 SREs auditing 'what changed outside of Terraform'⏱ ~20 minintermediate
Wann einsetzen: Monthly drift check, or when a cloud console change is suspected.
Ablauf
Run a plan against prod and look for changes
Run terraform plan against prod and tell me if there's drift — resources where the real state diverges from .tf.✓ Kopiert
→ List of drifted resources with diffs
Classify each drift
For each drift, say whether it's safe to refresh (reconcile Terraform to reality) or requires re-apply (reconcile reality to Terraform).✓ Kopiert
→ Two lists: refresh-candidates and re-apply-candidates
Ergebnis: A drift report with specific remediation plan per resource.
Fallstricke
Drift is normal for some auto-scaled or provider-managed fields — Add a drift-ignore list (via ignore_changes lifecycle block) for known-noisy fields like last_modified timestamps
Understand an unfamiliar Terraform module
👤 New team members dropped into a 500-file terraform repo⏱ ~15 minbeginner
Wann einsetzen: You inherited an infra repo and need a map of what's there before touching anything.
Ablauf
Scan the directory
List every module in ~/work/infra. For each, tell me what resources it manages and what inputs it expects.✓ Kopiert
→ Module inventory with purpose and inputs per module
Generate a dependency graph
Run terraform graph and describe the module dependency tree — which modules depend on which.✓ Kopiert
→ Clear ASCII tree or numbered list
Ergebnis: A mental map of the repo without having to read every .tf file by hand.
Fallstricke
Some modules are unused dead code — Ask tfmcp to flag modules referenced nowhere in the root or any other module