Terraform MCP

v1.0.0โ€ขDeveloper Toolsโ€ขstable

๐ŸŒ Terraform Model Context Protocol (MCP) Tool - An experimental CLI tool that enables AI assistants to manage and operate Terraform environments. Supports reading Terraform configurations, analyzing plans, applying configurations, and managing state

mcpmcp-serverterraform
Share:
364
Stars
0
Downloads
0
Weekly
0/5

What is Terraform MCP?

Terraform MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to ๐ŸŒ terraform model context protocol (mcp) tool - an experimental cli tool that enables ai assistants to manage and operate terraform environments. supports reading terraform configurations, analyzing ...

๐ŸŒ Terraform Model Context Protocol (MCP) Tool - An experimental CLI tool that enables AI assistants to manage and operate Terraform environments. Supports reading Terraform configurations, analyzing plans, applying configurations, and managing state

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • ๐ŸŒ Terraform Model Context Protocol (MCP) Tool - An experimen

Use Cases

Manage Terraform environments via AI.
Read and analyze Terraform plans.
Apply infrastructure changes.
nwiizo

Maintainer

LicenseMIT License
Languagerust
Versionv1.0.0
UpdatedMay 14, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx tfmcp

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Terraform MCP

tfmcp is an experimental Rust-based CLI tool that wraps the Terraform CLI as an MCP server, enabling AI assistants like Claude to read configurations, analyze plans, apply changes, and manage Terraform state through natural language. It exposes 31 MCP tools covering the full Terraform workflow โ€” from init and plan through apply, destroy, workspace management, security scanning, and Terraform Registry lookups. Infrastructure engineers use it to let AI assistants assist with Terraform operations, review infrastructure plans, and automate routine IaC tasks with built-in audit logging and safety guards.

Prerequisites

  • Rust 1.85.0 or later installed (for building from source) or a prebuilt tfmcp binary
  • Terraform CLI installed and available on PATH
  • An MCP-compatible client such as Claude Desktop
  • TERRAFORM_DIR environment variable set to your Terraform project directory (defaults to ~/terraform)
1

Install tfmcp from crates.io

Install the tfmcp binary using Cargo, the Rust package manager. This is the recommended installation method.

cargo install tfmcp
2

Or build from source

Alternatively, clone the repository and build locally if you want to modify the source.

git clone https://github.com/nwiizo/tfmcp.git && cd tfmcp && cargo install --path .
3

Verify Terraform is on PATH

tfmcp wraps the Terraform CLI, so it must be installed and accessible. Verify both are available.

terraform --version && tfmcp --version
4

Configure environment variables

Set the required and optional environment variables to control tfmcp behavior. TERRAFORM_DIR is the most important, pointing to your infrastructure directory.

export TERRAFORM_DIR=/path/to/your/terraform/project
export TFMCP_LOG_LEVEL=info
export TFMCP_ALLOW_DANGEROUS_OPS=false
export TFMCP_ALLOW_AUTO_APPROVE=false
export TFMCP_AUDIT_ENABLED=true
5

Configure Claude Desktop to use tfmcp

Add tfmcp to your Claude Desktop configuration. Use the absolute path to the tfmcp binary and pass 'mcp' as the argument to launch it in MCP server mode.

{
  "mcpServers": {
    "tfmcp": {
      "command": "/Users/you/.cargo/bin/tfmcp",
      "args": ["mcp"],
      "env": {
        "HOME": "/Users/you",
        "TERRAFORM_DIR": "/Users/you/infra/terraform",
        "TFMCP_LOG_LEVEL": "info",
        "TFMCP_ALLOW_DANGEROUS_OPS": "false"
      }
    }
  }
}

Terraform MCP Examples

Client configuration

Full Claude Desktop configuration for tfmcp with safety guards enabled and pointing to a Terraform project.

{
  "mcpServers": {
    "tfmcp": {
      "command": "/Users/you/.cargo/bin/tfmcp",
      "args": ["mcp"],
      "env": {
        "HOME": "/Users/you",
        "TERRAFORM_DIR": "/Users/you/projects/infra",
        "TFMCP_LOG_LEVEL": "info",
        "TFMCP_ALLOW_DANGEROUS_OPS": "false",
        "TFMCP_ALLOW_AUTO_APPROVE": "false",
        "TFMCP_AUDIT_ENABLED": "true",
        "TFMCP_AUDIT_LOG_FILE": "/Users/you/.tfmcp/audit.log"
      }
    }
  }
}

Prompts to try

Example prompts to manage Terraform infrastructure through the tfmcp MCP server.

- "Run terraform plan on my infrastructure and summarize what changes will be made"
- "List all resources currently in my Terraform state"
- "Check my Terraform configuration for formatting issues and security vulnerabilities"
- "Show me the dependency graph for the resources in my main.tf"
- "Search the Terraform Registry for an AWS RDS module and show me the latest version"

Troubleshooting Terraform MCP

tfmcp cannot find the terraform binary

Ensure Terraform is installed and on your system PATH. When running via Claude Desktop, the PATH may differ from your terminal. Set the full absolute path to terraform in the env block: 'PATH': '/usr/local/bin:/usr/bin:/bin' or specify TERRAFORM_BIN=/usr/local/bin/terraform if supported.

apply and destroy operations are blocked

These dangerous operations require TFMCP_ALLOW_DANGEROUS_OPS=true. Set this environment variable explicitly in your MCP server config env block. Additionally, TFMCP_ALLOW_AUTO_APPROVE=true is needed to skip interactive approval prompts.

cargo install tfmcp fails with Rust edition errors

tfmcp requires Rust 1.85.0 or later (edition 2024). Run 'rustup update stable' to upgrade your Rust toolchain to the latest stable version, then retry the installation.

Frequently Asked Questions about Terraform MCP

What is Terraform MCP?

Terraform MCP is a Model Context Protocol (MCP) server that ๐ŸŒ terraform model context protocol (mcp) tool - an experimental cli tool that enables ai assistants to manage and operate terraform environments. supports reading terraform configurations, analyzing plans, applying configurations, and managing state It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Terraform MCP?

Follow the installation instructions on the Terraform MCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Terraform MCP?

Terraform MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Terraform MCP free to use?

Yes, Terraform MCP is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "tfmcp": { "command": "npx", "args": ["-y", "tfmcp"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide โ†’

Ready to use Terraform MCP?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides