- Home
- MCP servers
- Terraform
Terraform
- typescript
0
GitHub Stars
typescript
Language
6 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"mjrestivo16-mcp-terraform": {
"command": "node",
"args": [
"/path/to/mcp-terraform/dist/index.js"
],
"env": {
"TERRAFORM_WORKING_DIR": "/path/to/terraform/projects"
}
}
}
}You can use this MCP server to manage Terraform configurations, state, workspaces, and infrastructure operations through a unified set of tools. It lets you plan, apply, destroy, format, and inspect Terraform projects from a consistent MCP interface, making it easier to automate and orchestrate IaC tasks across environments.
How to use
You interact with the Terraform MCP Server through your MCP client. Use the available tools to perform common Terraform activities without directly invoking the CLI. Start by ensuring your Terraform CLI is installed, credentials are configured, and you point the server at your working directory. You can run operations in a controlled, repeatable way and inspect outputs, state, and plans as part of your automation workflows.
How to install
Prerequisites: you need Node.js and npm installed on your machine. You also need Terraform installed and available in your PATH, plus your cloud provider credentials configured.
# Install dependencies for the MCP server
npm install
# Build the MCP server bundle
npm run build
# Start the server in development mode (example command shown here for reference)
npm run dev
Configuration and runtime setup
Configure the MCP server to point at your Terraform projects by setting a default working directory. You can set this as an environment variable and override it per run if needed.
export TERRAFORM_WORKING_DIR="/path/to/your/terraform/projects"
You can also provide this value through the runtime environment when you launch the server or via your MCP client configuration.
## Server connection and environment example
The MCP server is exposed as a local stdio endpoint. You connect by launching Node with the server entry script and supplying the working directory via an environment variable.
{ "mcpServers": { "terraform": { "command": "node", "args": ["/path/to/mcp-terraform/dist/index.js"], "env": { "TERRAFORM_WORKING_DIR": "/path/to/terraform/projects" } } } }
## Usage with Claude Desktop (example configuration)
If you use Claude Desktop, add a Terraform server config to your claude\_desktop\_config.json. This example shows the runtime command and environment variable needed to point at your Terraform projects.
{ "mcpServers": { "terraform": { "command": "node", "args": ["/path/to/mcp-terraform/dist/index.js"], "env": { "TERRAFORM_WORKING_DIR": "/path/to/terraform/projects" } } } }
## Additional notes
The server executes Terraform commands with the environment you provide, so ensure your credentials and sensitive data are managed securely. Use the available tools to organize workspaces, manage state, read and modify configuration files, and visualize dependencies. Always review plans carefully before applying changes to non-production environments.
## Available tools
### tf\_version
Retrieve Terraform version information to verify the installed Terraform CLI version.
### tf\_init
Initialize a Terraform working directory, with optional provider upgrades, preparing the environment for plan or apply.
### tf\_validate
Validate Terraform configuration syntax to catch errors before planning.
### tf\_plan
Create an execution plan to preview changes that Terraform will apply.
### tf\_apply
Apply Terraform changes to your infrastructure, updating real resources.
### tf\_destroy
Destroy Terraform-managed infrastructure according to the specified targets.
### tf\_output
Fetch Terraform outputs in JSON or plain text to feed into downstream steps.
### tf\_state\_list
List all resources currently tracked in Terraform state.
### tf\_state\_show
Show detailed information for a specific resource in the state.
### tf\_state\_rm
Remove a resource from Terraform state without deleting the actual resource.
### tf\_state\_mv
Move or rename a resource within Terraform state.
### tf\_import
Import existing infrastructure into Terraform state so it is managed by Terraform.
### tf\_refresh
Refresh Terraform state to reflect the real-world state.
### tf\_fmt
Format Terraform configuration files to maintain code style consistency.
### tf\_workspace\_list
List all Terraform workspaces in the current directory.
### tf\_workspace\_select
Switch to a different Terraform workspace.
### tf\_workspace\_new
Create a new Terraform workspace.
### tf\_workspace\_delete
Delete a Terraform workspace.
### tf\_providers
List Terraform providers in use in your configuration.
### tf\_graph
Generate a dependency graph in DOT format for visualization.
### tf\_taint
Mark a resource to be recreated on the next apply.
### tf\_untaint
Remove a taint marking from a resource.
### tf\_show\_plan
Show details of a saved Terraform plan file.
### tf\_list\_files
List Terraform-related files in a directory (.tf, .tfvars, .tfstate).
### tf\_read\_file
Read contents of a Terraform configuration file.
### tf\_write\_file
Write content to a Terraform configuration file.