tfmcp: Terraform Model Context Protocol Tool

by nwiizo

370 583 downloads Not rated yet MIT

About

๐ŸŒ 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 with Claude Desktop integrati

Details

License
MIT

Explore

- ๐Ÿš€ Terraform Integration
Deeply integrates with the Terraform CLI to analyze and execute operations.

- ๐Ÿ“„ MCP Server Capabilities
Runs as a Model Context Protocol server, allowing AI assistants to access and manage Terraform.

- ๐Ÿ”ฌ Module Health Analysis
Whitebox approach to Infrastructure as Code with cohesion/coupling analysis, health scoring, and refactoring suggestions based on software engineering principles.

- ๐Ÿ“Š Resource Dependency Graph
Visualize resource relationships including explicit depends_on and implicit reference dependencies.

- ๐Ÿ“ฆ Module Registry Integration
Search and explore Terraform modules from the registry, get module details and versions.

- ๐Ÿ” Enterprise Security
Production-ready security controls with configurable policies, audit logging, and access restrictions.

- ๐Ÿ“Š Advanced Analysis
Detailed Terraform configuration analysis with best practice recommendations and security checks.

- ๐Ÿ“‹ Guideline Compliance (v0.1.8)
Future Architect Terraform guidelines integration with compliance scoring, secret detection, and variable quality checks.

- โšก๏ธ Blazing Fast
High-speed processing powered by the Rust ecosystem with optimized parsing and caching.

- ๐Ÿ› ๏ธ Automatic Setup
Automatically creates sample Terraform projects when needed, ensuring smooth operation even for new users.

- ๐Ÿณ Docker Support
Run tfmcp in a containerized environment with all dependencies pre-installed.

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name tfmcp: Terraform Model Context Protocol Tool
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

- Rust (edition 2021)
- Terraform CLI installed and available in PATH
- Claude Desktop (for AI assistant integration)
- Docker (optional, for containerized deployment)

cargo install --path .


docker run -it -e TFMCP_LOG_LEVEL=debug tfmcp

- TERRAFORM_DIR: Set this to specify a custom Terraform project directory. If not set, tfmcp will use the directory provided by command line arguments, configuration files, or fall back to ~/terraform. You can also change the project directory at runtime using the set_terraform_directory tool.
- TFMCP_LOG_LEVEL: Set to debug, info, warn, or error to control logging verbosity.
- TFMCP_DEMO_MODE: Set to true to enable demo mode with additional safety features.

- TFMCP_ALLOW_DANGEROUS_OPS: Set to true to enable apply/destroy operations (default: false)
- TFMCP_ALLOW_AUTO_APPROVE: Set to true to enable auto-approve for dangerous operations (default: false)
- TFMCP_MAX_RESOURCES: Set maximum number of resources that can be managed (default: 50)
- TFMCP_AUDIT_ENABLED: Set to false to disable audit logging (default: true)
- TFMCP_AUDIT_LOG_FILE: Custom path for audit log file (default: ~/.tfmcp/audit.log)
- TFMCP_AUDIT_LOG_SENSITIVE: Set to true to include sensitive information in audit logs (default: false)

```bash

Trust Score

โš ๏ธ This project includes production-ready security features but is still under active development. While the security system provides robust protection, please review all operations carefully in production environments. โš ๏ธ

tfmcp is a command-line tool that helps you interact with Terraform via the Model Context Protocol (MCP). It allows LLMs to manage and operate your Terraform environments, including:

tfmcp provides 31 MCP tools for AI assistants:

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "tfmcp: terraform model context protocol tool": {
            "tfmcp": {
                "command": "docker",
                "args": [
                    "build",
                    "-t",
                    "tfmcp",
                    "."
                ]
            }
        }
    }
}

McpServers

{
    "tfmcp": {
        "command": "docker",
        "args": [
            "build",
            "-t",
            "tfmcp",
            "."
        ]
    }
}

Trust Score

โš ๏ธ This project includes production-ready security features but is still under active development. While the security system provides robust protection, please review all operations carefully in production environments. โš ๏ธ

tfmcp is a command-line tool that helps you interact with Terraform via the Model Context Protocol (MCP). It allows LLMs to manage and operate your Terraform environments, including:

๐ŸŽฎ Demo

See tfmcp in action with Claude Desktop:

tfmcp Demo with Claude Desktop

- Reading Terraform configuration files
- Analyzing Terraform plan outputs
- Applying Terraform configurations
- Managing Terraform state
- Creating and modifying Terraform configurations

๐ŸŽ‰ Latest Release

The latest version of tfmcp (v0.1.9) is now available on Crates.io! You can easily install it using Cargo:

cargo install tfmcp

๐Ÿ†• What's New in v0.1.9

- ๐Ÿ“Š Plan Analysis: Structured plan analysis with risk scoring and recommendations - ๐Ÿ” State Analysis: Deep state inspection with drift detection - ๐Ÿ“ Workspace Management: Full terraform workspace support (list, show, new, select, delete) - ๐Ÿ“ฅ Import Helper: Guided resource import with config generation - โœจ Code Formatting: terraform fmt integration - ๐Ÿ”— Dependency Graph: terraform graph visualization with DOT output - ๐Ÿ“ค Output Management: terraform output access - ๐Ÿท๏ธ Taint/Untaint: Resource taint management (with deprecation notices for 1.5+) - ๐Ÿ”„ State Refresh: Explicit state refresh operations - ๐Ÿ“ฆ Provider Info: Detailed provider information with lock file parsing - ๐Ÿฆ€ Rust Edition 2024: Migrated to Rust Edition 2024 (requires Rust 1.85.0+)

Features

- ๐Ÿš€ Terraform Integration
Deeply integrates with the Terraform CLI to analyze and execute operations.

- ๐Ÿ“„ MCP Server Capabilities
Runs as a Model Context Protocol server, allowing AI assistants to access and manage Terraform.

- ๐Ÿ”ฌ Module Health Analysis
Whitebox approach to Infrastructure as Code with cohesion/coupling analysis, health scoring, and refactoring suggestions based on software engineering principles.

- ๐Ÿ“Š Resource Dependency Graph
Visualize resource relationships including explicit depends_on and implicit reference dependencies.

- ๐Ÿ“ฆ Module Registry Integration
Search and explore Terraform modules from the registry, get module details and versions.

- ๐Ÿ” Enterprise Security
Production-ready security controls with configurable policies, audit logging, and access restrictions.

- ๐Ÿ“Š Advanced Analysis
Detailed Terraform configuration analysis with best practice recommendations and security checks.

- ๐Ÿ“‹ Guideline Compliance (v0.1.8)
Future Architect Terraform guidelines integration with compliance scoring, secret detection, and variable quality checks.

- โšก๏ธ Blazing Fast
High-speed processing powered by the Rust ecosystem with optimized parsing and caching.

- ๐Ÿ› ๏ธ Automatic Setup
Automatically creates sample Terraform projects when needed, ensuring smooth operation even for new users.

- ๐Ÿณ Docker Support
Run tfmcp in a containerized environment with all dependencies pre-installed.

Installation

From Source

```bash
No reviews yet โ€” be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.

Videos about tfmcp: Terraform Model Context Protocol Tool

Relevant YouTube tutorials, setups, and demos