Terraform MCP Server
Acerca de este servidor
El servidor oficial de Terraform MCP de HashiCorp. Permite a los agentes de IA integrarse sin problemas con el ecosistema Terraform: gestionar archivos de estado, planificar ejecuciones y escribir Infraestructura como Código (IaC).
Instalación
npx -y @hashicorp/terraform-mcp-serverGuía oficial de instalación del README (en inglés)
Usage with Visual Studio Code
Add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open User Settings (JSON).
More about using MCP server tools in VS Code's agent mode documentation.
<table>
<tr><th>Version 0.3.0+ or greater</th><th>Version 0.2.3 or lower</th></tr>
<tr valign=top>
<td>
{
"mcp": {
"servers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "TFE_TOKEN=${input:tfe_token}",
"-e", "TFE_ADDRESS=${input:tfe_address}",
"hashicorp/terraform-mcp-server:1.1.0"
]
}
},
"inputs": [
{
"type": "promptString",
"id": "tfe_token",
"description": "Terraform API Token",
"password": true
},
{
"type": "promptString",
"id": "tfe_address",
"description": "Terraform Address",
"password": false
}
]
}
}</td>
<td>
{
"mcp": {
"servers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"hashicorp/terraform-mcp-server:0.2.3"
]
}
}
}
}</td>
</tr>
</table>
Optionally, you can add a similar example (i.e. without the mcp key) to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.
<table>
<tr><th>Version 0.3.0+ or greater</th><th>Version 0.2.3 or lower</th></tr>
<tr valign=top>
<td>
{
"servers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "TFE_TOKEN=${input:tfe_token}",
"-e", "TFE_ADDRESS=${input:tfe_address}",
"hashicorp/terraform-mcp-server:1.1.0"
]
}
},
"inputs": [
{
"type": "promptString",
"id": "tfe_token",
"description": "Terraform API Token",
"password": true
},
{
"type": "promptString",
"id": "tfe_address",
"description": "Terraform Address",
"password": false
}
]
}</td>
<td>
{
"servers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"hashicorp/terraform-mcp-server:0.2.3"
]
}
}
}</td>
</tr>
</table>
Usage with Cursor
Add this to your Cursor config (~/.cursor/mcp.json) or via Settings → Cursor Settings → MCP:
<table>
<tr><th>Version 0.3.0+ or greater</th><th>Version 0.2.3 or lower</th></tr>
<tr valign=top>
<td>
{
"mcpServers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "TFE_ADDRESS=<<PASTE_TFE_ADDRESS_HERE>>",
"-e", "TFE_TOKEN=<<PASTE_TFE_TOKEN_HERE>>",
"hashicorp/terraform-mcp-server:1.1.0"
]
}
}
}</td>
<td>
{
"servers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"hashicorp/terraform-mcp-server:0.2.3"
]
}
}
}</td>
</tr>
</table>
<a href="cursor://anysphere.cursor-deeplink/mcp/install?name=terraform&config=eyJjb21tYW5kIjoiZG9ja2VyIiwiYXJncyI6WyJydW4iLCItaSIsIi0tcm0iLCJoYXNoaWNvcnAvdGVycmFmb3JtLW1jcC1zZXJ2ZXIiXX0%3D">
<img alt="Add terraform MCP server to Cursor" src="https://cursor.com/deeplink/mcp-install-dark.png" height="32" />
</a>
Usage with Claude Desktop / Amazon Q Developer / Kiro CLI
More about using MCP server tools in Claude Desktop user documentation. Read more about using MCP server in Amazon Q Developer and Kiro CLI.
<table>
<tr><th>Version 0.3.0+ or greater</th><th>Version 0.2.3 or lower</th></tr>
<tr valign=top>
<td>
{
"mcpServers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "TFE_ADDRESS=<<PASTE_TFE_ADDRESS_HERE>>",
"-e", "TFE_TOKEN=<<PASTE_TFE_TOKEN_HERE>>",
"hashicorp/terraform-mcp-server:1.1.0"
]
}
}
}</td>
<td>
{
"mcpServers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"hashicorp/terraform-mcp-server:0.2.3"
]
}
}
}</td>
</tr>
</table>
Usage with Claude Code
More about using and adding MCP server tools in Claude Code user documentation
- Local (
stdio) Transport
claude mcp add terraform -s user -t stdio -- docker run -i --rm hashicorp/terraform-mcp-server- Remote (
streamable-http) Transport
# Run server (example)
docker run -p 8080:8080 --rm -e TRANSPORT_MODE=streamable-http -e TRANSPORT_HOST=0.0.0.0 hashicorp/terraform-mcp-server
# Add to Claude Code
claude mcp add --transport http terraform http://localhost:8080/mcpUsage with Gemini extensions
For security, avoid hardcoding your credentials, create or update ~/.gemini/.env (where ~ is your home or project directory) for storing HCP Terraform or Terraform Enterprise credentials
# ~/.gemini/.env
TFE_ADDRESS=your_tfe_address_here
TFE_TOKEN=your_tfe_token_hereInstall the extension & run Gemini
gemini extensions install https://github.com/hashicorp/terraform-mcp-server
geminiUsage with Bob IDE / Shell
More about using and adding MCP servers tools in Bob IDE or Shell Using MCP in Bob.
<table>
<tr><th>Version 0.3.0+ or greater</th><th>Version 0.2.3 or lower</th></tr>
<tr valign=top>
<td>
{
"mcpServers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "TFE_ADDRESS=<<PASTE_TFE_ADDRESS_HERE>>",
"-e", "TFE_TOKEN=<<PASTE_TFE_TOKEN_HERE>>",
"hashicorp/terraform-mcp-server:1.1.0"
],
"disabled": false
}
}
}</td>
<td>
{
"mcpServers": {
"terraform": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"hashicorp/terraform-mcp-server:0.2.3"
],
"disabled": false
}
}
}</td>
</tr>
</table>
Preguntas frecuentes
¿Qué puede hacer Terraform MCP?
Permite a los agentes de IA escribir y ejecutar configuraciones de Terraform directamente: gestionar archivos de estado, ver y crear planes de ejecución, previsualizar cambios de recursos, y leer configuraciones y salidas de Terraform. Haciendo la gestión de infraestructura más inteligente y eficiente.
¿Terraform MCP necesita tener Terraform instalado?
Sí, necesitas tener Terraform CLI instalado localmente. El servidor MCP ejecuta operaciones llamando al comando terraform local, por lo que necesitarás Terraform instalado y credenciales de proveedor de nube configuradas.
¿Terraform MCP es gratuito?
Completamente gratuito y de código abierto (licencia BUSL), mantenido oficialmente por HashiCorp. El servidor MCP en sí es gratuito, pero gestionar recursos en la nube con Terraform incurrirá en cargos de tu proveedor de nube según el uso de recursos.