Terraform MCP Server
HashiCorp’s official MCP server for Terraform Registry, HCP Terraform, workspaces, and IaC automation.
- Skill Road
- Terraform MCP Server
Description
Terraform MCP Server is HashiCorp’s official Model Context Protocol server for Terraform. It connects MCP-capable AI clients to the Terraform ecosystem, including Terraform Registry, HCP Terraform, and Terraform Enterprise. The direct product link points to HashiCorp Developer documentation; the source code is in hashicorp/terraform-mcp-server. For Skill Road, this entry matters because infrastructure as code is a place where an agent needs more than fluent text generation: it must understand available modules, providers, workspaces, variables, and operational boundaries. Without a controlled source, a model can easily guess around current Terraform syntax or an organization’s real structure.
Terraform context for agents
According to HashiCorp, the server integrates public Registry APIs for providers, modules, and policies as well as HCP Terraform or Terraform Enterprise. It can list workspaces and, depending on the enabled toolset, support workspace operations. The README also documents resources, tool filtering, and metrics for tool calls. In practice, a coding agent can ask more targeted questions while writing or reviewing Terraform configuration, instead of relying only on training data. That is especially useful for teams that standardize modules, manage many workspaces, or need to reason about infrastructure changes without leaving the agent workflow.
Installation and transports
The documented local entry path is containerized, for example docker run -i --rm hashicorp/terraform-mcp-server. The README gives a direct claude mcp add command for Claude Code and separate examples for Codex CLI, Cursor, and VS Code. Alongside stdio, the server supports Streamable HTTP for centralized or distributed deployments. That is where security decisions become more important: address, token, allowed origins, TLS certificates, rate limits, and organization allowlists should be controlled server-side. A local developer setup is simpler; a central deployment needs explicit operating rules.
Permissions, tokens, and security limits
The server can expose Terraform data to the MCP client and LLM. HashiCorp itself warns not to use it with untrusted MCP clients or LLMs. In Streamable HTTP setups, TFE_ADDRESS cannot be supplied by clients through headers or query parameters; the server rejects those attempts so tokens are not redirected to a malicious Terraform address. Tokens should never be passed through query parameters. For centralized deployments, TLS, MCP_ALLOWED_ORIGINS, organization allowlists, and least-privilege Terraform permissions are essential. An agent should receive only the toolsets needed for the current task.
License, version, and GitHub stars
The repository is MPL-2.0 licensed. The GitHub API reported exactly 1,522 stars on 2026-09-07; that number is a snapshot, not proof of security, maintainability, or fit. Version 1.3.0 was used in the documented container examples. The server itself is open source, but useful capabilities depend on Terraform Registry, HCP Terraform or Terraform Enterprise, and the selected client. This entry does not state fixed prices; the official provider plans and the organization’s own infrastructure are decisive. The server is especially suitable for DevOps and platform teams that want IaC work in Claude Code, Codex, or Cursor to be grounded in official Terraform sources.
Requirements
Docker, an MCP client, and a suitably scoped API token for HCP Terraform or Terraform Enterprise.
Installation instructions
What the Terraform MCP Server is
According to HashiCorp, the Terraform MCP Server is a Model Context Protocol server that connects AI assistants with current information from the Terraform Registry as well as APIs from HCP Terraform and Terraform Enterprise. Terraform itself is an Infrastructure as Code tool: infrastructure such as cloud resources, networks, databases, or access rules is described in configuration files and then applied reproducibly. The MCP server extends that workflow by giving a compatible AI client structured tools for querying providers, modules, policies, workspaces, and private registry content. In plain language, this means the AI assistant doesn't have to guess from training data alone which Terraform resources or modules exist; during the task it can actively retrieve information from official Terraform sources and, where configured, from the user's own HCP Terraform organization. This is especially useful for fast-moving provider APIs, where outdated examples can easily lead to incorrect or insecure infrastructure.
Step 1: Prerequisites
The official README states that an MCP-capable AI client is required, such as Claude Desktop, Claude Code, Cursor, VS Code, Amazon Q Developer, Kiro, Codex CLI, or Gemini extensions, depending on the integration being used. For containerized operation, Docker must be installed and running. The server supports two transport types: stdio, meaning communication over standard input and output, and Streamable HTTP, where an HTTP endpoint such as /mcp is exposed. For public Registry queries, an HCP Terraform token is not necessarily required, but organization, workspace, and private registry features require a valid Terraform Enterprise or HCP Terraform API token. Relevant environment variables include TFE_ADDRESS for the Terraform Enterprise or HCP Terraform instance address, TFE_TOKEN for the API token, TRANSPORT_MODE for the transport mode, and optional TLS, CORS, and rate-limit settings for HTTP operation.
Step 2: Step-by-step setup
The exact configuration depends on the client. For local clients, setup usually means adding an MCP configuration block that either starts a Docker image or runs a locally installed binary with the appropriate arguments. In stdio mode, the server is intended for that one client process and is relatively easy to secure because no network address is opened. For centrally hosted environments, Streamable HTTP mode can be used; in that case host, port, endpoint, TLS certificate, allowed origins, session mode, and rate limits are configured via environment variables. HashiCorp also documents Helm charts and container builds for deployment scenarios. After configuration, it's wise to start with a harmless tool call, such as a provider or module search in the public Registry, before enabling features that can write to HCP Terraform or Terraform Enterprise or modify workspaces. This staged rollout lowers the risk that a misconfigured client can immediately perform broad actions.
Security and trust model
HashiCorp explicitly warns that, depending on the request, the MCP server may expose Terraform data to the MCP client and the LLM. That can include not only public Registry information but also organization, project, workspace, variable, and registry data when HCP Terraform is connected. For that reason the server should only be used with trusted clients and trusted language models. In HTTP mode, TLS, a tight CORS configuration, rate limits, and, where appropriate, an organization allowlist are among the most important protective measures. Token passthrough for centralized deployments is particularly sensitive: the server can forward requests on behalf of different users, which is only safe if headers, trusted proxy hops, and client IP forwarding are carefully controlled. API tokens should have minimal permissions, be rotated regularly, and never appear in repositories or prompt text.
Who should use it
The Terraform MCP Server is mainly useful for teams that already use Terraform professionally and want AI assistants to support them while writing, reviewing, or exploring infrastructure code. It is not so much a beginner tool that replaces Terraform, but rather an interface that brings official Terraform information into an assistant's working context. Compared with generic web search, it has the advantage of being focused directly on the Terraform Registry and HCP Terraform and of offering structured tools rather than freely interpreted web pages. Compared with custom scripts, it saves integration work, but it also requires trust in the MCP client chain. In production environments, every Terraform change proposed by the model should still go through terraform plan, code review, policy checks, and, where appropriate, manual approval.
docker run -i --rm hashicorp/terraform-mcp-server
Authentication
Some Registry functions work without a token; HCP Terraform/Terraform Enterprise requires TFE_TOKEN and a fixed TFE_ADDRESS.
Required access permissions
Permissions follow the Terraform token and enabled toolsets. Toolsets and individual tools can be filtered.
Transmitted or stored data
The server calls Terraform Registry and HCP/TFE APIs and returns results to the MCP client.
Security risks
Broad tokens, untrusted clients, or centralized HTTP endpoints without TLS/origin controls can expose or change infrastructure information.
License and costs
- License
- MPL-2.0
- Cost
- free
The server is open source. Costs depend on Terraform products, HCP/TFE usage, infrastructure, and the selected AI client.
Alternatives
Not recorded yet.
At a glance
- Provider
- HashiCorp
- Status
- Official server
- Deployment
- Local and remote
- Current version
- 1.3.0
- GitHub stars
- 1,562
- Last reviewed
- 07.09.2026
Repository and documentation
Categories
Supported clients
Related guides
Guides and background related to this entry.