Terraform
Deploy the Terraform MCP server
This topic describes how to deploy the Terraform model context protocol (MCP) server in a Docker container on your local workstation. The Terraform MCP server connects to a client so that your LLM can use data stored in the Terraform registry to help you write Terraform configuration. Refer to the overview for additional information about the Terraform MCP server.
Note
This feature is currently in beta. Do not use beta functionality in production environments.
Overview
Complete the following steps to deploy the Terraform MCP server:
- Pull the Docker image
- Connect your client to the MCP server
- Configure your client
Requirements
One of the following Docker distributions is required:
- Docker Engine v20.10.21+
- Docker Desktop v4.14.0+
Refer to the Docker documentation for installation instructions.
The following MCP clients are supported:
- VS Code with CoPilot. Refer to the VS Code documentation for installation instructions.
- Cursor. Refer to the Cursor website for more information.
- Anthropic Claude Desktop. Refer to the Anthropic Claude Desktop documentation for installation instructions.
Enable MCP in your client
Refer to your client's documentation for instructions on enabling MCP:
Install the server
For VS Code, create an mcp.json
file in the .vscode
or .cursor
directory of your local workspace and add the following configuration:
{
"servers": {
"terraform-mcp-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"hashicorp/terraform-mcp-server:0.1.0"
]
}
}
}
For Claude Desktop MCP clients, create an mcp.json
file and add the following configuration:
{
"mcpServers": {
"servers": {
"hcp-terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"hashicorp/terraform-mcp-server:0.1.0"
]
}
}
}
}
Configure your MCP client
Complete the following steps if you are using Copilot in VS Code:
- Open the chat interface and choose Agent from the mode settings.
- Click the tools icon to verify that the Terraform MCP server tools are enabled.
Complete the following steps if you are using Cursor:
- Open the chat pane and choose Chat Settings from the ellipses menu.
- Choose Agent from the Default new chat mode** drop-down menu.
- Choose MCP from the Cursor Settings sidebar to verify that the Terraform MCP server tools are enabled.
Complete the following steps if you are using Claude Desktop:
- Open the chat pane and choose the search and tools slider icon to the bottom left of the chat pane.
- Click terraform-mcp-server to verify that all the tools are enabled.
Next steps
After downloading the Terraform MCP server and connecting it to your client, you can begin prompting your model about your Terraform configuration code. Refer to Prompt an AI model for more information.