terraform
The Terraform MCP Server provides seamless integration with Terraform ecosystem, enabling advanced automation and interaction capabilities for Infrastructure as Code (IaC) development.
claude mcp add --transport stdio hashicorp-terraform-mcp-server docker run -i --rm -e TFE_TOKEN=${input:tfe_token} -e TFE_ADDRESS=${input:tfe_address} hashicorp/terraform-mcp-server:0.4.0 \
--env LOG_LEVEL="info" \
--env TFE_TOKEN="Terraform API token" \
--env LOG_FORMAT="text" \
--env TFE_ADDRESS="HCP Terraform or Terraform Enterprise address (default: https://app.terraform.io)" \
--env MCP_ENDPOINT="/mcp" \
--env MCP_CORS_MODE="strict" \
--env MCP_KEEP_ALIVE="0" \
--env TRANSPORT_HOST="127.0.0.1" \
--env TRANSPORT_MODE="stdio or streamable-http (default: stdio)" \
--env TRANSPORT_PORT="8080" \
--env MCP_SESSION_MODE="stateful" \
--env MCP_TLS_KEY_FILE="" \
--env MCP_TLS_CERT_FILE="" \
--env MCP_ALLOWED_ORIGINS="" \
--env TFE_SKIP_TLS_VERIFY="false" \
--env ENABLE_TF_OPERATIONS="false" \
--env MCP_RATE_LIMIT_GLOBAL="10:20" \
--env MCP_RATE_LIMIT_SESSION="5:10"How to use
This Terraform MCP Server provides an interface to interact with Terraform Registry APIs and manage Terraform workspaces, providers, modules, and policies through the MCP protocol. It supports both stdio and StreamableHTTP transports, enabling local or network-accessible operation. After starting the server (e.g., via Docker), you can query Terraform workspaces, list organizations/projects, and perform workspace operations such as create, update, and delete, including handling variables and run management. The server is designed to work with HCP Terraform or Terraform Enterprise deployments and supports private registry access. When using the StreamableHTTP transport, ensure you configure MCP_ALLOWED_ORIGINS to restrict access to trusted origins for security. The server may expose Terraform data to MCP clients and LLMs depending on the query scope, so review outputs carefully before applying changes.
How to install
Prerequisites:
- Docker installed and running
- Access token for Terraform Enterprise (if using TFE) and Terraform address information
Installation steps:
- Ensure Docker is up and running on your host.
- Pull and run the Terraform MCP Server using the provided Docker image:
# Run in stdio mode (default)
docker run -it --rm \
-e TFE_TOKEN="<your-terraform-token>" \
-e TFE_ADDRESS="<https://app.terraform.io>" \
hashicorp/terraform-mcp-server:0.4.0
- If you need StreamableHTTP transport, configure and run with the appropriate environment variables or CLI flags as described in the README, ensuring MCP_ENDPOINT and related TLS/CORS settings are secured.
- Optional: Integrate with VS Code or your MCP client, using the provided examples in the README to format the server configuration for your environment.
Additional notes
Security notes:
- The server is intended for local use; if using StreamableHTTP transport, set MCP_ALLOWED_ORIGINS to trusted origins to mitigate DNS rebinding and cross-origin risks.
- Some Terraform data may be exposed to MCP clients; avoid using the server with untrusted MCP clients or LLMs.
- Review outputs and recommendations carefully to ensure they align with your security, cost, and compliance requirements before implementation.
Environment and configuration tips:
- Use TFE_ADDRESS and TFE_TOKEN to connect to your Terraform Enterprise or Cloud instance.
- Adjust MCP_RATE_LIMIT_GLOBAL and MCP_RATE_LIMIT_SESSION to enforce appropriate usage limits.
- For non-local deployments, provide valid TLS certificate and key in MCP_TLS_CERT_FILE and MCP_TLS_KEY_FILE.
- If enabling TF operations via ENABLE_TF_OPERATIONS, ensure explicit approvals are in place for tools that require elevated access.
Related MCP Servers
trpc-agent-go
trpc-agent-go is a powerful Go framework for building intelligent agent systems using large language models (LLMs) and tools.
station
Station is our open-source runtime that lets teams deploy agents on their own infrastructure with full control.
tiger-cli
Tiger CLI is the command-line interface for Tiger Cloud. It includes an MCP server for helping coding agents write production-level Postgres code.
gopls
MCP server for golang projects development: Expand AI Code Agent ability boundary to have a semantic understanding and determinisic information for golang projects.
kubernetes
A Model Context Protocol (MCP) server for the Kubernetes API.
gcp-cost
💰 An MCP server that enables AI assistants to estimate Google Cloud costs, powered by Cloud Billing Catalog API and built with Genkit for Go