Terraform MCP Server

Terraform MCP Server

Terraform MCP Server is a protocol server that connects Terraform Registry APIs with modern AI workflows, enabling automated exploration, analysis, and integration of Terraform providers and modules inside agent-enabled development environments like VS Code and Claude Desktop.

Author: hashicorp


View Protocol

What is Terraform MCP Server?

Terraform MCP Server bridges Infrastructure as Code workflows with powerful AI agents by exposing Terraform Registry data and capabilities via standardized MCP tools. It enables developers to automate provider discovery, module exploration, and documentation retrieval, streamlining IaC development and empowering intelligent agents to interact directly with Terraform resources.

How to Configure Terraform MCP Server

  • With Docker: Simply add an MCP server configuration referencing the hashicorp/terraform-mcp-server image to your development environment. Example for VS Code:
    {
      "mcp": {
        "servers": {
          "terraform": {
            "command": "docker",
            "args": [
              "run",
              "-i",
              "--rm",
              "hashicorp/terraform-mcp-server"
            ]
          }
        }
      }
    }
    
  • From Source: Clone the official repository, run make build, and point your server configuration to the locally built binary.
    {
      "mcp": {
        "servers": {
          "terraform": {
            "command": "/path/to/terraform-mcp-server",
            "args": ["stdio"]
          }
        }
      }
    }
    
  • In Claude Desktop: Use the mcpServers key in your settings with the same Docker (or local binary) command options.

How to Use Terraform MCP Server

  1. Start your development environment (VS Code, Claude Desktop, or other agent-ready tools).
  2. Configure the MCP server for Terraform as described above.
  3. Interact via AI agents or LLM-enabled chat – query providers, search modules, and fetch documentation directly from the Terraform Registry without manual browser lookup.
  4. Optionally share .vscode/mcp.json in your workspace to let others use your environment setup.
  5. Invoke available tools (like searchModules, getProviderDocs) using the interface of your chosen host environment for quick, context-rich Infrastructure as Code guidance.

Key Features

  • Direct integration with Terraform Registry APIs for live data on providers and modules
  • Exposes tools as MCP endpoints to automate discovery, retrieval, and exploration
  • Seamless interoperability with VS Code, Claude Desktop, and any MCP-compatible host
  • Supports containerized or local-source deployments
  • Provides raw and structured documentation in markdown for easy AI consumption
  • Facilitates AI-assisted IaC workflows with minimal manual configuration
  • Strong alignment with best practices in security, compliance, and automated infrastructure analysis

Use Cases

  • Automating the search and discovery of Terraform modules relevant to your project from within your IDE.
  • Quickly extracting, analyzing, or summarizing the documentation for provider resources or data sources.
  • Getting detailed input, output, and example information for modules without leaving your coding environment.
  • Empowering AI agents to recommend, review, or refactor Infrastructure as Code by supplying rich, real-time registry data.
  • Exploring available providers and validating best-fit module choices to enhance cost, security, and compliance outcomes.

FAQ

Q1: Do I need Docker to use Terraform MCP Server?
A: While Docker is the simplest path for most users, you can also build and run the server from source if you have Go installed.

Q2: Is my Terraform Registry data secure when accessed via MCP?
A: The server is designed to respect your development environment's security practices and can be run fully locally, without exposing sensitive infrastructure information externally.

Q3: Can I share my Terraform MCP Server configuration with teammates?
A: Yes, you can include the configuration in .vscode/mcp.json files for easy sharing across a codebase or team.

Q4: Which environments are currently supported?
A: Official documentation covers VS Code and Claude Desktop, but any MCP-compatible host may be used in principle.

Q5: How often are the outputs or recommendations updated?
A: Results are generated dynamically based on queries, so changes in the Terraform Registry or server updates are reflected immediately.