MCP Directory

tfmcp

Terraform MCP server letting AI assistants read, plan, apply, analyze, and manage Terraform infrastructure.

Unverified
stdio (local)
No auth
Rust

Add to your client

Copy the config for your MCP client and paste it into its config file.

Install / run
cargo install tfmcp

Paste into ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "tfmcp": {
      "command": "/path/to/your/tfmcp",
      "args": [
        "mcp"
      ],
      "env": {
        "HOME": "/Users/yourusername",
        "PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
        "TERRAFORM_DIR": "/path/to/your/terraform/project"
      }
    }
  }
}

Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf

Before you start

  • Rust (edition 2021; v0.1.9 requires Rust 1.85.0+ / Edition 2024)
  • Terraform CLI installed and available in PATH
  • Claude Desktop (for AI assistant integration)
  • Docker (optional, for containerized deployment)

About tfmcp

tfmcp is a Rust CLI and MCP server that gives AI assistants safe, structured access to Terraform. Launched via tfmcp mcp, it integrates with Claude Desktop over stdio and exposes 31 tools for reading configs, generating and analyzing plans, applying/destroying infrastructure, managing state and workspaces, formatting and graphing code, analyzing module health, and searching the Terraform registry. It ships with enterprise security controls (dangerous ops disabled by default, resource limits, sensitive-path blocking, audit logging) and can automatically scaffold a sample Terraform project so new users can start immediately.

Tools & capabilities (31)

init_terraform

Initialize Terraform working directory.

get_terraform_plan

Generate and show execution plan.

analyze_plan

Analyze plan with risk scoring and recommendations.

apply_terraform

Apply Terraform configuration.

destroy_terraform

Destroy Terraform-managed infrastructure.

validate_terraform

Validate configuration syntax.

validate_terraform_detailed

Detailed validation with guidelines.

get_terraform_state

Show current state.

analyze_state

Analyze state with drift detection.

list_terraform_resources

List all managed resources.

set_terraform_directory

Change active project directory.

terraform_workspace

Manage workspaces (list, show, new, select, delete).

terraform_import

Import existing resources.

terraform_taint

Taint/untaint resources.

terraform_refresh

Refresh state.

terraform_fmt

Format code.

terraform_graph

Generate dependency graph.

terraform_output

Get output values.

terraform_providers

Get provider info with lock file.

analyze_terraform

Analyze configuration.

analyze_module_health

Module health with cohesion/coupling metrics.

get_resource_dependency_graph

Resource dependencies visualization.

suggest_module_refactoring

Refactoring suggestions.

get_security_status

Security scan with secret detection.

search_terraform_providers

Search providers.

get_provider_info

Provider details.

get_provider_docs

Provider documentation.

search_terraform_modules

Search modules.

get_module_details

Module details.

get_latest_module_version

Latest module version.

get_latest_provider_version

Latest provider version.

What this server can do

tfmcp provides tools for these capabilities — tap one to see every MCP server that does the same:

When to use it

  • Let an AI assistant read and explain existing Terraform configurations.
  • Generate a Terraform plan and get AI-driven risk scoring and recommendations before applying.
  • Apply or destroy infrastructure through Claude Desktop with safety guardrails and audit logging.
  • Inspect and manage Terraform state and workspaces, including drift detection.
  • Analyze module health (cohesion/coupling) and get refactoring suggestions.
  • Search the Terraform registry for providers and modules and fetch their docs and latest versions.

Security notes

Dangerous operations (apply/destroy) are disabled by default and must be explicitly enabled via TFMCP_ALLOW_DANGEROUS_OPS=true. Auto-approve is off by default (TFMCP_ALLOW_AUTO_APPROVE). Resource count is capped (TFMCP_MAX_RESOURCES, default 50). Built-in access controls block prod*, production*, and secret* file patterns. Audit logging is enabled by default and written to ~/.tfmcp/audit.log. Always review AI-generated Terraform plans before applying, and apply appropriate IAM boundaries in cloud environments.

tfmcp FAQ

Is tfmcp an official Terraform/HashiCorp product?

No. It is an independent open-source project by nwiizo, licensed under MIT. The README notes it is experimental and under active development.

How do I connect tfmcp to Claude Desktop?

Install it (`cargo install tfmcp`), find the binary path with `which tfmcp`, then add an mcpServers entry to ~/Library/Application Support/Claude/claude_desktop_config.json with command set to the tfmcp path and args set to ["mcp"]. Restart Claude Desktop and enable the tool.

Are apply and destroy operations safe?

By default they are disabled. You must set TFMCP_ALLOW_DANGEROUS_OPS=true to enable them, and TFMCP_ALLOW_AUTO_APPROVE remains false unless explicitly enabled. tfmcp also caps resource counts and blocks sensitive file patterns.

Can I run tfmcp with Docker?

Yes. Build the image with `docker build -t tfmcp .`, then point Claude Desktop's command at "docker" with args ["run", "--rm", "-v", "/path/to/your/terraform:/app/terraform", "tfmcp", "mcp"].

Alternatives to tfmcp

Compare all alternatives →

GitHub's official server for repos, issues, PRs, and Actions — local Docker or hosted remote.

Featured
Verified
stdio (local)
API key
Go
7 tools
Updated 7 days agoRepo

Official AWS Labs server that lets agents call any AWS API via the AWS CLI surface.

Verified
stdio (local)
API key
Python
3 tools
Updated 9 days agoRepo

Bulk Kubernetes port forwarding with an MCP server that lets AI assistants forward services, inspect pods, and monitor traffic.

Unverified
stdio (local)
No auth
Go
28 tools
Updated 1 day agoRepo