Terraform MCP Server
Query the Terraform Registry and manage HCP Terraform workspaces and runs from your AI assistant.
Terraform MCP Server
This page documents HashiCorp's official Terraform MCP server: hashicorp/terraform-mcp-server. It connects MCP clients to the public Terraform Registry and to HCP Terraform / Terraform Enterprise APIs.
Use it to look up provider, module, and policy documentation, and to inspect or manage HCP Terraform workspaces and runs.
What it Does
- Registry search: Find provider, module, and Sentinel policy documentation
- Provider details: Retrieve resource, data source, and function documentation, capabilities, and latest versions
- Module details: Retrieve inputs, outputs, examples, submodules, and latest versions
- HCP Terraform workspaces: List and inspect workspaces
- Runs and plans: List runs, inspect plan details, logs, and JSON output, and act on runs
Installation
The upstream project publishes the Docker image hashicorp/terraform-mcp-server.
# Docker (stdio)
docker run -i --rm -e TFE_TOKEN=YOUR_TOKEN hashicorp/terraform-mcp-server:1.3.0
Configuration
{
"mcpServers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"TFE_TOKEN=YOUR_TOKEN",
"hashicorp/terraform-mcp-server:1.3.0"
]
}
}
}
For HCP Terraform or Terraform Enterprise, also pass -e TFE_ADDRESS=https://app.terraform.io (or your TFE address). Add -e ENABLE_TF_OPERATIONS=true to enable destructive tools. To limit the tool surface, append --toolsets=registry or --tools=<names> after the image name.
Available Tools
| Tool | Purpose | Category |
|---|---|---|
search_providers | Find provider documentation by service name | Registry |
get_provider_details | Retrieve full documentation for a provider component | Registry |
get_provider_capabilities | Discover the resource types a provider supports | Registry |
get_latest_provider_version | Retrieve the latest version of a provider | Registry |
search_modules | Find modules by name or functionality | Registry |
get_module_details | Get inputs, outputs, examples, and submodules | Registry |
get_latest_module_version | Retrieve the latest version of a module | Registry |
search_policies | Find Sentinel policies by topic or requirement | Registry |
get_policy_details | Retrieve policy documentation | Registry |
list_workspaces | Search and list workspaces in an organization | HCP Terraform |
get_workspace_details | Get workspace configuration, variables, and state information | HCP Terraform |
list_runs | List or search runs in a workspace | HCP Terraform |
get_plan_details | Fetch metadata for a specific plan | HCP Terraform |
get_plan_logs | Retrieve the logs for a specific plan | HCP Terraform |
get_plan_json_output | Retrieve the structured JSON output of a plan | HCP Terraform |
action_run | Apply, discard, or cancel a run (requires ENABLE_TF_OPERATIONS=true) | HCP Terraform |
The full tool list is in the Terraform MCP server reference.
Common Workflows
Finding Provider Documentation
- Search providers for the service you are configuring
- Retrieve the full documentation for the relevant resource or data source
- Check the provider's capabilities and latest version
- Ask for a configuration example based on the returned documentation
Finding and Inspecting a Module
- Search modules by name or functionality
- Get module details for inputs, outputs, and examples
- Retrieve the latest module version
- Ask for a usage example based on the module documentation
Inspecting Runs and Plans
- List workspaces to find the target workspace
- List runs for that workspace
- Retrieve plan details, plan logs, or the plan JSON output
- Use
action_runonly whenENABLE_TF_OPERATIONS=trueis set
Example Prompts
- "Find the documentation for the AWS S3 bucket resource"
- "Show me modules for deploying a Kubernetes cluster on AWS"
- "What Sentinel policies are available for enforcing tagging?"
- "List my HCP Terraform workspaces"
- "Show the plan JSON output for the latest run in staging"
Troubleshooting
| Issue | Likely Cause | Solution |
|---|---|---|
| Docker command fails | Docker is not installed or running | Start Docker and confirm the hashicorp/terraform-mcp-server image can be pulled |
| Registry tools work but HCP Terraform tools are missing | No valid TFE_TOKEN | Set TFE_TOKEN; the terraform and registry-private toolsets are registered only with a valid token |
| Authentication errors | Wrong token or address | Verify TFE_TOKEN and TFE_ADDRESS; TFE_ADDRESS must include the protocol |
| Destructive tool is rejected | ENABLE_TF_OPERATIONS is not enabled | Set ENABLE_TF_OPERATIONS=true |
| Certificate error behind a TLS-inspecting proxy | The container does not trust the corporate CA | Configure the container to trust the proxy CA certificate; see the upstream README |
Supported Providers
The registry tools query the public Terraform Registry, so they cover providers and modules published there, including AWS, Azure, Google Cloud, Kubernetes, and others. The HCP Terraform tools operate on workspaces and runs in your organization.
Sources
Related Articles & Guides
Accessibility Scanner MCP Server
Accessibility Scanner MCP servers enable AI models to perform WCAG compliance checks, capture annotated screenshots, and generate detailed accessibility reports.
AWS MCP Server
Interact with Amazon Web Services through your AI assistant using the AWS API MCP Server.
Auth0 MCP Server
Auth0 MCP server enables AI models to interact with Auth0 identity and access management, including applications, APIs, actions, logs, and forms.