Terraform MCP Server
HashiCorp's official MCP server for Terraform, giving agents direct access to the public Terraform Registry (providers, modules, policies) and to HCP Terraform / Terraform Enterprise workspaces.
Overview
Terraform MCP Server connects an agent directly to the Terraform Registry API and, optionally, to HCP Terraform or Terraform Enterprise, so infrastructure-as-code suggestions are grounded in real provider and module documentation instead of a model's memory of an older Terraform version.
How it works
- It queries the public Terraform Registry for provider and module documentation, letting an agent look up the exact resource arguments and examples for the provider version you're actually using.
- With an HCP Terraform or Terraform Enterprise token, it can list organizations and workspaces, and manage workspace variables, tags and runs directly, not just read documentation.
- It supports both local stdio (for a single client on your machine) and Streamable HTTP (for a centrally hosted deployment shared across a team), with per-user token passthrough so a shared server enforces each user's own permissions.
- Workspace-mutating operations stay behind an explicit
ENABLE_TF_OPERATIONSflag, so read-only registry lookups work out of the box while anything that changes real infrastructure needs to be turned on deliberately. - It exposes usage metrics (tool call volume, latency, failures) via OpenTelemetry when running in HTTP mode, useful if you're running this centrally for a team rather than locally for yourself.
Examples
"Look up the current arguments for the aws_s3_bucket resource in the
latest AWS provider and add server-side encryption to this Terraform
file."
Notes
The license is Mozilla Public License 2.0 (MPL-2.0), a weak-copyleft license: you can use and modify it freely, including commercially, but changes to the licensed files themselves must stay MPL-2.0 if redistributed. It doesn't affect your own Terraform configurations or unrelated code.
Installation
You need Docker for the example config, or a Go binary if you prefer running it natively. An HCP Terraform or Terraform Enterprise token is only needed for workspace management, not for registry lookups.
- Add the server to your MCP client's config using the Docker-based block in the sidebar.
- Restart your client. Registry lookups (providers, modules, docs) work immediately with no extra setup.
- Optional: set an HCP Terraform/Terraform Enterprise token and
ENABLE_TF_OPERATIONS=trueif you also want the agent to manage workspaces and runs.
Related assets
Awesome MCP Servers
The largest community catalog of MCP servers: thousands of entries across dozens of categories (databases, browser automation, cloud, communication and more), tagged by language and scope.
Context7
Pulls updated, version-specific documentation and code examples straight from the source into your prompt, so agents stop citing outdated APIs or hallucinating ones that don't exist.
Terraform IaC Reviewer
Reviews and writes Terraform changes with a focus on state safety, least-privilege IAM, drift detection and a strict plan-before-apply discipline.