Terraform MCP
๐ 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
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
Maintainer
Works with
Installation
Manual Installation
npx tfmcpConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
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)
Install tfmcp from crates.io
Install the tfmcp binary using Cargo, the Rust package manager. This is the recommended installation method.
cargo install tfmcpOr 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 .Verify Terraform is on PATH
tfmcp wraps the Terraform CLI, so it must be installed and accessible. Verify both are available.
terraform --version && tfmcp --versionConfigure 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=trueConfigure 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.
Terraform MCP Alternatives โ Similar Developer Tools Servers
Looking for alternatives to Terraform MCP? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
โ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
โ 155.8kJava ้ข่ฏ & ๅ็ซฏ้็จ้ข่ฏๆๅ๏ผ่ฆ็่ฎก็ฎๆบๅบ็กใๆฐๆฎๅบใๅๅธๅผใ้ซๅนถๅใ็ณป็ป่ฎพ่ฎกไธ AI ๅบ็จๅผๅ
Gemini CLI
โ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
โ 87.3kโญ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
โ 86.0kModel Context Protocol Servers
CC Switch
โ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
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.
Set Up Terraform MCP in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
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.